aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-02 00:42:40 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-02 00:42:40 +0100
commite1369ff7e8fc02116b9c4261036f0e42e3423cf4 (patch)
treec621067ebda8977a888bfed34b7bbecf64b3b0f0 /src/crypto
parentaaf7e1338d6cdb1b4e01ad318938b3eaea2f922b (diff)
downloadwallet-core-e1369ff7e8fc02116b9c4261036f0e42e3423cf4.tar.xz
the giant refactoring: split wallet into multiple parts
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/cryptoApi.ts12
-rw-r--r--src/crypto/cryptoImplementation.ts25
2 files changed, 17 insertions, 20 deletions
diff --git a/src/crypto/cryptoApi.ts b/src/crypto/cryptoApi.ts
index b5eae9beb..5ef787711 100644
--- a/src/crypto/cryptoApi.ts
+++ b/src/crypto/cryptoApi.ts
@@ -22,12 +22,11 @@
/**
* Imports.
*/
-import { AmountJson } from "../amounts";
+import { AmountJson } from "../util/amounts";
import {
CoinRecord,
DenominationRecord,
- PlanchetRecord,
RefreshSessionRecord,
ReserveRecord,
TipPlanchet,
@@ -38,9 +37,9 @@ import { CryptoWorker } from "./cryptoWorker";
import { ContractTerms, PaybackRequest } from "../talerTypes";
-import { BenchmarkResult, CoinWithDenom, PayCoinInfo, PlanchetCreationResult } from "../walletTypes";
+import { BenchmarkResult, CoinWithDenom, PayCoinInfo, PlanchetCreationResult, PlanchetCreationRequest } from "../walletTypes";
-import * as timer from "../timer";
+import * as timer from "../util/timer";
/**
* State of a crypto worker.
@@ -336,10 +335,9 @@ export class CryptoApi {
}
createPlanchet(
- denom: DenominationRecord,
- reserve: ReserveRecord,
+ req: PlanchetCreationRequest
): Promise<PlanchetCreationResult> {
- return this.doRpc<PlanchetCreationResult>("createPlanchet", 1, denom, reserve);
+ return this.doRpc<PlanchetCreationResult>("createPlanchet", 1, req);
}
createTipPlanchet(denom: DenominationRecord): Promise<TipPlanchet> {
diff --git a/src/crypto/cryptoImplementation.ts b/src/crypto/cryptoImplementation.ts
index 7cddf9031..faebbaa4a 100644
--- a/src/crypto/cryptoImplementation.ts
+++ b/src/crypto/cryptoImplementation.ts
@@ -42,11 +42,12 @@ import {
PayCoinInfo,
Timestamp,
PlanchetCreationResult,
+ PlanchetCreationRequest,
} from "../walletTypes";
-import { canonicalJson, getTalerStampSec } from "../helpers";
-import { AmountJson } from "../amounts";
-import * as Amounts from "../amounts";
-import * as timer from "../timer";
+import { canonicalJson, getTalerStampSec } from "../util/helpers";
+import { AmountJson } from "../util/amounts";
+import * as Amounts from "../util/amounts";
+import * as timer from "../util/timer";
import {
getRandomBytes,
encodeCrock,
@@ -155,24 +156,23 @@ export class CryptoImplementation {
* reserve.
*/
createPlanchet(
- denom: DenominationRecord,
- reserve: ReserveRecord,
+ req: PlanchetCreationRequest,
): PlanchetCreationResult {
- const reservePub = decodeCrock(reserve.reservePub);
- const reservePriv = decodeCrock(reserve.reservePriv);
- const denomPub = decodeCrock(denom.denomPub);
+ const reservePub = decodeCrock(req.reservePub);
+ const reservePriv = decodeCrock(req.reservePriv);
+ const denomPub = decodeCrock(req.denomPub);
const coinKeyPair = createEddsaKeyPair();
const blindingFactor = createBlindingKeySecret();
const coinPubHash = hash(coinKeyPair.eddsaPub);
const ev = rsaBlind(coinPubHash, blindingFactor, denomPub);
- const amountWithFee = Amounts.add(denom.value, denom.feeWithdraw).amount;
+ const amountWithFee = Amounts.add(req.value, req.feeWithdraw).amount;
const denomPubHash = hash(denomPub);
const evHash = hash(ev);
const withdrawRequest = buildSigPS(SignaturePurpose.RESERVE_WITHDRAW)
.put(reservePub)
.put(amountToBuffer(amountWithFee))
- .put(amountToBuffer(denom.feeWithdraw))
+ .put(amountToBuffer(req.feeWithdraw))
.put(denomPubHash)
.put(evHash)
.build();
@@ -184,10 +184,9 @@ export class CryptoImplementation {
coinEv: encodeCrock(ev),
coinPriv: encodeCrock(coinKeyPair.eddsaPriv),
coinPub: encodeCrock(coinKeyPair.eddsaPub),
- coinValue: denom.value,
+ coinValue: req.value,
denomPub: encodeCrock(denomPub),
denomPubHash: encodeCrock(denomPubHash),
- exchangeBaseUrl: reserve.exchangeBaseUrl,
reservePub: encodeCrock(reservePub),
withdrawSig: encodeCrock(sig),
};