diff options
author | Iván Ávalos <avalos@disroot.org> | 2023-06-30 17:52:24 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2023-07-26 12:09:17 -0600 |
commit | ef51ba983f49b32a04bb8460f24f720f7952f306 (patch) | |
tree | 9a8aad3bc818066b8677c626887ce08631cb1837 /packages/taler-util | |
parent | 0b606028339d8256643ce60f11e72a090a301b58 (diff) | |
download | wallet-core-ef51ba983f49b32a04bb8460f24f720f7952f306.tar.xz |
WIP: initial work for Anastasis in qtart
Diffstat (limited to 'packages/taler-util')
-rw-r--r-- | packages/taler-util/package.json | 5 | ||||
-rw-r--r-- | packages/taler-util/src/taler-crypto.ts | 35 |
2 files changed, 38 insertions, 2 deletions
diff --git a/packages/taler-util/package.json b/packages/taler-util/package.json index 40fa94923..766163c48 100644 --- a/packages/taler-util/package.json +++ b/packages/taler-util/package.json @@ -69,11 +69,12 @@ "big-integer": "^1.6.51", "fflate": "^0.7.4", "jed": "^1.1.1", - "tslib": "^2.5.3" + "tslib": "^2.5.3", + "hash-wasm": "^4.9.0" }, "ava": { "files": [ "lib/**/*test.js" ] } -}
\ No newline at end of file +} 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); |