2import * as ob from 'urbit-ob'
3import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
4import * as more from 'more-entropy'
5import lodash from 'lodash'
7 MAX_GALAXY, MIN_STAR, MAX_STAR, MIN_PLANET,
8 GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
13const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
15// returns a promise for a ticket string
16const makeTicket = point => {
18 const bits = point < MIN_STAR
24 const bytes = bits / 8
25 const some = new Uint8Array(bytes)
26 window.crypto.getRandomValues(some)
28 const gen = new more.Generator()
30 return new Promise((resolve, reject) => {
31 gen.generate(bits, result => {
32 const chunked = lodash.chunk(result, 2)
33 const desired = chunked.slice(0, bytes) // only take required entropy
34 const more = lodash.flatMap(desired, arr => arr[0] ^ arr[1])
35 const entropy = lodash.zipWith(some, more, (x, y) => x ^ y)
36 const buf = Buffer.from(entropy)
37 const patq = ob.hex2patq(buf.toString('hex'))
39 reject('Entropy generation failed')
44// return a wallet object
45const generateWallet = async (point, ticket, boot) => {
49 seedSize: SEED_LENGTH_BYTES,
56 const wallet = await kg.generateWallet(config);
58 // This is here to notify the anyone who opens console because the thread
59 // hangs, blocking UI updates so this cannot be doen in the UI
60 console.log('Generating Wallet for point address: ', point);
65const seq = num => Array.from(Array(num), (_, i) => i)
67const compose = (...fs) => fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list