on master help sign in
wallet-gen: add getEntropyBits helper
commit3bba937982a003338cfb5db40e256ca76eca28f3 authorLiam Fitzgerald <liam@urizen.co> dateWed 1 Apr 2020, 04:36 (7 years ago) parent6a7e3db
1 file changed+9−12
src/lib/walletgen.js+9−12
src/lib/walletgen.js+9−12
@@ -16,14 +16,16 @@ import {
1616
1717const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8;
1818
19+const getEntropyBits = point =>
20+ point < MIN_STAR
21+ ? GALAXY_ENTROPY_BITS
22+ : point < MIN_PLANET
23+ ? STAR_ENTROPY_BITS
24+ : PLANET_ENTROPY_BITS;
25+
1926// returns a promise for a ticket string
2027export const makeTicket = point => {
21− const bits =
22− point < MIN_STAR
23− ? GALAXY_ENTROPY_BITS
24− : point < MIN_PLANET
25− ? STAR_ENTROPY_BITS
26− : PLANET_ENTROPY_BITS;
28+ const bits = getEntropyBits(point);
2729
2830 const bytes = bits / 8;
2931 const some = new Uint8Array(bytes);
@@ -46,12 +48,7 @@ export const makeTicket = point => {
4648};
4749
4850export const makeDeterministicTicket = (point, seed) => {
49− const bits =
50− point < MIN_STAR
51− ? GALAXY_ENTROPY_BITS
52− : point < MIN_PLANET
53− ? STAR_ENTROPY_BITS
54− : PLANET_ENTROPY_BITS;
51+ const bits = getEntropyBits(point);
5552
5653 const bytes = bits / 8;
5754