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`)
110 let networkSeedWarning
112 if (this.state.networkSeed === '') {
113 networkSeedWarning = (
116 { "No network seed detected. To generate a keyfile, you must reset your networking keys." }
123 <Col className={'col-md-8'}>
124 <H1>{ 'Generate keyfile' }</H1>
127 { "Generate a private key file for booting this point in Arvo." }
130 { networkSeedWarning }
135 disabled={this.state.networkSeed === ''}
138 if (hexRegExp.test(networkSeed)) {
139 const keyfile = genKey(networkSeed, point, revision)
140 this.setState({ keyfile })
149 <Code className="pb-5">
165export 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