gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: anastasis-core: salt rename,


From: gnunet
Subject: [taler-wallet-core] branch master updated: anastasis-core: salt rename, fix tagging
Date: Wed, 13 Apr 2022 13:16:39 +0200

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 31b6496d anastasis-core: salt rename, fix tagging
31b6496d is described below

commit 31b6496db502b302e5a33597723ed847a83fe63e
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Apr 13 13:16:35 2022 +0200

    anastasis-core: salt rename, fix tagging
---
 packages/anastasis-core/src/index.ts               | 31 +++++-----
 .../anastasis-core/src/recovery-document-types.ts  |  2 +-
 .../src/pages/home/ChallengeOverviewScreen.tsx     |  6 +-
 .../pages/home/authMethod/AuthMethodEmailSolve.tsx |  5 +-
 .../pages/home/authMethod/AuthMethodIbanSolve.tsx  |  5 +-
 .../pages/home/authMethod/AuthMethodPostSolve.tsx  |  5 +-
 .../home/authMethod/AuthMethodQuestionSolve.tsx    |  5 +-
 .../pages/home/authMethod/AuthMethodSmsSolve.tsx   |  5 +-
 .../pages/home/authMethod/AuthMethodTotpSolve.tsx  | 16 +++--
 .../pages/home/authMethod/AuthMethodVideoSolve.tsx |  3 +-
 packages/taler-util/src/bitcoin.ts                 | 70 +++++++++++++---------
 11 files changed, 76 insertions(+), 77 deletions(-)

