1import ob from 'urbit-ob';
2import kg from 'urbit-key-generation';
3import * as more from 'more-entropy';
4import { chunk, flatMap, zipWith } from 'lodash';
16const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8;
18// returns a promise for a ticket string
19export const makeTicket = point => {
25 : PLANET_ENTROPY_BITS;
27 const bytes = bits / 8;
28 const some = new Uint8Array(bytes);
29 window.crypto.getRandomValues(some);
31 const gen = new more.Generator();
33 return new Promise((resolve, reject) => {
34 gen.generate(bits, result => {
35 const chunked = chunk(result, 2);
36 const desired = chunked.slice(0, bytes); // only take required entropy
37 const more = flatMap(desired, arr => arr[0] ^ arr[1]);
38 const entropy = zipWith(some, more, (x, y) => x ^ y);
39 const buf = Buffer.from(entropy);
40 const patq = ob.hex2patq(buf.toString('hex'));
42 reject('Entropy generation failed');
47// return a wallet object
48export const generateWallet = async (point, ticket, boot) => {
51 seedSize: SEED_LENGTH_BYTES,
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);
62 const wallet = await kg.generateWallet(config);
67export const generateOwnershipWallet = (ship, ticket) =>
68 kg.generateOwnershipWallet({ ship, ticket });
70// temporary wallets need to be derivable from just the ticket,
71// so we always use ~zod as the wallet point.
72export const generateTemporaryOwnershipWallet = ticket =>
73 generateOwnershipWallet(ZOD, ticket);
75export const generateTemporaryTicketAndWallet = async point => {
76 const ticket = await makeTicket(point);
77 const owner = await generateOwnershipWallet(ZOD, ticket);
79 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