1import * as ob from 'urbit-ob';
2import * as kg from 'urbit-key-generation/dist/index';
3import * as more from 'more-entropy';
4import lodash from 'lodash';
14const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8;
16// returns a promise for a ticket string
17const makeTicket = point => {
23 : PLANET_ENTROPY_BITS;
25 const bytes = bits / 8;
26 const some = new Uint8Array(bytes);
27 window.crypto.getRandomValues(some);
29 const gen = new more.Generator();
31 return new Promise((resolve, reject) => {
32 gen.generate(bits, result => {
33 const chunked = lodash.chunk(result, 2);
34 const desired = chunked.slice(0, bytes); // only take required entropy
35 const more = lodash.flatMap(desired, arr => arr[0] ^ arr[1]);
36 const entropy = lodash.zipWith(some, more, (x, y) => x ^ y);
37 const buf = Buffer.from(entropy);
38 const patq = ob.hex2patq(buf.toString('hex'));
40 reject('Entropy generation failed');
45// return a wallet object
46const generateWallet = async (point, ticket, boot) => {
49 seedSize: SEED_LENGTH_BYTES,
56 const wallet = await kg.generateWallet(config);
58 // This is here to notify anyone who opens console because the thread
59 // hangs, blocking UI updates so this cannot be done in the UI
60 console.log('Generating Wallet for point address: ', point);
66const generateOwnershipWallet = (ship, ticket) =>
67 kg.generateOwnershipWallet({ ship, ticket });
69const seq = num => Array.from(Array(num), (_, i) => i);
71const compose = (...fs) =>
72 fs.reduceRight((pF, nF) => (...args) => nF(pF(...args)), v => v);
74export { makeTicket, generateWallet, generateOwnershipWallet, compose, seq };
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