gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] 02/02: wallet-core: include age restriction in p2p s


From: gnunet
Subject: [taler-wallet-core] 02/02: wallet-core: include age restriction in p2p signature, mark coins as spent
Date: Mon, 05 Sep 2022 12:55:51 +0200

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

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

commit 300242637f20401fa9074e36eea5fa8788cc7202
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Sep 5 12:55:46 2022 +0200

    wallet-core: include age restriction in p2p signature, mark coins as spent
---
 .../taler-wallet-core/src/crypto/cryptoImplementation.ts    | 12 ++++++++++--
 packages/taler-wallet-core/src/operations/peer-to-peer.ts   | 13 +++++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)

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]