diff options
author | Florian Dold <florian@dold.me> | 2022-03-14 18:31:30 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-14 18:31:36 +0100 |
commit | 332745862e728dc5e79a424698b2736c4f2683bf (patch) | |
tree | 6617d10c145868741f751853261c9c126b6f580e /packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts | |
parent | 9e7ee06ad1870339d011a0be27867cc36f94490d (diff) | |
download | wallet-core-332745862e728dc5e79a424698b2736c4f2683bf.tar.xz |
wallet: towards db-less benchmarking, some refactoring
Diffstat (limited to 'packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index af77e2be4..15a086ae1 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -53,7 +53,7 @@ import { Logger, MakeSyncSignatureRequest, PlanchetCreationRequest, - PlanchetCreationResult, + WithdrawalPlanchet, randomBytes, RecoupRefreshRequest, RecoupRequest, @@ -70,6 +70,9 @@ import { Timestamp, timestampTruncateToSecond, typedArrayConcat, + BlindedDenominationSignature, + RsaUnblindedSignature, + UnblindedSignature, } from "@gnu-taler/taler-util"; import bigint from "big-integer"; import { DenominationRecord, WireFee } from "../../db.js"; @@ -169,7 +172,7 @@ export class CryptoImplementation { */ async createPlanchet( req: PlanchetCreationRequest, - ): Promise<PlanchetCreationResult> { + ): Promise<WithdrawalPlanchet> { const denomPub = req.denomPub; if (denomPub.cipher === DenomKeyType.Rsa) { const reservePub = decodeCrock(req.reservePub); @@ -200,7 +203,7 @@ export class CryptoImplementation { priv: req.reservePriv, }); - const planchet: PlanchetCreationResult = { + const planchet: WithdrawalPlanchet = { blindingKey: encodeCrock(derivedPlanchet.bks), coinEv, coinPriv: encodeCrock(derivedPlanchet.coinPriv), @@ -428,6 +431,30 @@ export class CryptoImplementation { }; } + unblindDenominationSignature(req: { + planchet: WithdrawalPlanchet; + evSig: BlindedDenominationSignature; + }): UnblindedSignature { + if (req.evSig.cipher === DenomKeyType.Rsa) { + if (req.planchet.denomPub.cipher !== DenomKeyType.Rsa) { + throw new Error( + "planchet cipher does not match blind signature cipher", + ); + } + const denomSig = rsaUnblind( + decodeCrock(req.evSig.blinded_rsa_signature), + decodeCrock(req.planchet.denomPub.rsa_public_key), + decodeCrock(req.planchet.blindingKey), + ); + return { + cipher: DenomKeyType.Rsa, + rsa_signature: encodeCrock(denomSig), + }; + } else { + throw Error(`unblinding for cipher ${req.evSig.cipher} not implemented`); + } + } + /** * Unblind a blindly signed value. */ |