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 MIN_STAR, MIN_PLANET, SEED_ENTROPY_BITS,
8 GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
11const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
13// returns a promise for a ticket string
14const makeTicket = point => {
16 const bits = point < MIN_STAR
22 const bytes = bits / 8
23 const some = new Uint8Array(bytes)
24 window.crypto.getRandomValues(some)
26 const gen = new more.Generator()
28 return new Promise((resolve, reject) => {
29 gen.generate(bits, result => {
30 const chunked = lodash.chunk(result, 2)
31 const desired = chunked.slice(0, bytes) // only take required entropy
32 const more = lodash.flatMap(desired, arr => arr[0] ^ arr[1])
33 const entropy = lodash.zipWith(some, more, (x, y) => x ^ y)
34 const buf = Buffer.from(entropy)
35 const patq = ob.hex2patq(buf.toString('hex'))
37 reject('Entropy generation failed')
42// return a wallet object
43const generateWallet = async (point, ticket, boot) => {
47 seedSize: SEED_LENGTH_BYTES,
54 const wallet = await kg.generateWallet(config);
56 // This is here to notify anyone who opens console because the thread
57 // hangs, blocking UI updates so this cannot be done in the UI
58 console.log('Generating Wallet for point address: ', point);
63const generateOwnershipWallet = async (point, ticket) => {
64 return await kg.generateOwnershipWallet({
70const seq = num => Array.from(Array(num), (_, i) => i)
72const compose = (...fs) => fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v)
77 generateOwnershipWallet,
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