diff options
author | Florian Dold <florian@dold.me> | 2021-11-27 20:56:58 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-11-27 20:57:07 +0100 |
commit | 5c4c25516df9d65d29dc7f3f38b5a2a1a8e9e374 (patch) | |
tree | 4665e79a6033ab949de211fd9de8de8ca681c2e0 /packages/taler-wallet-core/src/operations/withdraw.ts | |
parent | 403de8170ef538ef74505859b1c04e3542cad9fb (diff) | |
download | wallet-core-5c4c25516df9d65d29dc7f3f38b5a2a1a8e9e374.tar.xz |
wallet: support both protocol versions
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 979bd0e53..8c9178f59 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -42,6 +42,7 @@ import { VersionMatchResult, DenomKeyType, LibtoolVersion, + UnblindedSignature, } from "@gnu-taler/taler-util"; import { CoinRecord, @@ -591,12 +592,28 @@ async function processPlanchetVerifyAndStoreCoin( const { planchet, exchangeBaseUrl } = d; const planchetDenomPub = planchet.denomPub; - if (planchetDenomPub.cipher !== DenomKeyType.Rsa) { - throw Error("cipher not supported"); + if ( + planchetDenomPub.cipher !== DenomKeyType.Rsa && + planchetDenomPub.cipher !== DenomKeyType.LegacyRsa + ) { + throw Error(`cipher (${planchetDenomPub.cipher}) not supported`); } - const evSig = resp.ev_sig; - if (evSig.cipher !== DenomKeyType.Rsa) { + let evSig = resp.ev_sig; + if (typeof resp.ev_sig === "string") { + evSig = { + cipher: DenomKeyType.LegacyRsa, + blinded_rsa_signature: resp.ev_sig, + }; + } else { + evSig = resp.ev_sig; + } + if ( + !( + evSig.cipher === DenomKeyType.Rsa || + evSig.cipher === DenomKeyType.LegacyRsa + ) + ) { throw Error("unsupported cipher"); } @@ -633,6 +650,19 @@ async function processPlanchetVerifyAndStoreCoin( return; } + let denomSig: UnblindedSignature; + if ( + planchet.denomPub.cipher === DenomKeyType.LegacyRsa || + planchet.denomPub.cipher === DenomKeyType.Rsa + ) { + denomSig = { + cipher: planchet.denomPub.cipher, + rsa_signature: denomSigRsa, + }; + } else { + throw Error("unsupported cipher"); + } + const coin: CoinRecord = { blindingKey: planchet.blindingKey, coinPriv: planchet.coinPriv, @@ -640,10 +670,7 @@ async function processPlanchetVerifyAndStoreCoin( currentAmount: planchet.coinValue, denomPub: planchet.denomPub, denomPubHash: planchet.denomPubHash, - denomSig: { - cipher: DenomKeyType.Rsa, - rsa_signature: denomSigRsa, - }, + denomSig, coinEvHash: planchet.coinEvHash, exchangeBaseUrl: exchangeBaseUrl, status: CoinStatus.Fresh, |