1import * as ob from 'urbit-ob';
2import * as kg from 'urbit-key-generation/dist';
3import * as more from 'more-entropy';
4import { chunk, flatMap, zipWith } from 'lodash';
15const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8;
17// returns a promise for a ticket string
18export const makeTicket = point => {
24 : PLANET_ENTROPY_BITS;
26 const bytes = bits / 8;
27 const some = new Uint8Array(bytes);
28 window.crypto.getRandomValues(some);
30 const gen = new more.Generator();
32 return new Promise((resolve, reject) => {
33 gen.generate(bits, result => {
34 const chunked = chunk(result, 2);
35 const desired = chunked.slice(0, bytes); // only take required entropy
36 const more = flatMap(desired, arr => arr[0] ^ arr[1]);
37 const entropy = zipWith(some, more, (x, y) => x ^ y);
38 const buf = Buffer.from(entropy);
39 const patq = ob.hex2patq(buf.toString('hex'));
41 reject('Entropy generation failed');
46// return a wallet object
47export const generateWallet = async (point, ticket, boot) => {
50 seedSize: SEED_LENGTH_BYTES,
57 const wallet = await kg.generateWallet(config);
59 // This is here to notify anyone who opens console because the thread
60 // hangs, blocking UI updates so this cannot be done in the UI
61 console.log('Generating Wallet for point address: ', point);
66export const generateOwnershipWallet = (ship, ticket) =>
67 kg.generateOwnershipWallet({ ship, ticket });
69export const generateTemporaryTicketAndWallet = async point => {
70 const ticket = await makeTicket(point);
71 const owner = await generateOwnershipWallet(0, ticket);
73 return { ticket, owner };
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