summaryrefslogtreecommitdiff
path: root/packages/taler-util/src/taler-crypto.ts
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-06-30 17:52:24 -0600
committerIván Ávalos <avalos@disroot.org>2023-07-26 12:09:17 -0600
commitef51ba983f49b32a04bb8460f24f720f7952f306 (patch)
tree9a8aad3bc818066b8677c626887ce08631cb1837 /packages/taler-util/src/taler-crypto.ts
parent0b606028339d8256643ce60f11e72a090a301b58 (diff)
downloadwallet-core-ef51ba983f49b32a04bb8460f24f720f7952f306.tar.gz
wallet-core-ef51ba983f49b32a04bb8460f24f720f7952f306.tar.bz2
wallet-core-ef51ba983f49b32a04bb8460f24f720f7952f306.zip
WIP: initial work for Anastasis in qtart
Diffstat (limited to 'packages/taler-util/src/taler-crypto.ts')
-rw-r--r--packages/taler-util/src/taler-crypto.ts35
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);