Added optional export of private key#108
Conversation
Added possibility of exporting key by adding feature export-private-key
|
I've found that you can hack your key using encrypt and decrypt which returns Vec: let raw_key = secret.to_crypto(password, 1).unwrap().decrypt(password).unwrap(); Still that solution that I posted is more elegant. |
tomusdrw
left a comment
There was a problem hiding this comment.
Looks good! I'd appreciate if you could fix minor readme changes and comment on calling the method raw instead of private.
We could also change the feature name to expose-raw-private-key or sth like that?
| A library to read JSON keyfiles and sign Ethereum stuff. | ||
|
|
||
| Library by defaults hide private key from access, | ||
| but you can add --features export-private-key to export it. |
There was a problem hiding this comment.
| but you can add --features export-private-key to export it. | |
| but you can enable `export-private-key` feature to export it. |
|
|
||
| A library to read JSON keyfiles and sign Ethereum stuff. | ||
|
|
||
| Library by defaults hide private key from access, |
There was a problem hiding this comment.
| Library by defaults hide private key from access, | |
| Library by default hides raw private key from being accessed, |
|
|
||
| #[cfg(feature = "export-private-key")] | ||
| { | ||
| //Do not print private key in that way in production code |
There was a problem hiding this comment.
| //Do not print private key in that way in production code | |
| // Do not print private key in that way in production code! |
|
|
||
| #[cfg(feature = "export-private-key")] | ||
| { | ||
| //Do not print private key in that way in production code |
There was a problem hiding this comment.
| //Do not print private key in that way in production code | |
| // Do not print private key in that way in production code! |
| /// Export stored, unencrypted, plain private key, use with caution | ||
| /// Do not expose this key in logs, etc. Use only if needed |
There was a problem hiding this comment.
| /// Export stored, unencrypted, plain private key, use with caution | |
| /// Do not expose this key in logs, etc. Use only if needed | |
| /// Export stored, unencrypted, plain private key. | |
| /// | |
| /// USE WITH CAUTION! Do not expose this key in logs, | |
| /// etc. Use only if really needed. |
| /// Export stored, unencrypted, plain private key, use with caution | ||
| /// Do not expose this key in logs, etc. Use only if needed | ||
| #[cfg(feature = "export-private-key")] | ||
| pub fn private(&self) -> [u8; 32] { |
There was a problem hiding this comment.
| pub fn private(&self) -> [u8; 32] { | |
| pub fn raw(&self) -> [u8; 32] { |
WDYT about calling the function raw instead of private? I think it makes sense as it returns the raw key.
For some implementations it's useful feature, when you store your keys in keystore, but also you want possibility of getting plain private key.