diff options
author | Florian Dold <florian@dold.me> | 2020-12-15 17:12:22 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-12-15 17:12:22 +0100 |
commit | c09c5bbe625566fc61c811160d2ccdab263327fa (patch) | |
tree | 4ce80e615bad8cf325b1b31aac957c6ce1ee0f05 /packages/taler-wallet-core/src/crypto/workers | |
parent | f332d61fb68fbc394f31337ddeb7d1fc114772d0 (diff) | |
download | wallet-core-c09c5bbe625566fc61c811160d2ccdab263327fa.tar.xz |
derive tipping planchets from seed, implement backup further
Diffstat (limited to 'packages/taler-wallet-core/src/crypto/workers')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts | 17 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts | 26 |
2 files changed, 15 insertions, 28 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts index 6a4264d2c..ef149823c 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts @@ -22,16 +22,7 @@ /** * Imports. */ -import { AmountJson } from "../../util/amounts"; - -import { - CoinRecord, - DenominationRecord, - RefreshSessionRecord, - TipPlanchet, - WireFee, - DenominationSelectionInfo, -} from "../../types/dbTypes"; +import { CoinRecord, DenominationRecord, WireFee } from "../../types/dbTypes"; import { CryptoWorker } from "./cryptoWorker"; @@ -49,7 +40,9 @@ import * as timer from "../../util/timer"; import { Logger } from "../../util/logging"; import { DerivedRefreshSession, + DerivedTipPlanchet, DeriveRefreshSessionRequest, + DeriveTipRequest, } from "../../types/cryptoTypes"; const logger = new Logger("cryptoApi.ts"); @@ -329,8 +322,8 @@ export class CryptoApi { return this.doRpc<PlanchetCreationResult>("createPlanchet", 1, req); } - createTipPlanchet(denom: DenominationRecord): Promise<TipPlanchet> { - return this.doRpc<TipPlanchet>("createTipPlanchet", 1, denom); + createTipPlanchet(req: DeriveTipRequest): Promise<DerivedTipPlanchet> { + return this.doRpc<DerivedTipPlanchet>("createTipPlanchet", 1, req); } hashString(str: string): Promise<string> { diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index d14f663e8..deaad42bb 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -30,11 +30,8 @@ import { CoinRecord, DenominationRecord, RefreshPlanchet, - RefreshSessionRecord, - TipPlanchet, WireFee, CoinSourceType, - DenominationSelectionInfo, } from "../../types/dbTypes"; import { CoinDepositPermission, RecoupRequest } from "../../types/talerTypes"; @@ -59,25 +56,25 @@ import { rsaUnblind, stringToBytes, createHashContext, - createEcdheKeyPair, keyExchangeEcdheEddsa, setupRefreshPlanchet, rsaVerify, - getRandomBytes, setupRefreshTransferPub, + setupTipPlanchet, } from "../talerCrypto"; import { randomBytes } from "../primitives/nacl-fast"; import { kdf } from "../primitives/kdf"; import { Timestamp, - getTimestampNow, timestampTruncateToSecond, } from "../../util/time"; import { Logger } from "../../util/logging"; import { DerivedRefreshSession, + DerivedTipPlanchet, DeriveRefreshSessionRequest, + DeriveTipRequest, } from "../../types/cryptoTypes"; const logger = new Logger("cryptoImplementation.ts"); @@ -199,21 +196,18 @@ export class CryptoImplementation { /** * Create a planchet used for tipping, including the private keys. */ - createTipPlanchet(denom: DenominationRecord): TipPlanchet { - const denomPub = decodeCrock(denom.denomPub); - const coinKeyPair = createEddsaKeyPair(); + createTipPlanchet(req: DeriveTipRequest): DerivedTipPlanchet { + const fc = setupTipPlanchet(decodeCrock(req.secretSeed), req.planchetIndex); + const denomPub = decodeCrock(req.denomPub); const blindingFactor = createBlindingKeySecret(); - const coinPubHash = hash(coinKeyPair.eddsaPub); + const coinPubHash = hash(fc.coinPub); const ev = rsaBlind(coinPubHash, blindingFactor, denomPub); - const tipPlanchet: TipPlanchet = { + const tipPlanchet: DerivedTipPlanchet = { blindingKey: encodeCrock(blindingFactor), coinEv: encodeCrock(ev), - coinPriv: encodeCrock(coinKeyPair.eddsaPriv), - coinPub: encodeCrock(coinKeyPair.eddsaPub), - coinValue: denom.value, - denomPub: encodeCrock(denomPub), - denomPubHash: encodeCrock(hash(denomPub)), + coinPriv: encodeCrock(fc.coinPriv), + coinPub: encodeCrock(fc.coinPub), }; return tipPlanchet; } |