diff options
Diffstat (limited to 'packages')
7 files changed, 84 insertions, 26 deletions
diff --git a/packages/taler-util/src/talerCrypto.ts b/packages/taler-util/src/talerCrypto.ts index 934a04e84..90d52ca72 100644 --- a/packages/taler-util/src/talerCrypto.ts +++ b/packages/taler-util/src/talerCrypto.ts @@ -616,8 +616,21 @@ export function hashDenomPub(pub: DenominationPubKey): Uint8Array { return nacl.hash(uint8ArrayBuf); } else if (pub.cipher === DenomKeyType.LegacyRsa) { return hash(decodeCrock(pub.rsa_public_key)); + } else if (pub.cipher === DenomKeyType.ClauseSchnorr) { + const pubBuf = decodeCrock(pub.cs_public_key); + const hashInputBuf = new ArrayBuffer(pubBuf.length + 4 + 4); + const uint8ArrayBuf = new Uint8Array(hashInputBuf); + const dv = new DataView(hashInputBuf); + dv.setUint32(0, pub.age_mask ?? 0); + dv.setUint32(4, pub.cipher); + uint8ArrayBuf.set(pubBuf, 8); + return nacl.hash(uint8ArrayBuf); } else { - throw Error(`unsupported cipher (${pub.cipher}), unable to hash`); + throw Error( + `unsupported cipher (${ + (pub as DenominationPubKey).cipher + }), unable to hash`, + ); } } diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/talerTypes.ts index 37350c661..7305122bd 100644 --- a/packages/taler-util/src/talerTypes.ts +++ b/packages/taler-util/src/talerTypes.ts @@ -1123,7 +1123,8 @@ export interface RsaDenominationPubKey { export interface CsDenominationPubKey { cipher: DenomKeyType.ClauseSchnorr; - // FIXME: finish definition + age_mask: number; + cs_public_key: string; } export namespace DenominationPubKey { @@ -1151,6 +1152,16 @@ export namespace DenominationPubKey { return 1; } return strcmp(p1.rsa_public_key, p2.rsa_public_key); + } else if ( + p1.cipher === DenomKeyType.ClauseSchnorr && + p2.cipher === DenomKeyType.ClauseSchnorr + ) { + if ((p1.age_mask ?? 0) < (p2.age_mask ?? 0)) { + return -1; + } else if ((p1.age_mask ?? 0) > (p2.age_mask ?? 0)) { + return 1; + } + return strcmp(p1.cs_public_key, p2.cs_public_key); } else { throw Error("unsupported cipher"); } @@ -1171,6 +1182,7 @@ export const codecForDenominationPubKey = () => buildCodecForUnion<DenominationPubKey>() .discriminateOn("cipher") .alternative(1, codecForRsaDenominationPubKey()) + .alternative(2, codecForCsDenominationPubKey()) .alternative(3, codecForLegacyRsaDenominationPubKey()) .build("DenominationPubKey"); @@ -1186,6 +1198,12 @@ export const codecForLegacyRsaDenominationPubKey = () => .property("rsa_public_key", codecForString()) .build("LegacyRsaDenominationPubKey"); +export const codecForCsDenominationPubKey = () => + buildCodecForObject<CsDenominationPubKey>() + .property("cipher", codecForConstNumber(2)) + .property("cs_public_key", codecForString()) + .build("CsDenominationPubKey"); + export const codecForBankWithdrawalOperationPostResponse = (): Codec<BankWithdrawalOperationPostResponse> => buildCodecForObject<BankWithdrawalOperationPostResponse>() diff --git a/packages/taler-wallet-cli/src/harness/denomStructures.ts b/packages/taler-wallet-cli/src/harness/denomStructures.ts index 5ab9aca00..2ca777030 100644 --- a/packages/taler-wallet-cli/src/harness/denomStructures.ts +++ b/packages/taler-wallet-cli/src/harness/denomStructures.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -export interface CoinConfig { +export interface CoinCoinfigCommon { name: string; value: string; durationWithdraw: string; @@ -24,10 +24,24 @@ export interface CoinConfig { feeDeposit: string; feeRefresh: string; feeRefund: string; +} + +export interface CoinConfigRsa extends CoinCoinfigCommon { + cipher: "RSA"; rsaKeySize: number; } -const coinCommon = { +/** + * Clause Schnorr coin config. + */ +export interface CoinConfigCs extends CoinCoinfigCommon { + cipher: "CS"; +} + +export type CoinConfig = CoinConfigRsa | CoinConfigCs; + +const coinRsaCommon = { + cipher: "RSA" as const, durationLegal: "3 years", durationSpend: "2 years", durationWithdraw: "7 days", @@ -35,7 +49,7 @@ const coinCommon = { }; export const coin_ct1 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_ct1`, value: `${curr}:0.01`, feeDeposit: `${curr}:0.00`, @@ -45,7 +59,7 @@ export const coin_ct1 = (curr: string): CoinConfig => ({ }); export const coin_ct10 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_ct10`, value: `${curr}:0.10`, feeDeposit: `${curr}:0.01`, @@ -55,7 +69,7 @@ export const coin_ct10 = (curr: string): CoinConfig => ({ }); export const coin_u1 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_u1`, value: `${curr}:1`, feeDeposit: `${curr}:0.02`, @@ -65,7 +79,7 @@ export const coin_u1 = (curr: string): CoinConfig => ({ }); export const coin_u2 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_u2`, value: `${curr}:2`, feeDeposit: `${curr}:0.02`, @@ -75,7 +89,7 @@ export const coin_u2 = (curr: string): CoinConfig => ({ }); export const coin_u4 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_u4`, value: `${curr}:4`, feeDeposit: `${curr}:0.02`, @@ -85,7 +99,7 @@ export const coin_u4 = (curr: string): CoinConfig => ({ }); export const coin_u8 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_u8`, value: `${curr}:8`, feeDeposit: `${curr}:0.16`, @@ -95,7 +109,7 @@ export const coin_u8 = (curr: string): CoinConfig => ({ }); const coin_u10 = (curr: string): CoinConfig => ({ - ...coinCommon, + ...coinRsaCommon, name: `${curr}_u10`, value: `${curr}:10`, feeDeposit: `${curr}:0.2`, @@ -114,16 +128,6 @@ export const defaultCoinConfig = [ coin_u10, ]; -const coinCheapCommon = (curr: string) => ({ - durationLegal: "3 years", - durationSpend: "2 years", - durationWithdraw: "7 days", - rsaKeySize: 1024, - feeRefresh: `${curr}:0.2`, - feeRefund: `${curr}:0.2`, - feeWithdraw: `${curr}:0.2`, -}); - export function makeNoFeeCoinConfig(curr: string): CoinConfig[] { const cc: CoinConfig[] = []; @@ -134,6 +138,7 @@ export function makeNoFeeCoinConfig(curr: string): CoinConfig[] { const cent = ct % 100; cc.push({ + cipher: "RSA", durationLegal: "3 years", durationSpend: "2 years", durationWithdraw: "7 days", diff --git a/packages/taler-wallet-cli/src/harness/harness.ts b/packages/taler-wallet-cli/src/harness/harness.ts index fc155ba6a..fc489327f 100644 --- a/packages/taler-wallet-cli/src/harness/harness.ts +++ b/packages/taler-wallet-cli/src/harness/harness.ts @@ -430,7 +430,14 @@ function setCoin(config: Configuration, c: CoinConfig) { config.setString(s, "fee_withdraw", c.feeWithdraw); config.setString(s, "fee_refresh", c.feeRefresh); config.setString(s, "fee_refund", c.feeRefund); - config.setString(s, "rsa_keysize", `${c.rsaKeySize}`); + if (c.cipher === "RSA") { + config.setString(s, "rsa_keysize", `${c.rsaKeySize}`); + config.setString(s, "cipher", "RSA"); + } else if (c.cipher === "CS") { + config.setString(s, "cipher", "CS"); + } else { + throw new Error(); + } } /** @@ -1328,6 +1335,7 @@ export class ExchangeService implements ExchangeServiceInterface { helperCryptoRsaProc: ProcessWrapper | undefined; helperCryptoEddsaProc: ProcessWrapper | undefined; + helperCryptoCsProc: ProcessWrapper | undefined; constructor( private globalState: GlobalTestState, @@ -1373,6 +1381,12 @@ export class ExchangeService implements ExchangeServiceInterface { await cryptoEddsa.wait(); this.helperCryptoRsaProc = undefined; } + const cryptoCs = this.helperCryptoCsProc; + if (cryptoCs) { + cryptoCs.proc.kill("SIGTERM"); + await cryptoCs.wait(); + this.helperCryptoCsProc = undefined; + } } /** @@ -1491,6 +1505,12 @@ export class ExchangeService implements ExchangeServiceInterface { `exchange-crypto-eddsa-${this.name}`, ); + this.helperCryptoCsProc = this.globalState.spawnService( + "taler-exchange-secmod-cs", + ["-c", this.configFilename, "-LDEBUG", ...this.timetravelArgArr], + `exchange-crypto-cs-${this.name}`, + ); + this.helperCryptoRsaProc = this.globalState.spawnService( "taler-exchange-secmod-rsa", ["-c", this.configFilename, "-LDEBUG", ...this.timetravelArgArr], diff --git a/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts b/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts index d3ff89ae4..aee9fffa0 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-fee-regression.ts @@ -76,6 +76,7 @@ export async function createMyTestkudosEnvironment( await bank.pingUntilAvailable(); const coinCommon = { + cipher: "RSA" as const, durationLegal: "3 years", durationSpend: "2 years", durationWithdraw: "7 days", diff --git a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts index 87c4d958b..bf35b5382 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts @@ -27,7 +27,7 @@ import { setupDb, BankService, delayMs, - getPayto + getPayto, } from "../harness/harness.js"; import { withdrawViaBank, @@ -97,6 +97,7 @@ async function createTestEnvironment( await bank.pingUntilAvailable(); const coin_u1: CoinConfig = { + cipher: "RSA" as const, durationLegal: "3 years", durationSpend: "2 years", durationWithdraw: "7 days", diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts index 98aab75c4..844904132 100644 --- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts +++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts @@ -14,9 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { - minimatch -} from "@gnu-taler/taler-util"; +import { minimatch } from "@gnu-taler/taler-util"; import { GlobalTestState, runTestWithState, @@ -88,6 +86,7 @@ import { runMerchantSpecPublicOrdersTest } from "./test-merchant-spec-public-ord import { runExchangeTimetravelTest } from "./test-exchange-timetravel.js"; import { runDenomUnofferedTest } from "./test-denom-unoffered.js"; import { runWithdrawalFakebankTest } from "./test-withdrawal-fakebank.js"; +import { runClauseSchnorrTest } from "./test-clause-schnorr.js"; /** * Test runner. @@ -106,6 +105,7 @@ interface TestMainFunction { const allTests: TestMainFunction[] = [ runBankApiTest, runClaimLoopTest, + runClauseSchnorrTest, runDepositTest, runDenomUnofferedTest, runExchangeManagementTest, |