From f0ac59005b83a582c9e62e8aca3b1cdf2fff0c48 Mon Sep 17 00:00:00 2001 From: reyraa Date: Thu, 28 Sep 2017 11:10:44 +0200 Subject: [PATCH 1/2] Set road map --- src/utils/passphrase.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/passphrase.js b/src/utils/passphrase.js index 7e1c046d9..14b63c9dd 100644 --- a/src/utils/passphrase.js +++ b/src/utils/passphrase.js @@ -50,6 +50,9 @@ const init = (rand = Math.random()) => ({ * @param {Number} percentage * @param {Number} step * + * @todo + * - Set minimum value for steps to make sure 100 iterations is enough + * * @returns {number[]} The input array whose member is pos is set */ export const generateSeed = ({ byte, seed, percentage, step } = init(), rand = Math.random()) => { From 03befac00ae945cc02b15df0003938c4bd8015e0 Mon Sep 17 00:00:00 2001 From: reyraa Date: Thu, 28 Sep 2017 13:05:08 +0200 Subject: [PATCH 2/2] Map the randoms under 0.01 to the range of 0.01 - 0.1 --- features/login.feature | 1 - src/utils/passphrase.js | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/features/login.feature b/features/login.feature index ed5188940..ba3189ef2 100644 --- a/features/login.feature +++ b/features/login.feature @@ -32,7 +32,6 @@ Feature: Login page Then I should be logged in And I should see text "Testnet" in "peer network" element - @ignore Scenario: should allow to create a new account Given I'm on login page When I click "new account button" diff --git a/src/utils/passphrase.js b/src/utils/passphrase.js index 14b63c9dd..5385c3b93 100644 --- a/src/utils/passphrase.js +++ b/src/utils/passphrase.js @@ -29,12 +29,16 @@ const leftPadd = (str, pad, length) => { /** * Resets previous settings and creates a step with a random length between 1.6% to 3.2% */ -const init = (rand = Math.random()) => ({ - step: (160 + Math.floor(rand * 160)) / 100, - percentage: 0, - seed: emptyByte('00'), - byte: emptyByte(0), -}); +const init = (rand = Math.random()) => { + let step = Math.max((160 + Math.floor(rand * 160))); + step = step >= 0.01 ? step : step * 10; + return { + step, + percentage: 0, + seed: emptyByte('00'), + byte: emptyByte(0), + }; +}; /** * - From a zero byte: @@ -50,9 +54,6 @@ const init = (rand = Math.random()) => ({ * @param {Number} percentage * @param {Number} step * - * @todo - * - Set minimum value for steps to make sure 100 iterations is enough - * * @returns {number[]} The input array whose member is pos is set */ export const generateSeed = ({ byte, seed, percentage, step } = init(), rand = Math.random()) => {