gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (4aaece0e -> 30024263)


From: gnunet
Subject: [taler-wallet-core] branch master updated (4aaece0e -> 30024263)
Date: Mon, 05 Sep 2022 12:55:49 +0200

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

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

    from 4aaece0e remove abort-pay test
     new b1f77f46 add integration test for p2p age restrictions
     new 30024263 wallet-core: include age restriction in p2p signature, mark 
coins as spent

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...ctions.ts => test-age-restrictions-merchant.ts} |  4 +-
 ...strictions.ts => test-age-restrictions-peer.ts} | 72 ++++++----------------
 .../src/integrationtests/testrunner.ts             |  6 +-
 .../src/crypto/cryptoImplementation.ts             | 12 +++-
 .../src/operations/peer-to-peer.ts                 | 13 +++-
 5 files changed, 47 insertions(+), 60 deletions(-)
 copy packages/taler-wallet-cli/src/integrationtests/{test-age-restrictions.ts 
=> test-age-restrictions-merchant.ts} (95%)
 rename 
packages/taler-wallet-cli/src/integrationtests/{test-age-restrictions.ts => 
test-age-restrictions-peer.ts} (56%)

diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions-merchant.ts
similarity index 95%
copy from 
packages/taler-wallet-cli/src/integrationtests/test-age-restrictions.ts
copy to 
packages/taler-wallet-cli/src/integrationtests/test-age-restrictions-merchant.ts
index c290fe91..27c36ae4 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions.ts
+++ 
b/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions-merchant.ts
@@ -28,7 +28,7 @@ import {
 /**
  * Run test for basic, bank-integrated withdrawal and payment.
  */
-export async function runAgeRestrictionsTest(t: GlobalTestState) {
+export async function runAgeRestrictionsMerchantTest(t: GlobalTestState) {
   // Set up test environment
 
   const { wallet: walletOne, bank, exchange, merchant } =
@@ -109,4 +109,4 @@ export async function runAgeRestrictionsTest(t: 
GlobalTestState) {
 
 }
 
-runAgeRestrictionsTest.suites = ["wallet"];
+runAgeRestrictionsMerchantTest.suites = ["wallet"];
diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions-peer.ts
similarity index 56%
rename from 
packages/taler-wallet-cli/src/integrationtests/test-age-restrictions.ts
rename to 
packages/taler-wallet-cli/src/integrationtests/test-age-restrictions-peer.ts
index c290fe91..12e993c3 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions.ts
+++ 
b/packages/taler-wallet-cli/src/integrationtests/test-age-restrictions-peer.ts
@@ -17,6 +17,7 @@
 /**
  * Imports.
  */
+import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { defaultCoinConfig } from "../harness/denomStructures.js";
 import { GlobalTestState, WalletCli } from "../harness/harness.js";
 import {
@@ -28,17 +29,21 @@ import {
 /**
  * Run test for basic, bank-integrated withdrawal and payment.
  */
-export async function runAgeRestrictionsTest(t: GlobalTestState) {
+export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
   // Set up test environment
 
-  const { wallet: walletOne, bank, exchange, merchant } =
-    await createSimpleTestkudosEnvironment(
-      t,
-      defaultCoinConfig.map((x) => x("TESTKUDOS")),
-      {
-        ageMaskSpec: "8:10:12:14:16:18:21",
-      },
-    );
+  const {
+    wallet: walletOne,
+    bank,
+    exchange,
+    merchant,
+  } = await createSimpleTestkudosEnvironment(
+    t,
+    defaultCoinConfig.map((x) => x("TESTKUDOS")),
+    {
+      ageMaskSpec: "8:10:12:14:16:18:21",
+    },
+  );
 
   const walletTwo = new WalletCli(t, "walletTwo");
   const walletThree = new WalletCli(t, "walletThree");
@@ -61,52 +66,15 @@ export async function runAgeRestrictionsTest(t: 
GlobalTestState) {
       minimum_age: 9,
     };
 
-    await makeTestPayment(t, { wallet, merchant, order });
-    await wallet.runUntilDone();
-  }
-
-  {
-    const wallet = walletTwo;
-
-    await withdrawViaBank(t, {
-      wallet,
-      bank,
-      exchange,
-      amount: "TESTKUDOS:20",
-      restrictAge: 13,
-    });
-
-    const order = {
-      summary: "Buy me!",
-      amount: "TESTKUDOS:5",
-      fulfillment_url: "taler://fulfillment-success/thx",
-    };
-
-    await makeTestPayment(t, { wallet, merchant, order });
-    await wallet.runUntilDone();
-  }
-
-  {
-    const wallet = walletThree;
-
-    await withdrawViaBank(t, {
-      wallet,
-      bank,
-      exchange,
-      amount: "TESTKUDOS:20",
+    await wallet.client.call(WalletApiOperation.InitiatePeerPushPayment, {
+      amount: "TESTKUDOS:1",
+      partialContractTerms: {
+        summary: "Hello, World",
+      },
     });
 
-    const order = {
-      summary: "Buy me!",
-      amount: "TESTKUDOS:5",
-      fulfillment_url: "taler://fulfillment-success/thx",
-      minimum_age: 9,
-    };
-
-    await makeTestPayment(t, { wallet, merchant, order });
     await wallet.runUntilDone();
   }
-
 }
 
-runAgeRestrictionsTest.suites = ["wallet"];
+runAgeRestrictionsPeerTest.suites = ["wallet"];
diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts 
b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
index 69905730..de6e246d 100644
--- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts
@@ -25,7 +25,7 @@ import {
   shouldLingerInTest,
   TestRunResult,
 } from "../harness/harness.js";
-import { runAgeRestrictionsTest } from "./test-age-restrictions.js";
+import { runAgeRestrictionsMerchantTest } from 
"./test-age-restrictions-merchant.js";
 import { runBankApiTest } from "./test-bank-api.js";
 import { runClaimLoopTest } from "./test-claim-loop.js";
 import { runClauseSchnorrTest } from "./test-clause-schnorr.js";
@@ -90,6 +90,7 @@ import { runWithdrawalAbortBankTest } from 
"./test-withdrawal-abort-bank.js";
 import { runWithdrawalBankIntegratedTest } from 
"./test-withdrawal-bank-integrated.js";
 import { runWithdrawalFakebankTest } from "./test-withdrawal-fakebank.js";
 import { runTestWithdrawalManualTest } from "./test-withdrawal-manual.js";
+import { runAgeRestrictionsPeerTest } from "./test-age-restrictions-peer.js";
 
 /**
  * Test runner.
@@ -106,7 +107,8 @@ interface TestMainFunction {
 }
 
 const allTests: TestMainFunction[] = [
-  runAgeRestrictionsTest,
+  runAgeRestrictionsMerchantTest,
+  runAgeRestrictionsPeerTest,
   runBankApiTest,
   runClaimLoopTest,
   runClauseSchnorrTest,
diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts 
b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
index 193712e5..6336539f 100644
--- a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
+++ b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts
@@ -442,6 +442,7 @@ export interface SignPurseDepositsRequest {
     contribution: AmountString;
     denomPubHash: string;
     denomSig: UnblindedSignature;
+    ageCommitmentProof: AgeCommitmentProof | undefined;
   }[];
 }
 
@@ -1361,11 +1362,18 @@ export const nativeCryptoR: TalerCryptoInterfaceR = {
     const hExchangeBaseUrl = hash(stringToBytes(req.exchangeBaseUrl + "\0"));
     const deposits: PurseDeposit[] = [];
     for (const c of req.coins) {
+      let maybeAch: Uint8Array;
+      if (c.ageCommitmentProof) {
+        maybeAch = decodeCrock(
+          AgeRestriction.hashCommitment(c.ageCommitmentProof.commitment),
+        );
+      } else {
+        maybeAch = new Uint8Array(32);
+      }
       const sigBlob = buildSigPS(TalerSignaturePurpose.WALLET_PURSE_DEPOSIT)
         .put(amountToBuffer(Amounts.parseOrThrow(c.contribution)))
         .put(decodeCrock(c.denomPubHash))
-        // FIXME: use h_age_commitment here
-        .put(new Uint8Array(32))
+        .put(maybeAch)
         .put(decodeCrock(req.pursePub))
         .put(hExchangeBaseUrl)
         .build();
diff --git a/packages/taler-wallet-core/src/operations/peer-to-peer.ts 
b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
index 27525808..965dfd8e 100644
--- a/packages/taler-wallet-core/src/operations/peer-to-peer.ts
+++ b/packages/taler-wallet-core/src/operations/peer-to-peer.ts
@@ -21,6 +21,7 @@ import {
   AbsoluteTime,
   AcceptPeerPullPaymentRequest,
   AcceptPeerPushPaymentRequest,
+  AgeCommitmentProof,
   AmountJson,
   AmountLike,
   Amounts,
@@ -89,6 +90,7 @@ export interface PeerCoinSelection {
     contribution: AmountString;
     denomPubHash: string;
     denomSig: UnblindedSignature;
+    ageCommitmentProof: AgeCommitmentProof | undefined;
   }[];
 
   /**
@@ -115,6 +117,8 @@ interface CoinInfo {
   denomPubHash: string;
 
   denomSig: UnblindedSignature;
+
+  ageCommitmentProof: AgeCommitmentProof | undefined;
 }
 
 export async function selectPeerCoins(
@@ -152,6 +156,7 @@ export async function selectPeerCoins(
         denomPubHash: denom.denomPubHash,
         coinPriv: coin.coinPriv,
         denomSig: coin.denomSig,
+        ageCommitmentProof: coin.ageCommitmentProof,
       });
     }
     if (coinInfos.length === 0) {
@@ -170,6 +175,7 @@ export async function selectPeerCoins(
       contribution: AmountString;
       denomPubHash: string;
       denomSig: UnblindedSignature;
+      ageCommitmentProof: AgeCommitmentProof | undefined;
     }[] = [];
     for (const coin of coinInfos) {
       if (Amounts.cmp(amountAcc, instructedAmount) >= 0) {
@@ -196,6 +202,7 @@ export async function selectPeerCoins(
         contribution: Amounts.stringify(contrib),
         denomPubHash: coin.denomPubHash,
         denomSig: coin.denomSig,
+        ageCommitmentProof: coin.ageCommitmentProof,
       });
     }
     continue;
@@ -257,6 +264,7 @@ export async function initiatePeerToPeerPush(
           coin.currentAmount,
           Amounts.parseOrThrow(c.contribution),
         ).amount;
+        coin.status = CoinStatus.Dormant;
         await tx.coins.put(coin);
       }
 
@@ -279,7 +287,7 @@ export async function initiatePeerToPeerPush(
 
       return sel;
     });
-  logger.info(`selected p2p coins: ${j2s(coinSelRes)}`);
+  logger.info(`selected p2p coins (push): ${j2s(coinSelRes)}`);
 
   if (!coinSelRes) {
     throw Error("insufficient balance");
@@ -592,6 +600,7 @@ export async function acceptPeerPullPayment(
           coin.currentAmount,
           Amounts.parseOrThrow(c.contribution),
         ).amount;
+        coin.status = CoinStatus.Dormant;
         await tx.coins.put(coin);
       }
 
@@ -608,7 +617,7 @@ export async function acceptPeerPullPayment(
 
       return sel;
     });
-  logger.info(`selected p2p coins: ${j2s(coinSelRes)}`);
+  logger.info(`selected p2p coins (pull): ${j2s(coinSelRes)}`);
 
   if (!coinSelRes) {
     throw Error("insufficient balance");

-- 
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]