summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/crypto/workers
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/crypto/workers')
-rw-r--r--packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts23
-rw-r--r--packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts33
2 files changed, 47 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts
index 16446bb9e..b5a5950b1 100644
--- a/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/cryptoApi.ts
@@ -22,20 +22,22 @@
/**
* Imports.
*/
-import { CoinRecord, DenominationRecord, WireFee } from "../../db.js";
+import { DenominationRecord, WireFee } from "../../db.js";
import { CryptoWorker } from "./cryptoWorkerInterface.js";
import {
+ BlindedDenominationSignature,
CoinDepositPermission,
CoinEnvelope,
RecoupRefreshRequest,
RecoupRequest,
+ UnblindedSignature,
} from "@gnu-taler/taler-util";
import {
BenchmarkResult,
- PlanchetCreationResult,
+ WithdrawalPlanchet,
PlanchetCreationRequest,
DepositInfo,
MakeSyncSignatureRequest,
@@ -324,10 +326,19 @@ export class CryptoApi {
return p;
}
- createPlanchet(
- req: PlanchetCreationRequest,
- ): Promise<PlanchetCreationResult> {
- return this.doRpc<PlanchetCreationResult>("createPlanchet", 1, req);
+ createPlanchet(req: PlanchetCreationRequest): Promise<WithdrawalPlanchet> {
+ return this.doRpc<WithdrawalPlanchet>("createPlanchet", 1, req);
+ }
+
+ unblindDenominationSignature(req: {
+ planchet: WithdrawalPlanchet;
+ evSig: BlindedDenominationSignature;
+ }): Promise<UnblindedSignature> {
+ return this.doRpc<UnblindedSignature>(
+ "unblindDenominationSignature",
+ 1,
+ req,
+ );
}
createTipPlanchet(req: DeriveTipRequest): Promise<DerivedTipPlanchet> {
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
index af77e2be4..15a086ae1 100644
--- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts
@@ -53,7 +53,7 @@ import {
Logger,
MakeSyncSignatureRequest,
PlanchetCreationRequest,
- PlanchetCreationResult,
+ WithdrawalPlanchet,
randomBytes,
RecoupRefreshRequest,
RecoupRequest,
@@ -70,6 +70,9 @@ import {
Timestamp,
timestampTruncateToSecond,
typedArrayConcat,
+ BlindedDenominationSignature,
+ RsaUnblindedSignature,
+ UnblindedSignature,
} from "@gnu-taler/taler-util";
import bigint from "big-integer";
import { DenominationRecord, WireFee } from "../../db.js";
@@ -169,7 +172,7 @@ export class CryptoImplementation {
*/
async createPlanchet(
req: PlanchetCreationRequest,
- ): Promise<PlanchetCreationResult> {
+ ): Promise<WithdrawalPlanchet> {
const denomPub = req.denomPub;
if (denomPub.cipher === DenomKeyType.Rsa) {
const reservePub = decodeCrock(req.reservePub);
@@ -200,7 +203,7 @@ export class CryptoImplementation {
priv: req.reservePriv,
});
- const planchet: PlanchetCreationResult = {
+ const planchet: WithdrawalPlanchet = {
blindingKey: encodeCrock(derivedPlanchet.bks),
coinEv,
coinPriv: encodeCrock(derivedPlanchet.coinPriv),
@@ -428,6 +431,30 @@ export class CryptoImplementation {
};
}
+ unblindDenominationSignature(req: {
+ planchet: WithdrawalPlanchet;
+ evSig: BlindedDenominationSignature;
+ }): UnblindedSignature {
+ if (req.evSig.cipher === DenomKeyType.Rsa) {
+ if (req.planchet.denomPub.cipher !== DenomKeyType.Rsa) {
+ throw new Error(
+ "planchet cipher does not match blind signature cipher",
+ );
+ }
+ const denomSig = rsaUnblind(
+ decodeCrock(req.evSig.blinded_rsa_signature),
+ decodeCrock(req.planchet.denomPub.rsa_public_key),
+ decodeCrock(req.planchet.blindingKey),
+ );
+ return {
+ cipher: DenomKeyType.Rsa,
+ rsa_signature: encodeCrock(denomSig),
+ };
+ } else {
+ throw Error(`unblinding for cipher ${req.evSig.cipher} not implemented`);
+ }
+ }
+
/**
* Unblind a blindly signed value.
*/