gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-wallet-webex] branch master updated: use EdDSA publi


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated: use EdDSA public key as nonce, store private key in DB
Date: Mon, 13 Feb 2017 09:53:38 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 3a07444  use EdDSA public key as nonce, store private key in DB
3a07444 is described below

commit 3a074443b764bf38b24e5ff4ef7e81d6ba351a55
Author: Florian Dold <address@hidden>
AuthorDate: Mon Feb 13 09:53:34 2017 +0100

    use EdDSA public key as nonce, store private key in DB
---
 src/content_scripts/notify.ts | 13 ++++++++++++-
 src/wallet.ts                 | 25 +++++++++++++++++++++++++
 src/wxBackend.ts              |  5 ++++-
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/src/content_scripts/notify.ts b/src/content_scripts/notify.ts
index 6a0d9d2..582375e 100644
--- a/src/content_scripts/notify.ts
+++ b/src/content_scripts/notify.ts
@@ -173,6 +173,17 @@ namespace TalerNotify {
     (detail: any, sendResponse: (msg: any) => void): void;
   }
 
+  function generateNonce(): Promise<string> {
+    const walletMsg = {
+      type: "generate-nonce",
+    };
+    return new Promise((resolve, reject) => {
+      chrome.runtime.sendMessage(walletMsg, (resp: any) => {
+        resolve(resp);
+      });
+    });
+  }
+
   function downloadContract(url: string, nonce: string): Promise<any> {
     let parsed_url = URI(url);
     url = parsed_url.setQuery({nonce}).href();
@@ -358,7 +369,7 @@ namespace TalerNotify {
         return;
       }
       if (msg.contract_url) {
-        let nonce = Math.round(Math.random() * 0xFFFF).toString()
+        let nonce = await generateNonce();
         let proposal = await downloadContract(msg.contract_url, nonce);
         if (proposal.data.nonce != nonce) {
           console.error("stale contract");
diff --git a/src/wallet.ts b/src/wallet.ts
index 1c9de01..67393ed 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -198,6 +198,11 @@ export interface Badge {
   stopBusy(): void;
 }
 
+export interface NonceRecord {
+  priv: string;
+  pub: string;
+}
+
 
 function setTimeout(f: any, t: number) {
   return chrome.extension.getBackgroundPage().setTimeout(f, t);
@@ -305,6 +310,12 @@ export namespace Stores {
     pubKeyIndex = new Index<string,ExchangeRecord>(this, "pubKey", 
"masterPublicKey");
   }
 
+  class NonceStore extends Store<NonceRecord> {
+    constructor() {
+      super("nonces", {keyPath: "pub"});
+    }
+  }
+
   class CoinsStore extends Store<CoinRecord> {
     constructor() {
       super("coins", {keyPath: "coinPub"});
@@ -358,6 +369,7 @@ export namespace Stores {
   }
 
   export const exchanges: ExchangeStore = new ExchangeStore();
+  export const nonces: NonceStore = new NonceStore();
   export const transactions: TransactionsStore = new TransactionsStore();
   export const reserves: Store<ReserveRecord> = new 
Store<ReserveRecord>("reserves", {keyPath: "reserve_pub"});
   export const coins: CoinsStore = new CoinsStore();
@@ -1708,6 +1720,19 @@ export class Wallet {
   }
 
 
+  /**
+   * Generate a nonce in form of an EdDSA public key.
+   * Store the private key in our DB, so we can prove ownership.
+   */
+  async generateNonce(): Promise<string> {
+    let {priv, pub} = await this.cryptoApi.createEddsaKeypair();
+    await this.q()
+              .put(Stores.nonces, {priv, pub})
+              .finish();
+    return pub;
+  }
+
+
   async paymentSucceeded(contractHash: string): Promise<any> {
     const doPaymentSucceeded = async() => {
       let t = await this.q().get<TransactionRecord>(Stores.transactions,
diff --git a/src/wxBackend.ts b/src/wxBackend.ts
index 50e0689..cdc8f43 100644
--- a/src/wxBackend.ts
+++ b/src/wxBackend.ts
@@ -35,7 +35,7 @@ import * as logging from "./logging";
 "use strict";
 
 const DB_NAME = "taler";
-const DB_VERSION = 12;
+const DB_VERSION = 14;
 
 import {Stores} from "./wallet";
 import {Store, Index} from "./query";
@@ -102,6 +102,9 @@ function makeHandlers(db: IDBDatabase,
       const req = ConfirmReserveRequest.checked(d);
       return wallet.confirmReserve(req);
     },
+    ["generate-nonce"]: function (detail, sender) {
+      return wallet.generateNonce();
+    },
     ["confirm-pay"]: function (detail, sender) {
       let offer: OfferRecord;
       try {

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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