summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/crypto
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-01-05 20:29:55 +0100
committerFlorian Dold <florian@dold.me>2022-01-05 20:29:55 +0100
commita7b89247e41c272027d9c90a13c9a76901019daa (patch)
tree229a80e2498ff0b2c788ac72a524012a9c9ae67a /packages/taler-wallet-core/src/crypto
parent188ff0b453631c21f39ec6027e19aa3d1e99c30a (diff)
downloadwallet-core-a7b89247e41c272027d9c90a13c9a76901019daa.tar.gz
wallet-core-a7b89247e41c272027d9c90a13c9a76901019daa.tar.bz2
wallet-core-a7b89247e41c272027d9c90a13c9a76901019daa.zip
wallet-core: towards exchange protocol v12
Diffstat (limited to 'packages/taler-wallet-core/src/crypto')
-rw-r--r--packages/taler-wallet-core/src/crypto/cryptoTypes.ts3
-rw-r--r--packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts37
2 files changed, 28 insertions, 12 deletions
diff --git a/packages/taler-wallet-core/src/crypto/cryptoTypes.ts b/packages/taler-wallet-core/src/crypto/cryptoTypes.ts
index 7d616ecb6..9b72dfbe2 100644
--- a/packages/taler-wallet-core/src/crypto/cryptoTypes.ts
+++ b/packages/taler-wallet-core/src/crypto/cryptoTypes.ts
@@ -27,7 +27,7 @@
/**
* Imports.
*/
-import { AmountJson, DenominationPubKey } from "@gnu-taler/taler-util";
+import { AmountJson, DenominationPubKey, ExchangeProtocolVersion } from "@gnu-taler/taler-util";
export interface RefreshNewDenomInfo {
count: number;
@@ -41,6 +41,7 @@ export interface RefreshNewDenomInfo {
* secret seed.
*/
export interface DeriveRefreshSessionRequest {
+ exchangeProtocolVersion: ExchangeProtocolVersion;
sessionSecretSeed: string;
kappa: number;
meltCoinPub: string;
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
index b5987582a..9e2dc18f3 100644
--- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
@@ -36,6 +36,7 @@ import {
buildSigPS,
CoinDepositPermission,
DenomKeyType,
+ ExchangeProtocolVersion,
FreshCoin,
hashDenomPub,
RecoupRequest,
@@ -162,7 +163,7 @@ async function myEddsaSign(
export class CryptoImplementation {
static enableTracing = false;
- constructor(private primitiveWorker?: PrimitiveWorker) { }
+ constructor(private primitiveWorker?: PrimitiveWorker) {}
/**
* Create a pre-coin of the given denomination to be withdrawn from then given
@@ -364,18 +365,18 @@ export class CryptoImplementation {
}
isValidWireAccount(
- versionCurrent: number,
+ versionCurrent: ExchangeProtocolVersion,
paytoUri: string,
sig: string,
masterPub: string,
): boolean {
- if (versionCurrent === 10 || versionCurrent === 11) {
+ if (versionCurrent === ExchangeProtocolVersion.V12) {
const paytoHash = hash(stringToBytes(paytoUri + "\0"));
const p = buildSigPS(TalerSignaturePurpose.MASTER_WIRE_DETAILS)
.put(paytoHash)
.build();
return eddsaVerify(p, decodeCrock(sig), decodeCrock(masterPub));
- } else if (versionCurrent === 9) {
+ } else if (versionCurrent === ExchangeProtocolVersion.V9) {
const h = kdf(
64,
stringToBytes("exchange-wire-signature"),
@@ -623,13 +624,27 @@ export class CryptoImplementation {
}
const sessionHash = sessionHc.finish();
- const confirmData = buildSigPS(TalerSignaturePurpose.WALLET_COIN_MELT)
- .put(sessionHash)
- .put(decodeCrock(meltCoinDenomPubHash))
- .put(amountToBuffer(valueWithFee))
- .put(amountToBuffer(meltFee))
- .put(decodeCrock(meltCoinPub))
- .build();
+ let confirmData: Uint8Array;
+ if (req.exchangeProtocolVersion === ExchangeProtocolVersion.V9) {
+ confirmData = buildSigPS(TalerSignaturePurpose.WALLET_COIN_MELT)
+ .put(sessionHash)
+ .put(decodeCrock(meltCoinDenomPubHash))
+ .put(amountToBuffer(valueWithFee))
+ .put(amountToBuffer(meltFee))
+ .put(decodeCrock(meltCoinPub))
+ .build();
+ } else if (req.exchangeProtocolVersion === ExchangeProtocolVersion.V12) {
+ confirmData = buildSigPS(TalerSignaturePurpose.WALLET_COIN_MELT)
+ .put(sessionHash)
+ .put(decodeCrock(meltCoinDenomPubHash))
+ .put(amountToBuffer(valueWithFee))
+ .put(amountToBuffer(meltFee))
+ .build();
+ } else {
+ throw Error(
+ `Exchange protocol version (${req.exchangeProtocolVersion}) not supported`,
+ );
+ }
const confirmSigResp = await myEddsaSign(this.primitiveWorker, {
msg: encodeCrock(confirmData),