aboutsummaryrefslogtreecommitdiff
path: root/packages/anastasis-core/src/crypto.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/anastasis-core/src/crypto.ts')
-rw-r--r--packages/anastasis-core/src/crypto.ts34
1 files changed, 15 insertions, 19 deletions
diff --git a/packages/anastasis-core/src/crypto.ts b/packages/anastasis-core/src/crypto.ts
index 5e45f995f..3a9483aa1 100644
--- a/packages/anastasis-core/src/crypto.ts
+++ b/packages/anastasis-core/src/crypto.ts
@@ -26,8 +26,8 @@ import {
secretbox_open,
hash,
bytesToString,
+ hashArgon2id,
} from "@gnu-taler/taler-util";
-import { argon2id } from "hash-wasm";
export type Flavor<T, FlavorT extends string> = T & {
_flavor?: `anastasis.${FlavorT}`;
@@ -71,15 +71,13 @@ export async function userIdentifierDerive(
): Promise<UserIdentifier> {
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",
- });
+ const result = await hashArgon2id(
+ hashInput, // password
+ decodeCrock(serverSalt), // salt
+ 3, // iterations
+ 1024, // memoryLimit (kibibytes)
+ 64, // hashLength
+ );
return encodeCrock(result);
}
@@ -343,15 +341,13 @@ export async function secureAnswerHash(
truthUuid: TruthUuid,
questionSalt: TruthSalt,
): Promise<SecureAnswerHash> {
- const powResult = await argon2id({
- hashLength: 64,
- iterations: 3,
- memorySize: 1024 /* kibibytes */,
- parallelism: 1,
- password: stringToBytes(answer),
- salt: decodeCrock(questionSalt),
- outputType: "binary",
- });
+ const powResult = await hashArgon2id(
+ stringToBytes(answer), // password
+ decodeCrock(questionSalt), // salt
+ 3, // iterations
+ 1024, // memorySize (kibibytes)
+ 64, // hashLength
+ );
const kdfResult = kdfKw({
outputLength: 64,
salt: decodeCrock(truthUuid),