diff options
author | Florian Dold <florian@dold.me> | 2020-11-03 17:39:30 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-11-03 17:39:30 +0100 |
commit | dffb293f2a3fa836ee007f19e36f873ed5d295e7 (patch) | |
tree | d2be687c45163c4f3fa597cf77d3aceecbd87178 /packages/taler-wallet-core/src/crypto | |
parent | 0d37ec5e91f6704261070e01bb77d7c46f85b7a2 (diff) | |
download | wallet-core-dffb293f2a3fa836ee007f19e36f873ed5d295e7.tar.xz |
check contract terms signature, handle errors
Diffstat (limited to 'packages/taler-wallet-core/src/crypto')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts | 14 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts | 13 |
2 files changed, 27 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts index 44de6b674..286de5a17 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts @@ -398,6 +398,20 @@ export class CryptoApi { ); } + isValidContractTermsSignature( + contractTermsHash: string, + sig: string, + merchantPub: string, + ): Promise<boolean> { + return this.doRpc<boolean>( + "isValidContractTermsSignature", + 4, + contractTermsHash, + sig, + merchantPub, + ); + } + createRecoupRequest(coin: CoinRecord): Promise<RecoupRequest> { return this.doRpc<RecoupRequest>("createRecoupRequest", 1, coin); } diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index c39ebb44a..46ac7c8a6 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -80,6 +80,7 @@ enum SignaturePurpose { WALLET_COIN_MELT = 1202, TEST = 4242, MERCHANT_PAYMENT_OK = 1104, + MERCHANT_CONTRACT = 1101, WALLET_COIN_RECOUP = 1203, WALLET_COIN_LINK = 1204, EXCHANGE_CONFIRM_RECOUP = 1039, @@ -297,6 +298,18 @@ export class CryptoImplementation { return eddsaVerify(p, decodeCrock(sig), decodeCrock(masterPub)); } + isValidContractTermsSignature( + contractTermsHash: string, + sig: string, + merchantPub: string, + ): boolean { + const cthDec = decodeCrock(contractTermsHash); + const p = buildSigPS(SignaturePurpose.MERCHANT_CONTRACT) + .put(cthDec) + .build(); + return eddsaVerify(p, decodeCrock(sig), decodeCrock(merchantPub)); + } + /** * Create a new EdDSA key pair. */ |