diff options
author | Florian Dold <florian@dold.me> | 2023-04-23 22:49:42 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-04-23 22:49:42 +0200 |
commit | eff3920bd5a2bff58d66ac72ba8bd2c1577f452f (patch) | |
tree | 1e7435da254b56bb9b8a543ce488aeb84f032ac9 /packages/taler-wallet-core/src/crypto/cryptoImplementation.ts | |
parent | 321252040efdb0712a38b3488297a7a802c5cb59 (diff) | |
download | wallet-core-eff3920bd5a2bff58d66ac72ba8bd2c1577f452f.tar.xz |
wallet-core: further towards deposit DD37
Diffstat (limited to 'packages/taler-wallet-core/src/crypto/cryptoImplementation.ts')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/cryptoImplementation.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts index 52d2dd24e..fa1271a7b 100644 --- a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts @@ -33,6 +33,7 @@ import { AmountString, BlindedDenominationSignature, bufferForUint32, + bufferForUint64, buildSigPS, CoinDepositPermission, CoinEnvelope, @@ -105,6 +106,8 @@ import { EncryptedContract, SignPurseMergeRequest, SignPurseMergeResponse, + SignRefundRequest, + SignRefundResponse, SignReservePurseCreateRequest, SignReservePurseCreateResponse, SignTrackTransactionRequest, @@ -233,6 +236,8 @@ export interface TalerCryptoInterface { signReservePurseCreate( req: SignReservePurseCreateRequest, ): Promise<SignReservePurseCreateResponse>; + + signRefund(req: SignRefundRequest): Promise<SignRefundResponse>; } /** @@ -409,6 +414,9 @@ export const nullCrypto: TalerCryptoInterface = { ): Promise<SignReservePurseCreateResponse> { throw new Error("Function not implemented."); }, + signRefund: function (req: SignRefundRequest): Promise<SignRefundResponse> { + throw new Error("Function not implemented."); + }, }; export type WithArg<X> = X extends (req: infer T) => infer R @@ -928,6 +936,7 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { const pub = decodeCrock(masterPub); return { valid: eddsaVerify(p, sig, pub) }; }, + /** * Check if the signature of a denomination is valid. */ @@ -1625,6 +1634,24 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { purseSig: purseSigResp.sig, }; }, + async signRefund( + tci: TalerCryptoInterfaceR, + req: SignRefundRequest, + ): Promise<SignRefundResponse> { + const refundSigBlob = buildSigPS(TalerSignaturePurpose.MERCHANT_REFUND) + .put(decodeCrock(req.contractTermsHash)) + .put(decodeCrock(req.coinPub)) + .put(bufferForUint64(req.rtransactionId)) + .put(amountToBuffer(req.refundAmount)) + .build(); + const refundSigResp = await tci.eddsaSign(tci, { + msg: encodeCrock(refundSigBlob), + priv: req.merchantPriv, + }); + return { + sig: refundSigResp.sig, + }; + }, }; function amountToBuffer(amount: AmountLike): Uint8Array { |