1import React from 'react'
3import { Button } from '../components/Base'
4import { RequiredInput, InnerLabel } from '../components/Base'
5import { Row, Col, H1, P } from '../components/Base'
6import { Form, Code } from '../components/Base'
8import * as ob from 'urbit-ob'
9import * as kg from '../../node_modules/urbit-key-generation/dist/index'
10import saveAs from 'file-saver'
12import { attemptSeedDerivation, genKey } from '../lib/keys'
13import { BRIDGE_ERROR } from '../lib/error'
16 } from '../lib/wallet'
18class GenKeyfile extends React.Component {
27 this.handleNetworkSeedInput = this.handleNetworkSeedInput.bind(this)
28 this.handleKeyfileChange = this.handleKeyfileChange.bind(this)
37 const seed = await attemptSeedDerivation(next, this.props)
39 networkSeed: seed.getOrElse('')
43 handleNetworkSeedInput = (networkSeed) => {
44 this.setState({ networkSeed })
47 handleKeyfileChange = (keyfile) => {
48 this.setState({ keyfile })
52 const { pointCache } = this.props
53 const { pointCursor } = this.props
55 const { keyfile, networkSeed } = this.state
57 const point = pointCursor.matchWith({
58 Just: (pt) => pt.value,
60 throw BRIDGE_ERROR.MISSING_POINT
67 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
69 const revision = parseInt(pointDetails.keyRevisionNumber)
71 const crypub = pointDetails.encryptionKey
72 const sgnpub = pointDetails.authenticationKey
74 const { crypt, auth } = kg.deriveNetworkKeys(networkSeed)
77 crypub === addHexPrefix(crypt.public)
78 && sgnpub === addHexPrefix(auth.public)
81 keyfile !== '' && keysmatch === false
84 <b>{ 'WARNING' }</b>{ ": derived key doesn't match Azimuth keys!" }
89 const hexRegExp = /[0-9A-Fa-f]{64}/g
96 let blob = new Blob([keyfile], {type:"text/plain;charset=utf-8"});
97 saveAs(blob, `${ob.patp(point).slice(1)}-${revision}.key`)
106 <Col className={'col-md-8'}>
107 <H1>{ 'Generate keyfile' }</H1>
110 { "Generate a private key file for booting this point in Arvo." }
115 `Enter a network seed below for generating your key file. Your
116 network seed must be a 32-byte-long hexadecimal string.`
121 `If you've authenticated with either a master ticket or a
122 management proxy mnemonic, a seed will be generated for you
131 prop-format='innerLabel'
133 value={ networkSeed }
134 onChange={ this.handleNetworkSeedInput }>
135 <InnerLabel>{ 'Network seed' }</InnerLabel>
143 if (hexRegExp.test(networkSeed)) {
144 const keyfile = genKey(networkSeed, point, revision)
145 this.setState({ keyfile })
169export default GenKeyfile
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