-
Notifications
You must be signed in to change notification settings - Fork 3
Add privkey in WIF format #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ export const en = { | |
| multiline: 'Multiline', | ||
| publicKeyQrCode: 'Public key QR code', | ||
| privateKey: 'Private key', | ||
| privateKeyWIF: 'Private key in WIF', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before merge, please add translations or at least placeholders. We don't want the users to see typical for JS "undefined" |
||
| phrase: 'Phrase', | ||
| privateKeyQrCode: 'Private key QR code', | ||
| generateNewKey: 'Generate new key', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import { pbkdf2Sync } from 'pbkdf2'; | |
| import * as ecurve from 'ecurve'; | ||
| import { GeneratedKey } from '../components/pages/keyGenerator/KeyGeneratorContent'; | ||
| const bigi = require('bigi'); | ||
| const wif = require('wif'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can see use import |
||
|
|
||
| const getBitsFromBytes = (bytes: Buffer) => { | ||
| let bits = ''; | ||
|
|
@@ -40,9 +41,17 @@ export const generateNewKeys = (): GeneratedKey => { | |
| const privateKey = pbkdf2Sync(random128bits, random132bits.slice(0, 4), 1, 32, 'sha256'); | ||
| const curve = ecurve.getCurveByName('secp256k1'); | ||
| const publicKey = curve.G.multiply(bigi.fromBuffer(privateKey)).getEncoded(false).toString('hex'); | ||
| let networkWIF; | ||
| if (process.env.REACT_APP_NETWORK === 'testnet' || process.env.REACT_APP_NETWORK === 'regtest') { | ||
| networkWIF = 0xef; | ||
| } else { | ||
| networkWIF = 0x80; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be clearer to extract it to function? |
||
|
|
||
| return { | ||
| publicKey, | ||
| privateKey: privateKey.toString('hex'), | ||
| privateKeyWIF: wif.encode(networkWIF, privateKey, false), | ||
| words: generatedWords || [] | ||
| }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it better to place it in a multiline field? It should be easier for users to copy it then, I believe