diff options
author | Florian Dold <florian@dold.me> | 2021-03-17 17:56:37 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-03-17 17:56:37 +0100 |
commit | 07cdfb2e4ec761021477271776b81f33af0e731d (patch) | |
tree | cb62b1d1a04e1e64b8ee47e78196e858727d2c0a /packages/taler-wallet-core/src/crypto | |
parent | 42a4d666f42ce94274995bfdae644444ff5f6d53 (diff) | |
download | wallet-core-07cdfb2e4ec761021477271776b81f33af0e731d.tar.xz |
towards wallet-core / util split
Diffstat (limited to 'packages/taler-wallet-core/src/crypto')
3 files changed, 153 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/crypto/cryptoTypes.ts b/packages/taler-wallet-core/src/crypto/cryptoTypes.ts new file mode 100644 index 000000000..922fbbfac --- /dev/null +++ b/packages/taler-wallet-core/src/crypto/cryptoTypes.ts @@ -0,0 +1,141 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** + * Types used by the wallet crypto worker. + * + * These types are defined in a separate file make tree shaking easier, since + * some components use these types (via RPC) but do not depend on the wallet + * code directly. + * + * @author Florian Dold <dold@taler.net> + */ + +/** + * Imports. + */ +import { AmountJson } from "@gnu-taler/taler-util"; + +export interface RefreshNewDenomInfo { + count: number; + value: AmountJson; + feeWithdraw: AmountJson; + denomPub: string; +} + +/** + * Request to derive a refresh session from the refresh session + * secret seed. + */ +export interface DeriveRefreshSessionRequest { + sessionSecretSeed: string; + kappa: number; + meltCoinPub: string; + meltCoinPriv: string; + meltCoinDenomPubHash: string; + newCoinDenoms: RefreshNewDenomInfo[]; + feeRefresh: AmountJson; +} + +/** + * + */ +export interface DerivedRefreshSession { + /** + * Public key that's being melted in this session. + */ + meltCoinPub: string; + + /** + * Signature to confirm the melting. + */ + confirmSig: string; + + /** + * Planchets for each cut-and-choose instance. + */ + planchetsForGammas: { + /** + * Public key for the coin. + */ + publicKey: string; + + /** + * Private key for the coin. + */ + privateKey: string; + + /** + * Blinded public key. + */ + coinEv: string; + + /** + * Hash of the blinded public key. + */ + coinEvHash: string; + + /** + * Blinding key used. + */ + blindingKey: string; + }[][]; + + /** + * The transfer keys, kappa of them. + */ + transferPubs: string[]; + + /** + * Private keys for the transfer public keys. + */ + transferPrivs: string[]; + + /** + * Hash of the session. + */ + hash: string; + + /** + * Exact value that is being melted. + */ + meltValueWithFee: AmountJson; +} + +export interface DeriveTipRequest { + secretSeed: string; + denomPub: string; + planchetIndex: number; +} + +/** + * Tipping planchet stored in the database. + */ +export interface DerivedTipPlanchet { + blindingKey: string; + coinEv: string; + coinEvHash: string; + coinPriv: string; + coinPub: string; +} + +export interface SignTrackTransactionRequest { + contractTermsHash: string; + wireHash: string; + coinPub: string; + merchantPriv: string; + merchantPub: string; +} diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts index d7eddd699..c124b89d4 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts @@ -22,11 +22,11 @@ /** * Imports. */ -import { CoinRecord, DenominationRecord, WireFee } from "../../types/dbTypes"; +import { CoinRecord, DenominationRecord, WireFee } from "../../db"; import { CryptoWorker } from "./cryptoWorker"; -import { RecoupRequest, CoinDepositPermission } from "../../types/talerTypes"; +import { RecoupRequest, CoinDepositPermission } from "@gnu-taler/taler-util"; import { BenchmarkResult, @@ -34,7 +34,7 @@ import { PlanchetCreationRequest, DepositInfo, MakeSyncSignatureRequest, -} from "../../types/walletTypes"; +} from "@gnu-taler/taler-util"; import * as timer from "../../util/timer"; import { Logger } from "../../util/logging"; @@ -44,7 +44,7 @@ import { DeriveRefreshSessionRequest, DeriveTipRequest, SignTrackTransactionRequest, -} from "../../types/cryptoTypes"; +} from "../cryptoTypes.js"; const logger = new Logger("cryptoApi.ts"); diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index 87fad8634..6e9427e57 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -26,23 +26,25 @@ * Imports. */ +// FIXME: Crypto should not use DB Types! import { CoinRecord, DenominationRecord, RefreshPlanchet, WireFee, CoinSourceType, -} from "../../types/dbTypes"; +} from "../../db.js"; -import { CoinDepositPermission, RecoupRequest } from "../../types/talerTypes"; +import { CoinDepositPermission, RecoupRequest } from "@gnu-taler/taler-util"; +// FIXME: These types should be internal to the wallet! import { BenchmarkResult, PlanchetCreationResult, PlanchetCreationRequest, DepositInfo, MakeSyncSignatureRequest, -} from "../../types/walletTypes"; -import { AmountJson, Amounts } from "../../util/amounts"; +} from "@gnu-taler/taler-util"; +import { AmountJson, Amounts } from "@gnu-taler/taler-util"; import * as timer from "../../util/timer"; import { encodeCrock, @@ -64,7 +66,7 @@ import { } from "../talerCrypto"; import { randomBytes } from "../primitives/nacl-fast"; import { kdf } from "../primitives/kdf"; -import { Timestamp, timestampTruncateToSecond } from "../../util/time"; +import { Timestamp, timestampTruncateToSecond } from "@gnu-taler/taler-util"; import { Logger } from "../../util/logging"; import { @@ -73,7 +75,7 @@ import { DeriveRefreshSessionRequest, DeriveTipRequest, SignTrackTransactionRequest, -} from "../../types/cryptoTypes"; +} from "../cryptoTypes.js"; const logger = new Logger("cryptoImplementation.ts"); |