summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-05-03 10:01:44 +0200
committerFlorian Dold <florian@dold.me>2023-05-03 10:01:51 +0200
commit1b0bec0363793996eff6483d36b844cfa2381404 (patch)
tree5f62533c0dfcc5d40c8d959e7dc71ce936fbf38b /packages/taler-wallet-core/src
parentda519af01fd3920b49a05cb3bebf0a9a6194abfc (diff)
downloadwallet-core-1b0bec0363793996eff6483d36b844cfa2381404.tar.gz
wallet-core-1b0bec0363793996eff6483d36b844cfa2381404.tar.bz2
wallet-core-1b0bec0363793996eff6483d36b844cfa2381404.zip
wallet-core: support new exchange wire account signature
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r--packages/taler-wallet-core/src/crypto/cryptoImplementation.ts25
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts3
-rw-r--r--packages/taler-wallet-core/src/versions.ts4
3 files changed, 27 insertions, 5 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)) };
},
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index b5e02e64d..d8fb95755 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -253,6 +253,9 @@ async function validateWireInfo(
paytoUri: a.payto_uri,
sig: a.master_sig,
versionCurrent,
+ conversionUrl: a.conversion_url,
+ creditRestrictions: a.credit_restrictions,
+ debitRestrictions: a.debit_restrictions,
});
isValid = v;
}
diff --git a/packages/taler-wallet-core/src/versions.ts b/packages/taler-wallet-core/src/versions.ts
index c3bc142f0..eedaf68f6 100644
--- a/packages/taler-wallet-core/src/versions.ts
+++ b/packages/taler-wallet-core/src/versions.ts
@@ -1,6 +1,6 @@
/*
This file is part of GNU Taler
- (C) 2019 Taler Systems S.A.
+ (C) 2019-2023 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -19,7 +19,7 @@
*
* Uses libtool's current:revision:age versioning.
*/
-export const WALLET_EXCHANGE_PROTOCOL_VERSION = "12:0:0";
+export const WALLET_EXCHANGE_PROTOCOL_VERSION = "15:0:2";
/**
* Protocol version spoken with the merchant.