diff --git a/packages/anastasis-core/src/index.ts 
b/packages/anastasis-core/src/index.ts
index 52cb33f5..68ecc517 100644
--- a/packages/anastasis-core/src/index.ts
+++ b/packages/anastasis-core/src/index.ts
@@ -458,7 +458,7 @@ async function prepareRecoveryData(
       escrow_type: authMethod.type as any,
       instructions: authMethod.instructions,
       provider_salt: provider.provider_salt,
-      truth_salt: tm.master_salt,
+      question_salt: tm.master_salt,
       truth_key: tm.truth_key,
       url: meth.provider,
       uuid: tm.uuid,
@@ -902,7 +902,7 @@ async function getResponseHash(
         respHash = await secureAnswerHash(
           solveRequest.answer,
           truth.uuid,
-          truth.truth_salt,
+          truth.question_salt,
         );
       } else {
         throw Error("unsupported answer request");
@@ -1074,18 +1074,21 @@ async function selectChallenge(
 
   const url = new URL(`/truth/${truth.uuid}/challenge`, truth.url);
 
-  if (truth.escrow_type === ChallengeType.Question) {
-    return {
-      ...state,
-      recovery_state: RecoveryStates.ChallengeSolving,
-      selected_challenge_uuid: truth.uuid,
-      challenge_feedback: {
-        ...state.challenge_feedback,
-        [truth.uuid]: {
-          state: ChallengeFeedbackStatus.Pending,
+  switch (truth.escrow_type) {
+    case ChallengeType.Question:
+    case ChallengeType.Totp: {
+      return {
+        ...state,
+        recovery_state: RecoveryStates.ChallengeSolving,
+        selected_challenge_uuid: truth.uuid,
+        challenge_feedback: {
+          ...state.challenge_feedback,
+          [truth.uuid]: {
+            state: ChallengeFeedbackStatus.Pending,
+          },
         },
-      },
-    };
+      };
+    }
   }
 
   const resp = await fetch(url.href, {
@@ -1732,7 +1735,7 @@ export async function reduceAction(
       return {
         reducer_type: "error",
         ...e.errorJson,
-      }
+      };
     }
     throw e;
   }
diff --git a/packages/anastasis-core/src/recovery-document-types.ts 
b/packages/anastasis-core/src/recovery-document-types.ts
index 3dc4481f..f94aa191 100644
--- a/packages/anastasis-core/src/recovery-document-types.ts
+++ b/packages/anastasis-core/src/recovery-document-types.ts
@@ -82,7 +82,7 @@ export interface EscrowMethod {
   /**
    * Salt to hash the security question answer if applicable.
    */
-  truth_salt: TruthSalt;
+  question_salt: TruthSalt;
 
   // Salt from the provider to derive the user ID
   // at this provider.
diff --git 
a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx 
b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx
index 11001194..c4047f0b 100644
--- a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.tsx
@@ -274,13 +274,13 @@ export function ChallengeOverviewScreen(): VNode {
               Policy #{policy_index + 1}: {policyName}
             </h3>
             {policy.challenges.length === 0 && (
-              <p>This policy doesn't have challenges.</p>
+              <p>This policy doesn't have any challenges.</p>
             )}
             {policy.challenges.length === 1 && (
-              <p>This policy just have one challenge.</p>
+              <p>This policy has one challenge.</p>
             )}
             {policy.challenges.length > 1 && (
-              <p>This policy have {policy.challenges.length} challenges.</p>
+              <p>This policy has {policy.challenges.length} challenges.</p>
             )}
             {tableBody}
           </div>
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx
index 9ee52d8e..4f7f2132 100644
--- 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx
+++ 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodEmailSolve.tsx
@@ -44,10 +44,7 @@ export function AuthMethodEmailSolve({ id }: 
AuthMethodSolveProps): VNode {
       </AnastasisClientFrame>
     );
   }
-  if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
-  ) {
+  if (reducer.currentReducerState?.reducer_type !== "recovery") {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx
index 3eea9c15..b58952fe 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodIbanSolve.tsx
@@ -22,10 +22,7 @@ export function AuthMethodIbanSolve({ id }: 
AuthMethodSolveProps): VNode {
       </AnastasisClientFrame>
     );
   }
-  if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
-  ) {
+  if (reducer.currentReducerState?.reducer_type !== "recovery") {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx
index 5f03437a..fcff0b49 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodPostSolve.tsx
@@ -43,10 +43,7 @@ export function AuthMethodPostSolve({ id }: 
AuthMethodSolveProps): VNode {
       </AnastasisClientFrame>
     );
   }
-  if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
-  ) {
+  if (reducer.currentReducerState?.reducer_type !== "recovery") {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
index f54f91d9..058efe00 100644
--- 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
+++ 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodQuestionSolve.tsx
@@ -22,10 +22,7 @@ export function AuthMethodQuestionSolve({ id }: 
AuthMethodSolveProps): VNode {
       </AnastasisClientFrame>
     );
   }
-  if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
-  ) {
+  if (reducer.currentReducerState?.reducer_type !== "recovery") {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx
index 1fd4343a..3b00f6f2 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodSmsSolve.tsx
@@ -44,10 +44,7 @@ export function AuthMethodSmsSolve({ id }: 
AuthMethodSolveProps): VNode {
       </AnastasisClientFrame>
     );
   }
-  if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
-  ) {
+  if (reducer.currentReducerState?.reducer_type !== "recovery") {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx
index bd31fd5b..ce7b2e54 100644
--- a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx
+++ b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodTotpSolve.tsx
@@ -12,7 +12,7 @@ import { SolveOverviewFeedbackDisplay } from "../SolveScreen";
 import { AuthMethodSolveProps } from "./index";
 
 export function AuthMethodTotpSolve({ id }: AuthMethodSolveProps): VNode {
-  const [answer, setAnswer] = useState("");
+  const [answerCode, setAnswerCode] = useState("");
 
   const reducer = useAnastasisContext();
   if (!reducer) {
@@ -22,10 +22,7 @@ export function AuthMethodTotpSolve({ id }: 
AuthMethodSolveProps): VNode {
       </AnastasisClientFrame>
     );
   }
-  if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
-  ) {
+  if (reducer.currentReducerState?.reducer_type !== "recovery") {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
         <div>invalid state</div>
@@ -72,11 +69,13 @@ export function AuthMethodTotpSolve({ id }: 
AuthMethodSolveProps): VNode {
   for (const ch of chArr) {
     challenges[ch.uuid] = ch;
   }
-  const selectedChallenge = challenges[selectedUuid];
   const feedback = challengeFeedback[selectedUuid];
 
   async function onNext(): Promise<void> {
-    return reducer?.transition("solve_challenge", { answer });
+    console.log(`sending TOTP code '${answerCode}'`);
+    return reducer?.transition("solve_challenge", {
+      pin: Number.parseInt(answerCode),
+    });
   }
   function onCancel(): void {
     reducer?.back();
@@ -96,7 +95,7 @@ export function AuthMethodTotpSolve({ id }: 
AuthMethodSolveProps): VNode {
         label="Answer"
         onConfirm={onNext}
         grabFocus
-        bind={[answer, setAnswer]}
+        bind={[answerCode, setAnswerCode]}
       />
 
       <div
@@ -118,4 +117,3 @@ export function AuthMethodTotpSolve({ id }: 
AuthMethodSolveProps): VNode {
     </AnastasisClientFrame>
   );
 }
-// NKE8 VD857T X033X6RG WEGPYP6D70 Q7YE XN8D2 ZN79SCN 231B4QK0
diff --git 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx
index 02158919..e0ebdce7 100644
--- 
a/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx
+++ 
b/packages/anastasis-webui/src/pages/home/authMethod/AuthMethodVideoSolve.tsx
@@ -23,8 +23,7 @@ export function AuthMethodVideoSolve({ id }: 
AuthMethodSolveProps): VNode {
     );
   }
   if (
-    !reducer.currentReducerState ||
-    reducer.currentReducerState.recovery_state === undefined
+    reducer.currentReducerState?.reducer_type !== "recovery"
   ) {
     return (
       <AnastasisClientFrame hideNav title="Recovery problem">
diff --git a/packages/taler-util/src/bitcoin.ts 
b/packages/taler-util/src/bitcoin.ts
index 85a176dc..cf9d52c4 100644
--- a/packages/taler-util/src/bitcoin.ts
+++ b/packages/taler-util/src/bitcoin.ts
@@ -14,55 +14,69 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { AmountJson } from "."
-import { Amounts, } from "./amounts"
-import { getRandomBytes, decodeCrock, encodeCrock } from "./talerCrypto"
-import * as segwit from "./segwit_addr"
 /**
  *
  * @author sebasjm
  */
 
+/**
+ * Imports.
+ */
+import { AmountJson, Amounts } from "./amounts.js";
+import { getRandomBytes, decodeCrock } from "./talerCrypto.js";
+import * as segwit from "./segwit_addr.js";
+
 export interface SegwitAddrs {
-  addr1: string,
-  addr2: string,
+  addr1: string;
+  addr2: string;
 }
 
-function buf2hex(buffer: Uint8Array) { // buffer is an ArrayBuffer
+function buf2hex(buffer: Uint8Array) {
+  // buffer is an ArrayBuffer
   return [...new Uint8Array(buffer)]
-    .map(x => x.toString(16).padStart(2, '0'))
-    .join('');
+    .map((x) => x.toString(16).padStart(2, "0"))
+    .join("");
 }
 
-export function generateFakeSegwitAddress(reservePub: string, addr: string): 
SegwitAddrs {
-  const pub = decodeCrock(reservePub)
+export function generateFakeSegwitAddress(
+  reservePub: string,
+  addr: string,
+): SegwitAddrs {
+  const pub = decodeCrock(reservePub);
 
-  const first_rnd = getRandomBytes(4)
-  const second_rnd = new Uint8Array(first_rnd.length)
-  second_rnd.set(first_rnd)
+  const first_rnd = getRandomBytes(4);
+  const second_rnd = new Uint8Array(first_rnd.length);
+  second_rnd.set(first_rnd);
 
-  first_rnd[0] = first_rnd[0] & 0b0111_1111
-  second_rnd[0] = second_rnd[0] | 0b1000_0000
+  first_rnd[0] = first_rnd[0] & 0b0111_1111;
+  second_rnd[0] = second_rnd[0] | 0b1000_0000;
 
-  const first_part = new Uint8Array(first_rnd.length + pub.length / 2)
-  first_part.set(first_rnd, 0)
-  first_part.set(pub.subarray(0, 16), 4)
-  const second_part = new Uint8Array(first_rnd.length + pub.length / 2)
-  second_part.set(first_rnd, 0)
-  second_part.set(pub.subarray(16), 4)
+  const first_part = new Uint8Array(first_rnd.length + pub.length / 2);
+  first_part.set(first_rnd, 0);
+  first_part.set(pub.subarray(0, 16), 4);
+  const second_part = new Uint8Array(first_rnd.length + pub.length / 2);
+  second_part.set(first_rnd, 0);
+  second_part.set(pub.subarray(16), 4);
 
-  console.log(first_part.length, second_part.length)
+  console.log(first_part.length, second_part.length);
 
-  const prefix = (addr[0] === 't' && addr[1] == 'b') ? "tb" : (addr[0] === 'b' 
&& addr[1] == 'c' && addr[2] === 'r' && addr[3] == 't') ? 'bcrt' : (addr[0] === 
'b' && addr[1] == 'c') ? 'bc' : undefined
-  if (prefix === undefined) throw new Error('unknown bitcoin net')
+  const prefix =
+    addr[0] === "t" && addr[1] == "b"
+      ? "tb"
+      : addr[0] === "b" && addr[1] == "c" && addr[2] === "r" && addr[3] == "t"
+      ? "bcrt"
+      : addr[0] === "b" && addr[1] == "c"
+      ? "bc"
+      : undefined;
+  if (prefix === undefined) throw new Error("unknown bitcoin net");
 
   return {
     addr1: segwit.default.encode(prefix, 0, first_part),
     addr2: segwit.default.encode(prefix, 0, second_part),
-  }
+  };
 }
 
 // https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp
 export function segwitMinAmount(): AmountJson {
-  return Amounts.parseOrThrow("BTC:0.00000294")
-}
\ No newline at end of file
+  return Amounts.parseOrThrow("BTC:0.00000294");
+}

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