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/cryptoDispatcher.ts8
-rw-r--r--packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts53
2 files changed, 49 insertions, 12 deletions
diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts
index 810273cca..f5782ab09 100644
--- a/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/cryptoDispatcher.ts
@@ -122,7 +122,7 @@ export class CryptoDispatcher {
worker.idleTimeoutHandle = null;
}
if (worker.currentWorkItem) {
- worker.currentWorkItem.reject(Error("explicitly terminated"));
+ worker.currentWorkItem.reject(new CryptoApiStoppedError());
worker.currentWorkItem = null;
}
if (worker.w) {
@@ -143,7 +143,7 @@ export class CryptoDispatcher {
*/
wake(ws: WorkerState, work: WorkItem): void {
if (this.stopped) {
- throw new CryptoApiStoppedError();
+ return;
}
if (ws.currentWorkItem !== null) {
throw Error("assertion failed");
@@ -331,8 +331,8 @@ export class CryptoDispatcher {
}
timeout.clear();
resolve(x);
- });
- p.catch((x) => {
+ }).catch((x) => {
+ logger.info(`crypto RPC call ${operation} threw`);
if (timedOut) {
return;
}
diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts b/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts
index 1d7539ed6..a5f154e92 100644
--- a/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts
@@ -47,14 +47,11 @@ export class SynchronousCryptoWorker {
this.cryptoImplR = { ...nativeCryptoR };
- if (
- process.env["TALER_WALLET_RPC_CRYPRO"] ||
- // Old name
- process.env["TALER_WALLET_PRIMITIVE_WORKER"]
- ) {
+ if (process.env["TALER_WALLET_PRIMITIVE_WORKER"]) {
+ logger.info("using RPC for some crypto operations");
const rpc = (this.rpcClient = new CryptoRpcClient());
this.cryptoImplR.eddsaSign = async (_, req) => {
- logger.trace("making RPC request");
+ logger.info("calling RPC impl of eddsaSign");
return await rpc.queueRequest({
op: "eddsa_sign",
args: {
@@ -63,6 +60,46 @@ export class SynchronousCryptoWorker {
},
});
};
+ this.cryptoImplR.setupRefreshPlanchet = async (_, req) => {
+ const res = await rpc.queueRequest({
+ op: "setup_refresh_planchet",
+ args: {
+ coin_index: req.coinNumber,
+ transfer_secret: req.transferSecret,
+ },
+ });
+ return {
+ bks: res.blinding_key,
+ coinPriv: res.coin_priv,
+ coinPub: res.coin_pub,
+ };
+ };
+ this.cryptoImplR.rsaBlind = async (_, req) => {
+ const res = await rpc.queueRequest({
+ op: "rsa_blind",
+ args: {
+ bks: req.bks,
+ hm: req.hm,
+ pub: req.pub,
+ },
+ });
+ return {
+ blinded: res.blinded,
+ };
+ };
+
+ this.cryptoImplR.keyExchangeEcdheEddsa = async (_, req) => {
+ const res = await rpc.queueRequest({
+ op: "kx_ecdhe_eddsa",
+ args: {
+ ecdhe_priv: req.ecdhePriv,
+ eddsa_pub: req.eddsaPub,
+ },
+ });
+ return {
+ h: res.h,
+ };
+ };
}
}
@@ -101,8 +138,8 @@ export class SynchronousCryptoWorker {
let result: any;
try {
result = await (impl as any)[operation](impl, req);
- } catch (e) {
- logger.error("error during operation", e);
+ } catch (e: any) {
+ logger.error(`error during operation '${operation}': ${e}`);
return;
}