gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: wallet-core: trust exchange f


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: trust exchange for exchange benchmark
Date: Wed, 08 Dec 2021 16:23:03 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 684c53e1 wallet-core: trust exchange for exchange benchmark
684c53e1 is described below

commit 684c53e105e2d4b4e07811423e409ff4735e7297
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Dec 8 16:23:00 2021 +0100

    wallet-core: trust exchange for exchange benchmark
---
 packages/taler-wallet-cli/src/bench1.ts            |  2 +
 packages/taler-wallet-core/src/common.ts           |  2 +
 .../src/crypto/workers/synchronousWorker.ts        |  2 +-
 .../taler-wallet-core/src/operations/exchanges.ts  | 46 +++++++++++++---------
 .../taler-wallet-core/src/operations/withdraw.ts   | 13 ++++--
 packages/taler-wallet-core/src/wallet.ts           | 10 +++++
 6 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/packages/taler-wallet-cli/src/bench1.ts 
b/packages/taler-wallet-cli/src/bench1.ts
index 30ef8732..3f3f752c 100644
--- a/packages/taler-wallet-cli/src/bench1.ts
+++ b/packages/taler-wallet-cli/src/bench1.ts
@@ -105,6 +105,8 @@ export async function runBench1(configJson: any): 
Promise<void> {
       logger.info(`Finished deposit amount=10 time=${Date.now() - start}`);
     }
   }
+
+  wallet.stop();
 }
 
 /**
diff --git a/packages/taler-wallet-core/src/common.ts 
b/packages/taler-wallet-core/src/common.ts
index 90c2afdd..d3c4a522 100644
--- a/packages/taler-wallet-core/src/common.ts
+++ b/packages/taler-wallet-core/src/common.ts
@@ -133,6 +133,8 @@ export interface InternalWalletState {
   timerGroup: TimerGroup;
   stopped: boolean;
 
+  insecureTrustExchange: boolean;
+
   /**
    * Asynchronous condition to interrupt the sleep of the
    * retry loop.
diff --git a/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts 
b/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts
index 8293bb36..ae8442ef 100644
--- a/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/synchronousWorker.ts
@@ -25,7 +25,7 @@ import { CryptoWorker } from "./cryptoWorkerInterface.js";
 import child_process from "child_process";
 import type internal from "stream";
 import { OpenedPromise, openPromise } from "../../index.js";
-import { FreshCoin, Logger } from "@gnu-taler/taler-util";
+import { Logger } from "@gnu-taler/taler-util";
 
 const logger = new Logger("synchronousWorker.ts");
 
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 16e37fd3..98703181 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -218,19 +218,24 @@ export async function acceptExchangeTermsOfService(
 }
 
 async function validateWireInfo(
+  ws: InternalWalletState,
   versionCurrent: number,
   wireInfo: ExchangeWireJson,
   masterPublicKey: string,
-  cryptoApi: CryptoApi,
 ): Promise<WireInfo> {
   for (const a of wireInfo.accounts) {
     logger.trace("validating exchange acct");
-    const isValid = await cryptoApi.isValidWireAccount(
-      versionCurrent,
-      a.payto_uri,
-      a.master_sig,
-      masterPublicKey,
-    );
+    let isValid = false;
+    if (ws.insecureTrustExchange) {
+      isValid = true;
+    } else {
+      isValid = await ws.cryptoApi.isValidWireAccount(
+        versionCurrent,
+        a.payto_uri,
+        a.master_sig,
+        masterPublicKey,
+      );
+    }
     if (!isValid) {
       throw Error("exchange acct signature invalid");
     }
@@ -248,11 +253,16 @@ async function validateWireInfo(
         startStamp,
         wireFee: Amounts.parseOrThrow(x.wire_fee),
       };
-      const isValid = await cryptoApi.isValidWireFee(
-        wireMethod,
-        fee,
-        masterPublicKey,
-      );
+      let isValid = false;
+      if (ws.insecureTrustExchange) {
+        isValid = true;
+      } else {
+        isValid = await ws.cryptoApi.isValidWireFee(
+          wireMethod,
+          fee,
+          masterPublicKey,
+        );
+      }
       if (!isValid) {
         throw Error("exchange wire fee signature invalid");
       }
@@ -488,10 +498,10 @@ async function updateExchangeFromUrlImpl(
   }
 
   const wireInfo = await validateWireInfo(
+    ws,
     version.current,
     wireInfoDownload,
     keysInfo.masterPublicKey,
-    ws.cryptoApi,
   );
 
   logger.info("finished validating exchange /wire info");
@@ -516,11 +526,11 @@ async function updateExchangeFromUrlImpl(
     tosFound !== undefined
       ? tosFound
       : await downloadExchangeWithTermsOfService(
-        baseUrl,
-        ws.http,
-        timeout,
-        "text/plain",
-      );
+          baseUrl,
+          ws.http,
+          timeout,
+          "text/plain",
+        );
 
   let recoupGroupId: string | undefined = undefined;
 
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index ebab5468..48d308b6 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -777,10 +777,15 @@ export async function updateWithdrawalDenoms(
             denominations.length
           }) signature of ${denom.denomPubHash}`,
         );
-        const valid = await ws.cryptoApi.isValidDenom(
-          denom,
-          exchangeDetails.masterPublicKey,
-        );
+        let valid: boolean = false;
+        if (ws.insecureTrustExchange) {
+          valid = true;
+        } else {
+          valid = await ws.cryptoApi.isValidDenom(
+            denom,
+            exchangeDetails.masterPublicKey,
+          );
+        }
         logger.trace(`Done validating ${denom.denomPubHash}`);
         if (!valid) {
           logger.warn(
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 04213ddc..1d809afa 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -1037,6 +1037,14 @@ export class Wallet {
     return this._client;
   }
 
+  /**
+   * Trust the exchange, do not validate signatures.
+   * Only used to benchmark the exchange.
+   */
+  setInsecureTrustExchange() {
+    this.ws.insecureTrustExchange = true;
+  }
+
   static async create(
     db: DbAccess<typeof WalletStoresV1>,
     http: HttpRequestLibrary,
@@ -1089,6 +1097,8 @@ class InternalWalletStateImpl implements 
InternalWalletState {
 
   merchantInfoCache: Record<string, MerchantInfo> = {};
 
+  insecureTrustExchange: boolean = false;
+
   timerGroup: TimerGroup = new TimerGroup();
   latch = new AsyncCondition();
   stopped = false;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]