diff options
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/taler-crypto.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/taler-util/src/taler-crypto.ts b/packages/taler-util/src/taler-crypto.ts index e3f7d49a8..cabe2b7d0 100644 --- a/packages/taler-util/src/taler-crypto.ts +++ b/packages/taler-util/src/taler-crypto.ts @@ -24,6 +24,7 @@ import * as nacl from "./nacl-fast.js"; import { hmacSha256, hmacSha512 } from "./kdf.js"; import bigint from "big-integer"; +import { argon2id } from "hash-wasm"; import { CoinEnvelope, CoinPublicKeyString, @@ -69,6 +70,13 @@ interface NativeTartLib { encodeCrock(buf: Uint8Array | ArrayBuffer): string; decodeCrock(str: string): Uint8Array; hash(buf: Uint8Array): Uint8Array; + hashArgon2id( + password: Uint8Array, + salt: Uint8Array, + iterations: number, + memorySize: number, + hashLength: number, + ): Uint8Array; eddsaGetPublic(buf: Uint8Array): Uint8Array; ecdheGetPublic(buf: Uint8Array): Uint8Array; eddsaSign(msg: Uint8Array, priv: Uint8Array): Uint8Array; @@ -253,6 +261,33 @@ export function decodeCrock(encoded: string): Uint8Array { return out; } +export async function hashArgon2id( + password: Uint8Array, + salt: Uint8Array, + iterations: number, + memorySize: number, + hashLength: number, +): Promise<Uint8Array> { + if (tart) { + return tart.hashArgon2id( + password, + salt, + iterations, + memorySize, + hashLength, + ); + } + return await argon2id({ + password: password, + salt: salt, + iterations: iterations, + memorySize: memorySize, + hashLength: hashLength, + parallelism: 1, + outputType: "binary", + }); +} + export function eddsaGetPublic(eddsaPriv: Uint8Array): Uint8Array { if (tart) { return tart.eddsaGetPublic(eddsaPriv); |