From c12a366d4937a5ede3dfe8cef3111e12fc39f23a Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Thu, 3 Aug 2023 21:44:53 +0200 Subject: adjustment of age-commitment and -proof generation age-withdraw requires that the public keys in the age groups that are too large for the commitment are derived from a published public key. --- packages/taler-wallet-core/src/crypto/cryptoImplementation.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts index 16d96eaa9..01d2677dc 100644 --- a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts @@ -720,9 +720,10 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { if (denomPub.age_mask) { const age = req.restrictAge || AgeRestriction.AGE_UNRESTRICTED; logger.info(`creating age-restricted planchet (age ${age})`); - maybeAcp = await AgeRestriction.restrictionCommit( + maybeAcp = await AgeRestriction.restrictionCommitSeeded( denomPub.age_mask, age, + stringToBytes(req.secretSeed) ); maybeAgeCommitmentHash = AgeRestriction.hashCommitment( maybeAcp.commitment, -- cgit v1.2.3 From 308a4282cbdde7376d88ca76e3eca967a1f02c46 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 5 Aug 2023 23:19:55 +0200 Subject: wallet-core: mock implementation of GetCurrencyInfo --- .../src/integrationtests/test-age-restrictions-peer.ts | 4 ++-- packages/taler-util/src/wallet-types.ts | 14 ++++++++++++++ packages/taler-wallet-core/src/db.ts | 5 ++++- packages/taler-wallet-core/src/wallet-api-types.ts | 10 ++++++++++ packages/taler-wallet-core/src/wallet.ts | 9 +++++++++ 5 files changed, 39 insertions(+), 3 deletions(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts index d15858322..45a4391cb 100644 --- a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts +++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts @@ -26,7 +26,7 @@ import { } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { defaultCoinConfig } from "../harness/denomStructures.js"; -import { GlobalTestState, WalletCli } from "../harness/harness.js"; +import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV2, createWalletDaemonWithClient, @@ -106,7 +106,7 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) { ); await wallet2.call(WalletApiOperation.ConfirmPeerPushCredit, { - peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId, + transactionId: checkResp.transactionId, }); const peerPullCreditDoneCond = wallet2.waitForNotificationCond( diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 38e5787ba..922b20862 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -379,6 +379,20 @@ export interface Balance { requiresUserInput: boolean; } +export interface GetCurrencyInfoRequest { + currency: string; + scope: ScopeInfo; +} + +export interface GetCurrencyInfoResponse { + decimalSeparator: string; + numFractionalDigits: number; + /** + * Is the currency name leading or trailing? + */ + isCurrencyNameLeading: boolean; +} + export interface InitRequest { skipDefaults?: boolean; } diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 3d2878d93..c7d0b0bda 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -711,7 +711,10 @@ export interface RewardCoinSource { coinIndex: number; } -export type CoinSource = WithdrawCoinSource | RefreshCoinSource | RewardCoinSource; +export type CoinSource = + | WithdrawCoinSource + | RefreshCoinSource + | RewardCoinSource; /** * CoinRecord as stored in the "coins" data store diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index eaa99a6c3..0c9755a3a 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -114,6 +114,8 @@ import { WithdrawUriInfoResponse, SharePaymentRequest, SharePaymentResult, + GetCurrencyInfoRequest, + GetCurrencyInfoResponse, } from "@gnu-taler/taler-util"; import { AuditorTrustRecord, WalletContractData } from "./db.js"; import { @@ -210,6 +212,7 @@ export enum WalletApiOperation { ApplyDevExperiment = "applyDevExperiment", ValidateIban = "validateIban", TestingWaitTransactionsFinal = "testingWaitTransactionsFinal", + GetCurrencyInfo = "getCurrencyInfo", } // group: Initialization @@ -601,6 +604,12 @@ export type ListCurrenciesOp = { response: WalletCurrencyInfo; }; +export type GetCurrencyInfoOp = { + op: WalletApiOperation.GetCurrencyInfo; + request: GetCurrencyInfoRequest; + response: GetCurrencyInfoResponse; +}; + // group: Deposits /** @@ -1072,6 +1081,7 @@ export type WalletOperations = { [WalletApiOperation.ApplyDevExperiment]: ApplyDevExperimentOp; [WalletApiOperation.ValidateIban]: ValidateIbanOp; [WalletApiOperation.TestingWaitTransactionsFinal]: TestingWaitTransactionsFinal; + [WalletApiOperation.GetCurrencyInfo]: GetCurrencyInfoOp; }; export type WalletCoreRequestType< diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index aab414e94..81ea26260 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -118,6 +118,7 @@ import { sampleWalletCoreTransactions, validateIban, codecForSharePaymentRequest, + GetCurrencyInfoResponse, } from "@gnu-taler/taler-util"; import { HttpRequestLibrary, @@ -1395,6 +1396,14 @@ async function dispatchRequestInternal( const resp = await getBackupRecovery(ws); return resp; } + case WalletApiOperation.GetCurrencyInfo: { + const resp: GetCurrencyInfoResponse = { + decimalSeparator: ",", + isCurrencyNameLeading: false, + numFractionalDigits: 2, + }; + return resp; + } case WalletApiOperation.ImportBackupRecovery: { const req = codecForAny().decode(payload); await loadBackupRecovery(ws, req); -- cgit v1.2.3 From 6286699f26f486a9406827ef7359f62896a2dada Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 5 Aug 2023 23:34:25 +0200 Subject: -validation --- packages/taler-util/src/wallet-types.ts | 52 +++++++++++++++++++--- packages/taler-wallet-core/src/wallet-api-types.ts | 8 ++-- packages/taler-wallet-core/src/wallet.ts | 6 ++- 3 files changed, 56 insertions(+), 10 deletions(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 922b20862..42d54752a 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -379,11 +379,44 @@ export interface Balance { requiresUserInput: boolean; } +export const codecForScopeInfoGlobal = (): Codec => + buildCodecForObject() + .property("currency", codecForString()) + .property("type", codecForConstString(ScopeType.Global)) + .build("ScopeInfoGlobal"); + +export const codecForScopeInfoExchange = (): Codec => + buildCodecForObject() + .property("currency", codecForString()) + .property("type", codecForConstString(ScopeType.Exchange)) + .property("url", codecForString()) + .build("ScopeInfoExchange"); + +export const codecForScopeInfoAuditor = (): Codec => + buildCodecForObject() + .property("currency", codecForString()) + .property("type", codecForConstString(ScopeType.Auditor)) + .property("url", codecForString()) + .build("ScopeInfoAuditor"); + +export const codecForScopeInfo = (): Codec => + buildCodecForUnion() + .discriminateOn("type") + .alternative(ScopeType.Global, codecForScopeInfoGlobal()) + .alternative(ScopeType.Exchange, codecForScopeInfoExchange()) + .alternative(ScopeType.Auditor, codecForScopeInfoAuditor()) + .build("ScopeInfo"); + export interface GetCurrencyInfoRequest { - currency: string; scope: ScopeInfo; } +export const codecForGetCurrencyInfoRequest = + (): Codec => + buildCodecForObject() + .property("scope", codecForScopeInfo()) + .build("GetCurrencyInfoRequest"); + export interface GetCurrencyInfoResponse { decimalSeparator: string; numFractionalDigits: number; @@ -407,10 +440,19 @@ export enum ScopeType { Auditor = "auditor", } -export type ScopeInfo = - | { type: ScopeType.Global; currency: string } - | { type: ScopeType.Exchange; currency: string; url: string } - | { type: ScopeType.Auditor; currency: string; url: string }; +export type ScopeInfoGlobal = { type: ScopeType.Global; currency: string }; +export type ScopeInfoExchange = { + type: ScopeType.Exchange; + currency: string; + url: string; +}; +export type ScopeInfoAuditor = { + type: ScopeType.Auditor; + currency: string; + url: string; +}; + +export type ScopeInfo = ScopeInfoGlobal | ScopeInfoExchange | ScopeInfoAuditor; export interface BalancesResponse { balances: Balance[]; diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 0c9755a3a..36c4809af 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -212,7 +212,7 @@ export enum WalletApiOperation { ApplyDevExperiment = "applyDevExperiment", ValidateIban = "validateIban", TestingWaitTransactionsFinal = "testingWaitTransactionsFinal", - GetCurrencyInfo = "getCurrencyInfo", + GetScopedCurrencyInfo = "getScopedCurrencyInfo", } // group: Initialization @@ -604,8 +604,8 @@ export type ListCurrenciesOp = { response: WalletCurrencyInfo; }; -export type GetCurrencyInfoOp = { - op: WalletApiOperation.GetCurrencyInfo; +export type GetScopedCurrencyInfoOp = { + op: WalletApiOperation.GetScopedCurrencyInfo; request: GetCurrencyInfoRequest; response: GetCurrencyInfoResponse; }; @@ -1081,7 +1081,7 @@ export type WalletOperations = { [WalletApiOperation.ApplyDevExperiment]: ApplyDevExperimentOp; [WalletApiOperation.ValidateIban]: ValidateIbanOp; [WalletApiOperation.TestingWaitTransactionsFinal]: TestingWaitTransactionsFinal; - [WalletApiOperation.GetCurrencyInfo]: GetCurrencyInfoOp; + [WalletApiOperation.GetScopedCurrencyInfo]: GetScopedCurrencyInfoOp; }; export type WalletCoreRequestType< diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 81ea26260..dfa41d60e 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -119,6 +119,7 @@ import { validateIban, codecForSharePaymentRequest, GetCurrencyInfoResponse, + codecForGetCurrencyInfoRequest, } from "@gnu-taler/taler-util"; import { HttpRequestLibrary, @@ -1396,7 +1397,10 @@ async function dispatchRequestInternal( const resp = await getBackupRecovery(ws); return resp; } - case WalletApiOperation.GetCurrencyInfo: { + case WalletApiOperation.GetScopedCurrencyInfo: { + logger.info(`payload: ${j2s(payload)}`); + // Ignore result, just validate in this mock implementation + codecForGetCurrencyInfoRequest().decode(payload); const resp: GetCurrencyInfoResponse = { decimalSeparator: ",", isCurrencyNameLeading: false, -- cgit v1.2.3 From 0547df9538657c36d733ff9617704e7c115adefa Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 5 Aug 2023 23:36:32 +0200 Subject: -remove logging --- packages/taler-wallet-core/src/wallet.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index dfa41d60e..78fb8789e 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1398,7 +1398,6 @@ async function dispatchRequestInternal( return resp; } case WalletApiOperation.GetScopedCurrencyInfo: { - logger.info(`payload: ${j2s(payload)}`); // Ignore result, just validate in this mock implementation codecForGetCurrencyInfoRequest().decode(payload); const resp: GetCurrencyInfoResponse = { -- cgit v1.2.3 From 44aeaba7b4d21e518928ca545b114e2a8e8c2a24 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 5 Aug 2023 23:56:07 +0200 Subject: wallet-core: introduce tiny digits --- packages/taler-util/src/wallet-types.ts | 1 + packages/taler-wallet-core/src/wallet.ts | 1 + 2 files changed, 2 insertions(+) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 42d54752a..3179cd6f3 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -420,6 +420,7 @@ export const codecForGetCurrencyInfoRequest = export interface GetCurrencyInfoResponse { decimalSeparator: string; numFractionalDigits: number; + numTinyDigits: number; /** * Is the currency name leading or trailing? */ diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 78fb8789e..796a96f14 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1404,6 +1404,7 @@ async function dispatchRequestInternal( decimalSeparator: ",", isCurrencyNameLeading: false, numFractionalDigits: 2, + numTinyDigits: 1, }; return resp; } -- cgit v1.2.3