gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: anastasis: implement user id


From: gnunet
Subject: [taler-wallet-core] branch master updated: anastasis: implement user id derivation
Date: Thu, 07 Oct 2021 15:09:50 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 0bbaafcd anastasis: implement user id derivation
0bbaafcd is described below

commit 0bbaafcd36ce68f95faee0b91738a169848c7a90
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Oct 7 15:09:40 2021 +0200

    anastasis: implement user id derivation
---
 packages/anastasis-core/src/crypto.test.ts |  7 ++++++-
 packages/anastasis-core/src/crypto.ts      | 21 +++++++++++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/packages/anastasis-core/src/crypto.test.ts 
b/packages/anastasis-core/src/crypto.test.ts
index 346806fa..78ff2a65 100644
--- a/packages/anastasis-core/src/crypto.test.ts
+++ b/packages/anastasis-core/src/crypto.test.ts
@@ -1,4 +1,5 @@
 import test from "ava";
+import { userIdentifierDerive } from "./crypto.js";
 
 // Vector generated with taler-anastasis-tvg
 const userIdVector = {
@@ -12,5 +13,9 @@ const userIdVector = {
 };
 
 test("user ID derivation", async (t) => {
-  t.fail();
+  const res = await userIdentifierDerive(
+    userIdVector.input_id_data,
+    userIdVector.input_server_salt,
+  );
+  t.is(res, userIdVector.output_id);
 });
diff --git a/packages/anastasis-core/src/crypto.ts 
b/packages/anastasis-core/src/crypto.ts
index 54f27b64..c20d323a 100644
--- a/packages/anastasis-core/src/crypto.ts
+++ b/packages/anastasis-core/src/crypto.ts
@@ -1,10 +1,27 @@
+import {
+  canonicalJson,
+  decodeCrock,
+  encodeCrock,
+  stringToBytes,
+} from "@gnu-taler/taler-util";
 import { argon2id } from "hash-wasm";
 
-async function userIdentifierDerive(
+export async function userIdentifierDerive(
   idData: any,
   serverSalt: string,
 ): Promise<string> {
-  throw Error("not implemented");
+  const canonIdData = canonicalJson(idData);
+  const hashInput = stringToBytes(canonIdData);
+  const result = await argon2id({
+    hashLength: 64,
+    iterations: 3,
+    memorySize: 1024 /* kibibytes */,
+    parallelism: 1,
+    password: hashInput,
+    salt: decodeCrock(serverSalt),
+    outputType: "binary",
+  });
+  return encodeCrock(result);
 }
 
 // interface Keypair {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]