1import React from 'react'
2import Maybe from 'folktale/maybe'
4import { Button } from '../components/Base'
5import { RequiredInput, InnerLabel } from '../components/Base'
6import { Row, Col, H1, P } from '../components/Base'
7import { Code } from '../components/Base'
9import * as ob from 'urbit-ob'
10import * as kg from '../../node_modules/urbit-key-generation/dist/index'
11import saveAs from 'file-saver'
13import { attemptSeedDerivation, genKey } from '../lib/keys'
14import { BRIDGE_ERROR } from '../lib/error'
17 } from '../lib/wallet'
19class GenKeyfile extends React.Component {
28 this.handleNetworkSeedInput = this.handleNetworkSeedInput.bind(this)
29 this.handleKeyfileChange = this.handleKeyfileChange.bind(this)
38 let seed = await attemptSeedDerivation(next, this.props)
40 if (seed.getOrElse('') === '' && this.props.networkSeedCache) {
41 seed = Maybe.Just(this.props.networkSeedCache)
45 networkSeed: seed.getOrElse('')
49 handleNetworkSeedInput = (networkSeed) => {
50 this.setState({ networkSeed })
53 handleKeyfileChange = (keyfile) => {
54 this.setState({ keyfile })
58 const { pointCache } = this.props
59 const { pointCursor } = this.props
61 const { keyfile, networkSeed } = this.state
63 const point = pointCursor.matchWith({
64 Just: (pt) => pt.value,
66 throw BRIDGE_ERROR.MISSING_POINT
73 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
75 const revision = parseInt(pointDetails.keyRevisionNumber)
77 const crypub = pointDetails.encryptionKey
78 const sgnpub = pointDetails.authenticationKey
80 const { crypt, auth } = kg.deriveNetworkKeys(networkSeed)
83 crypub === addHexPrefix(crypt.public)
84 && sgnpub === addHexPrefix(auth.public)
87 keyfile !== '' && keysmatch === false
90 <b>{ 'WARNING' }</b>{ ": derived key doesn't match Azimuth keys!" }
95 const hexRegExp = /[0-9A-Fa-f]{64}/g
102 let blob = new Blob([keyfile], {type:"text/plain;charset=utf-8"});
103 saveAs(blob, `${ob.patp(point).slice(1)}-${revision}.key`)
112 <Col className={'col-md-8'}>
113 <H1>{ 'Generate keyfile' }</H1>
116 { "Generate a private key file for booting this point in Arvo." }
121 `Enter a network seed below for generating your key file. Your
122 network seed must be a string of 64 characters (containing 0-9, A-Z, a-z)`
127 `If you've authenticated with either a master ticket or a
128 management proxy mnemonic, a seed will be generated for you
136 prop-format='innerLabel'
138 value={ networkSeed }
139 onChange={ this.handleNetworkSeedInput }>
140 <InnerLabel>{ 'Network seed' }</InnerLabel>
148 if (hexRegExp.test(networkSeed)) {
149 const keyfile = genKey(networkSeed, point, revision)
150 this.setState({ keyfile })
173export 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