aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-11-17 10:23:22 +0100
committerFlorian Dold <florian@dold.me>2021-11-17 10:23:30 +0100
commit9f0429cb2f8ad9cb2e98a787139602d913c1aefa (patch)
treecda55e2d07a291dd2ff6f243bb423121ecf220b3 /packages/taler-wallet-core/src/operations/withdraw.ts
parenta994009d2f094c4d9c12da68dac3abb28bdef4b3 (diff)
downloadwallet-core-9f0429cb2f8ad9cb2e98a787139602d913c1aefa.tar.gz
wallet-core-9f0429cb2f8ad9cb2e98a787139602d913c1aefa.tar.bz2
wallet-core-9f0429cb2f8ad9cb2e98a787139602d913c1aefa.zip
wallet: implement exchange protocol v9
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts35
1 files changed, 26 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index 620ad88be..57bd49d23 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -41,6 +41,7 @@ import {
URL,
WithdrawUriInfoResponse,
VersionMatchResult,
+ DenomKeyType,
} from "@gnu-taler/taler-util";
import {
CoinRecord,
@@ -495,7 +496,7 @@ async function processPlanchetExchangeRequest(
]);
if (!denom) {
- console.error("db inconsistent: denom for planchet not found");
+ logger.error("db inconsistent: denom for planchet not found");
return;
}
@@ -589,16 +590,26 @@ async function processPlanchetVerifyAndStoreCoin(
const { planchet, exchangeBaseUrl } = d;
- const denomSig = await ws.cryptoApi.rsaUnblind(
- resp.ev_sig,
+ const planchetDenomPub = planchet.denomPub;
+ if (planchetDenomPub.cipher !== DenomKeyType.Rsa) {
+ throw Error("cipher not supported");
+ }
+
+ const evSig = resp.ev_sig;
+ if (evSig.cipher !== DenomKeyType.Rsa) {
+ throw Error("unsupported cipher");
+ }
+
+ const denomSigRsa = await ws.cryptoApi.rsaUnblind(
+ evSig.blinded_rsa_signature,
planchet.blindingKey,
- planchet.denomPub,
+ planchetDenomPub.rsa_public_key,
);
const isValid = await ws.cryptoApi.rsaVerify(
planchet.coinPub,
- denomSig,
- planchet.denomPub,
+ denomSigRsa,
+ planchetDenomPub.rsa_public_key,
);
if (!isValid) {
@@ -629,7 +640,10 @@ async function processPlanchetVerifyAndStoreCoin(
currentAmount: planchet.coinValue,
denomPub: planchet.denomPub,
denomPubHash: planchet.denomPubHash,
- denomSig,
+ denomSig: {
+ cipher: DenomKeyType.Rsa,
+ rsa_signature: denomSigRsa,
+ },
coinEvHash: planchet.coinEvHash,
exchangeBaseUrl: exchangeBaseUrl,
status: CoinStatus.Fresh,
@@ -728,7 +742,9 @@ export async function updateWithdrawalDenoms(
batchIdx++, current++
) {
const denom = denominations[current];
- if (denom.verificationStatus === DenominationVerificationStatus.Unverified) {
+ if (
+ denom.verificationStatus === DenominationVerificationStatus.Unverified
+ ) {
logger.trace(
`Validating denomination (${current + 1}/${
denominations.length
@@ -745,7 +761,8 @@ export async function updateWithdrawalDenoms(
);
denom.verificationStatus = DenominationVerificationStatus.VerifiedBad;
} else {
- denom.verificationStatus = DenominationVerificationStatus.VerifiedGood;
+ denom.verificationStatus =
+ DenominationVerificationStatus.VerifiedGood;
}
updatedDenominations.push(denom);
}