anastasis: implement user id derivation
This commit is contained in:
parent
e2fe2d6db1
commit
0bbaafcd36
@ -1,4 +1,5 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
|
import { userIdentifierDerive } from "./crypto.js";
|
||||||
|
|
||||||
// Vector generated with taler-anastasis-tvg
|
// Vector generated with taler-anastasis-tvg
|
||||||
const userIdVector = {
|
const userIdVector = {
|
||||||
@ -12,5 +13,9 @@ const userIdVector = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test("user ID derivation", async (t) => {
|
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);
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,27 @@
|
|||||||
|
import {
|
||||||
|
canonicalJson,
|
||||||
|
decodeCrock,
|
||||||
|
encodeCrock,
|
||||||
|
stringToBytes,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import { argon2id } from "hash-wasm";
|
import { argon2id } from "hash-wasm";
|
||||||
|
|
||||||
async function userIdentifierDerive(
|
export async function userIdentifierDerive(
|
||||||
idData: any,
|
idData: any,
|
||||||
serverSalt: string,
|
serverSalt: string,
|
||||||
): Promise<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 {
|
// interface Keypair {
|
||||||
|
Loading…
Reference in New Issue
Block a user