diff options
Diffstat (limited to 'packages/aml-backoffice-ui/src/account.ts')
-rw-r--r-- | packages/aml-backoffice-ui/src/account.ts | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/packages/aml-backoffice-ui/src/account.ts b/packages/aml-backoffice-ui/src/account.ts index bd3c2003e..1c8cd7f53 100644 --- a/packages/aml-backoffice-ui/src/account.ts +++ b/packages/aml-backoffice-ui/src/account.ts @@ -1,14 +1,20 @@ import { - bytesToString, + PaytoUri, + TalerSignaturePurpose, + bufferForUint32, + buildSigPS, createEddsaKeyPair, decodeCrock, decryptWithDerivedKey, eddsaGetPublic, + eddsaSign, encodeCrock, encryptWithDerivedKey, getRandomBytesF, stringToBytes, + stringifyPaytoUri, } from "@gnu-taler/taler-util"; +import { AmlExchangeBackend } from "./types.js"; export interface Account { accountId: AccountId; @@ -45,6 +51,26 @@ export async function unlockAccount( return { accountId, signingKey }; } +export function buildQuerySignature(key: SigningKey): string { + const sigBlob = buildSigPS( + TalerSignaturePurpose.TALER_SIGNATURE_AML_QUERY, + ).build(); + + return encodeCrock(eddsaSign(sigBlob, key)); +} +export function buildDecisionSignature( + key: SigningKey, + payto: PaytoUri, + state: AmlExchangeBackend.AmlState, +): string { + const sigBlob = buildSigPS(TalerSignaturePurpose.TALER_SIGNATURE_AML_DECISION) + .put(decodeCrock(stringifyPaytoUri(payto))) + .put(bufferForUint32(state)) + .build(); + + return encodeCrock(eddsaSign(sigBlob, key)); +} + declare const opaque_Account: unique symbol; export type LockedAccount = string & { [opaque_Account]: true }; |