taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit e1fe553756596224378f80bb630ef453c0a6e330
parent 29faccd67d87d66533405bcbe4ebc68127ac678a
Author: Florian Dold <florian@dold.me>
Date:   Thu, 24 Apr 2025 15:46:48 +0200

util: adjust refresh rc computation to exchange

Diffstat:
Mpackages/taler-wallet-core/src/crypto/cryptoImplementation.ts | 33++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts @@ -91,6 +91,7 @@ import { TalerProtocolTimestamp, TalerSignaturePurpose, timestampRoundedToBuffer, + toHexString, TokenEnvelope, TokenIssueBlindSig, TokenIssuePublicKey, @@ -134,6 +135,8 @@ import { const logger = new Logger("cryptoImplementation.ts"); +const debugDumpSigs = false; + /** * Interface for (asynchronous) cryptographic operations that * Taler uses. @@ -1496,13 +1499,28 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { const sessionHc = createHashContext(); sessionHc.update(decodeCrock(sessionPublicSeed)); + // For CS, we'd need to also read the blinding_seed into sessionHc. sessionHc.update(decodeCrock(meltCoinPub)); sessionHc.update(bufferFromAmount(valueWithFee)); + if (debugDumpSigs) { + logger.info( + `hashing session seed: ${toHexString(decodeCrock(sessionPublicSeed))}`, + ); + logger.info( + `hashing melt coin pub: ${toHexString(decodeCrock(meltCoinPub))}`, + ); + logger.info( + `hashing amount: ${toHexString(bufferFromAmount(valueWithFee))}`, + ); + } + for (let i = 0; i < kappa; i++) { const planchets: RefreshPlanchetInfo[] = []; const nonce = noncesBytes.slice(i * 64, i * 64 + 64); + const planchetsHc = createHashContext(); + const coinLink = buildSigPS(TalerSignaturePurpose.WALLET_COIN_LINK) .put(nonce) .put(coinDenomsHash) @@ -1568,10 +1586,16 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { ageCommitmentProof: newAc, }; planchets.push(planchet); - sessionHc.update(coinEvHash); + planchetsHc.update(coinEvHash); } } + const planchetsHash = planchetsHc.finish(); + if (debugDumpSigs) { + logger.info(`planchets hash ${i}: ${toHexString(planchetsHash)}`); + } + sessionHc.update(planchetsHash); + planchetsForGammas.push(planchets); } @@ -1595,6 +1619,13 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { .put(bufferFromAmount(feeRefresh)) .build(); + if (debugDumpSigs) { + logger.info(`melt signature blob:`); + logger.info(toHexString(confirmData)); + logger.info(`valueWithFee: ${Amounts.stringify(valueWithFee)}`); + logger.info(`meltFee: ${Amounts.stringify(feeRefresh)}`); + } + const confirmSigResp = await tci.eddsaSign(tci, { msg: encodeCrock(confirmData), priv: meltCoinPriv,