on master help sign in
wallet-gen: add getEntropyBits helper
3bba937Liam Fitzgerald
src/lib/walletgen.js+9−12
@@ -16,14 +16,16 @@ import {
16
16
17const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8;
17const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8;
18
18
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+
19// returns a promise for a ticket string
26// returns a promise for a ticket string
20export const makeTicket = point => {
27export const makeTicket = point => {
21− const bits =
28+ const bits = getEntropyBits(point);
22− point < MIN_STAR
23− ? GALAXY_ENTROPY_BITS
24− : point < MIN_PLANET
25− ? STAR_ENTROPY_BITS
26− : PLANET_ENTROPY_BITS;
27
29
28 const bytes = bits / 8;
30 const bytes = bits / 8;
29 const some = new Uint8Array(bytes);
31 const some = new Uint8Array(bytes);
@@ -46,12 +48,7 @@ export const makeTicket = point => {
46};
48};
47
49
48export const makeDeterministicTicket = (point, seed) => {
50export const makeDeterministicTicket = (point, seed) => {
49− const bits =
51+ const bits = getEntropyBits(point);
50− point < MIN_STAR
51− ? GALAXY_ENTROPY_BITS
52− : point < MIN_PLANET
53− ? STAR_ENTROPY_BITS
54− : PLANET_ENTROPY_BITS;
55
52
56 const bytes = bits / 8;
53 const bytes = bits / 8;
57
54