From 332745862e728dc5e79a424698b2736c4f2683bf Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Mar 2022 18:31:30 +0100 Subject: wallet: towards db-less benchmarking, some refactoring --- packages/taler-util/src/talerCrypto.ts | 16 ++++++++++++ packages/taler-util/src/talerTypes.ts | 46 ++++++++++++++++++++++++++++++++++ packages/taler-util/src/time.ts | 3 +++ packages/taler-util/src/walletTypes.ts | 2 +- 4 files changed, 66 insertions(+), 1 deletion(-) (limited to 'packages/taler-util/src') diff --git a/packages/taler-util/src/talerCrypto.ts b/packages/taler-util/src/talerCrypto.ts index 358da9dac..4d6e73671 100644 --- a/packages/taler-util/src/talerCrypto.ts +++ b/packages/taler-util/src/talerCrypto.ts @@ -785,6 +785,22 @@ export function setupRefreshTransferPub( }; } +/** + * + * @param paytoUri + * @param salt 16-byte salt + * @returns + */ +export function hashWire(paytoUri: string, salt: string): string { + const r = kdf( + 64, + stringToBytes(paytoUri + "\0"), + decodeCrock(salt), + stringToBytes("merchant-wire-signature"), + ); + return encodeCrock(r); +} + export enum TalerSignaturePurpose { MERCHANT_TRACK_TRANSACTION = 1103, WALLET_RESERVE_WITHDRAW = 1200, diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/talerTypes.ts index b38f788af..4ccfffce0 100644 --- a/packages/taler-util/src/talerTypes.ts +++ b/packages/taler-util/src/talerTypes.ts @@ -951,6 +951,15 @@ export interface MerchantPayResponse { sig: string; } +export interface ExchangeMeltRequest { + coin_pub: CoinPublicKeyString; + confirm_sig: EddsaSignatureString; + denom_pub_hash: HashCodeString; + denom_sig: UnblindedSignature; + rc: string; + value_with_fee: AmountString; +} + export interface ExchangeMeltResponse { /** * Which of the kappa indices does the client not have to reveal. @@ -1710,3 +1719,40 @@ export interface ExchangeRefreshRevealRequest { link_sigs: EddsaSignatureString[]; } + +export interface DepositSuccess { + // Optional base URL of the exchange for looking up wire transfers + // associated with this transaction. If not given, + // the base URL is the same as the one used for this request. + // Can be used if the base URL for /transactions/ differs from that + // for /coins/, i.e. for load balancing. Clients SHOULD + // respect the transaction_base_url if provided. Any HTTP server + // belonging to an exchange MUST generate a 307 or 308 redirection + // to the correct base URL should a client uses the wrong base + // URL, or if the base URL has changed since the deposit. + transaction_base_url?: string; + + // timestamp when the deposit was received by the exchange. + exchange_timestamp: Timestamp; + + // the EdDSA signature of TALER_DepositConfirmationPS using a current + // signing key of the exchange affirming the successful + // deposit and that the exchange will transfer the funds after the refund + // deadline, or as soon as possible if the refund deadline is zero. + exchange_sig: string; + + // public EdDSA key of the exchange that was used to + // generate the signature. + // Should match one of the exchange's signing keys from /keys. It is given + // explicitly as the client might otherwise be confused by clock skew as to + // which signing key was used. + exchange_pub: string; +} + +export const codecForDepositSuccess = (): Codec => + buildCodecForObject() + .property("exchange_pub", codecForString()) + .property("exchange_sig", codecForString()) + .property("exchange_timestamp", codecForTimestamp) + .property("transaction_base_url", codecOptional(codecForString())) + .build("DepositSuccess"); diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index 5fef0bf47..3b80b4ee0 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -78,6 +78,9 @@ export namespace Duration { return Math.ceil(d.d_ms / 1000 / 60 / 60 / 24 / 365); } export const fromSpec = durationFromSpec; + export function getForever(): Duration { + return { d_ms: "forever" }; + } } export namespace Timestamp { diff --git a/packages/taler-util/src/walletTypes.ts b/packages/taler-util/src/walletTypes.ts index b8433e261..444fac154 100644 --- a/packages/taler-util/src/walletTypes.ts +++ b/packages/taler-util/src/walletTypes.ts @@ -458,7 +458,7 @@ export interface TalerErrorDetails { details: unknown; } -export interface PlanchetCreationResult { +export interface WithdrawalPlanchet { coinPub: string; coinPriv: string; reservePub: string; -- cgit v1.2.3