@@ -15,19 +15,10 @@ import { BRIDGE_ERROR } from '../lib/error'
1515import { Row, Col, Warning, Button, H1, H3 } from '../components/Base'
1616
1717// for wallet generation
18−import * as kg from '../../../node_modules/urbit-key-generation/dist/index'
19−import * as more from 'more-entropy'
20−import lodash from 'lodash'
18+import * as wg from '../../walletgen/lib/lib'
2119import PaperCollateralRenderer from 'PaperCollateralRenderer'
2220import JSZip from 'jszip'
2321import saveAs from 'file-saver'
24−import { MAX_GALAXY, MIN_STAR, MAX_STAR, MIN_PLANET,
25− GALAXY_ENTROPY_BITS, STAR_ENTROPY_BITS, PLANET_ENTROPY_BITS,
26− SEED_ENTROPY_BITS,
27− GEN_STATES
28− } from '../../walletgen/lib/constants'
29−const SEED_LENGTH_BYTES = SEED_ENTROPY_BITS / 8
30−const NEXT_STEP_NUM = 6;
3122
3223class InviteWallet extends React.Component {
3324
@@ -74,63 +65,10 @@ class InviteWallet extends React.Component {
7465 //
7566 }
7667
77− //TODO pulled from walletgen/views/Generate and Download, put into lib
7868 async generateWallet(point) {
79− const makeTicket = point => {
80−
81− const bits = point < MIN_STAR
82− ? GALAXY_ENTROPY_BITS
83− : point < MIN_PLANET
84− ? STAR_ENTROPY_BITS
85− : PLANET_ENTROPY_BITS
86−
87− const bytes = bits / 8
88− const some = new Uint8Array(bytes)
89− window.crypto.getRandomValues(some)
90−
91− const gen = new more.Generator()
92−
93− return new Promise((resolve, reject) => {
94− gen.generate(bits, result => {
95− const chunked = lodash.chunk(result, 2)
96− const desired = chunked.slice(0, bytes) // only take required entropy
97− const more = lodash.flatMap(desired, arr => arr[0] ^ arr[1])
98− const entropy = lodash.zipWith(some, more, (x, y) => x ^ y)
99− const buf = Buffer.from(entropy)
100− const patq = ob.hex2patq(buf.toString('hex'))
101− resolve(patq)
102− reject('Entropy generation failed')
103− })
104− })
105− }
106−
107− const genWallet = async (point, ticket, cb) => {
108−
109− const config = {
110− ticket: ticket,
111− seedSize: SEED_LENGTH_BYTES,
112− ship: point,
113− password: '',
114− revisions: {},
115− boot: false //TODO should this generate networking keys here already?
116− };
117−
118− const wallet = await kg.generateWallet(config);
119−
120− // This is here to notify the anyone who opens console because the thread
121− // hangs, blocking UI updates so this cannot be doen in the UI
122− console.log('Generating Wallet for point address: ', point);
123−
124− return wallet;
125− }
126−
127− const ticket = await makeTicket(point);
128−
129− const wallet = await genWallet(point, ticket);
130−
69+ const ticket = await wg.makeTicket(point);
70+ const wallet = await wg.generateWallet(point, ticket);
13171 this.setState({ wallet: Just(wallet) });
132− console.log('got wallet', wallet);
133− console.log('should start rendering now');
13472 }
13573
13674 download() {