@@ -22,44 +22,14 @@ class GenKeyfile extends React.Component {
23 this.state = {
23 this.state = {
24 keyfile: '',
24 keyfile: '',
25− networkSeed: ''
25+ loaded: false
28− this.handleNetworkSeedInput = this.handleNetworkSeedInput.bind(this)
29− this.handleKeyfileChange = this.handleKeyfileChange.bind(this)
32− componentDidMount() {
36− async deriveSeed() {
29+ getPointDetails() {
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
30 const { pointCache } = this.props
59 const { pointCursor } = this.props
31 const { pointCursor } = this.props
61− const { keyfile, networkSeed } = this.state
63 const point = pointCursor.matchWith({
33 const point = pointCursor.matchWith({
64 Just: (pt) => pt.value,
34 Just: (pt) => pt.value,
65 Nothing: () => {
35 Nothing: () => {
@@ -74,6 +44,34 @@ class GenKeyfile extends React.Component {
75 const revision = parseInt(pointDetails.keyRevisionNumber)
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) {
77 const crypub = pointDetails.encryptionKey
75 const crypub = pointDetails.encryptionKey
78 const sgnpub = pointDetails.authenticationKey
76 const sgnpub = pointDetails.authenticationKey
@@ -83,77 +81,64 @@ class GenKeyfile extends React.Component {
83 crypub === addHexPrefix(crypt.public)
81 crypub === addHexPrefix(crypt.public)
84 && sgnpub === addHexPrefix(auth.public)
82 && sgnpub === addHexPrefix(auth.public)
87− keyfile !== '' && keysmatch === false
84+ return keysmatch;
90− <b>{ 'WARNING' }</b>{ ": derived key doesn't match Azimuth keys!" }
95− const hexRegExp = /[0-9A-Fa-f]{64}/g
87+ async deriveSeed() {
89+ let seed = await attemptSeedDerivation(next, this.props)
97− const download =
91+ if (seed.getOrElse('') === '' && this.props.networkSeedCache) {
98− keyfile !== ''
92+ seed = Maybe.Just(this.props.networkSeedCache)
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." }
95+ return seed.getOrElse('')
99+ const { point, pointDetails, revision } = this.getPointDetails();
100+ const { keyfile, loading } = this.state
123 <Col className={'col-md-8'}>
104 <Col className={'col-md-8'}>
124 <H1>{ 'Generate keyfile' }</H1>
105 <H1>{ 'Generate keyfile' }</H1>
127− { "Generate a private key file for booting this point in Arvo." }
108+ { "Download a private key file for booting this point in Arvo." }
130− { networkSeedWarning }
111+ { keyfile === '' &&
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">
150− { keyfile }
113+ { "Generating keyfile..." }
154− { warning }
117+ { keyfile === '' &&
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` }
156− { download }
126+ { keyfile !== '' &&
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`)