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 {
30 const { pointCache } = this.props
31 const { pointCursor } = this.props
33 const point = pointCursor.matchWith({
34 Just: (pt) => pt.value,
36 throw BRIDGE_ERROR.MISSING_POINT
43 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
45 const revision = parseInt(pointDetails.keyRevisionNumber)
54 async componentDidMount() {
55 const { point, pointDetails, revision } = this.getPointDetails();
58 const hexRegExp = /[0-9A-Fa-f]{64}/g
59 const networkSeed = await this.deriveSeed()
61 const keysmatch = this.checkKeysMatch(networkSeed, pointDetails)
62 const seedValid = hexRegExp.test(networkSeed)
64 if (keysmatch && seedValid) {
65 keyfile = genKey(networkSeed, point, revision)
74 checkKeysMatch(networkSeed, pointDetails) {
75 const crypub = pointDetails.encryptionKey
76 const sgnpub = pointDetails.authenticationKey
78 const { crypt, auth } = kg.deriveNetworkKeys(networkSeed)
81 crypub === addHexPrefix(crypt.public)
82 && sgnpub === addHexPrefix(auth.public)
89 let seed = await attemptSeedDerivation(next, this.props)
91 if (seed.getOrElse('') === '' && this.props.networkSeedCache) {
92 seed = Maybe.Just(this.props.networkSeedCache)
95 return seed.getOrElse('')
99 const { point, pointDetails, revision } = this.getPointDetails();
100 const { keyfile, loaded } = this.state
104 <Col className={'col-md-8'}>
105 <H1>{ 'Generate keyfile' }</H1>
108 { "Download a private key file for booting this point in Arvo." }
111 { keyfile === '' && !loaded &&
113 { "Generating keyfile..." }
117 { keyfile === '' && loaded &&
120 { `No valid network seed detected. To generate a keyfile, you
121 must reset your networking keys, or try logging in with your
122 master ticket or management mnemonic` }
128 <div className="pb-5 text-code keyfile">
134 let blob = new Blob([keyfile], {type:"text/plain;charset=utf-8"});
135 saveAs(blob, `${ob.patp(point).slice(1)}-${revision}.key`)
150export 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