summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/crypto/cryptoImplementation.ts')
-rw-r--r--packages/taler-wallet-core/src/crypto/cryptoImplementation.ts25
1 files changed, 22 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
index fa1271a7b..6b44c297d 100644
--- a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
+++ b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
@@ -35,6 +35,7 @@ import {
bufferForUint32,
bufferForUint64,
buildSigPS,
+ canonicalJson,
CoinDepositPermission,
CoinEnvelope,
createHashContext,
@@ -82,6 +83,7 @@ import {
TalerProtocolTimestamp,
TalerSignaturePurpose,
UnblindedSignature,
+ validateIban,
WireFee,
WithdrawalPlanchet,
} from "@gnu-taler/taler-util";
@@ -534,6 +536,9 @@ export interface WireAccountValidationRequest {
paytoUri: string;
sig: string;
masterPub: string;
+ conversionUrl?: string;
+ debitRestrictions?: any[];
+ creditRestrictions?: any[];
}
export interface EddsaKeypair {
@@ -975,9 +980,23 @@ export const nativeCryptoR: TalerCryptoInterfaceR = {
): Promise<ValidationResult> {
const { sig, masterPub, paytoUri } = req;
const paytoHash = hashTruncate32(stringToBytes(paytoUri + "\0"));
- const p = buildSigPS(TalerSignaturePurpose.MASTER_WIRE_DETAILS)
- .put(paytoHash)
- .build();
+ const pb = buildSigPS(TalerSignaturePurpose.MASTER_WIRE_DETAILS);
+ pb.put(paytoHash);
+ if (req.versionCurrent >= 15) {
+ let conversionUrlHash;
+ if (!req.conversionUrl) {
+ conversionUrlHash = new Uint8Array(64);
+ } else {
+ conversionUrlHash = hash(stringToBytes(req.conversionUrl + "\0"));
+ }
+ pb.put(conversionUrlHash);
+ pb.put(hash(stringToBytes(canonicalJson(req.debitRestrictions) + "\0")));
+ pb.put(hash(stringToBytes(canonicalJson(req.creditRestrictions) + "\0")));
+ }
+ const p = pb.build();
+ logger.info(`wire sig blob: ${encodeCrock(p)}`);
+ logger.info(`credit restrictions: ${j2s(req.creditRestrictions)}`);
+ logger.info(`debit restrictions: ${j2s(req.debitRestrictions)}`);
return { valid: eddsaVerify(p, decodeCrock(sig), decodeCrock(masterPub)) };
},