bip38
Rust implementation of bip-0038 to be used as a dependency (crate).
Functionalities
Encrypt and decrypt bitcoin private keys with bip-0038 standard.
This crate treat bitcoin private keys as raw 32 bytes ([u8; 32]
). Hexadecimal, wif or any other representation (excepting the resulting encrypted private keys) are out of scope of this implementation.
Basic examples
Encryption
use ;
// true => compress
assert_eq!;
// false => uncompress
assert_eq!;
// [0x00; 32] is an invalid private key and cannot generate a valid bitcoin address
assert_eq!;
assert_eq!;
Decryption
use ;
assert_eq!;
assert_eq!;
assert_eq!;
Generation (elliptic curve multiplication, not deterministic)
use ;
// true => compress
assert!;
// false => uncompress
assert!;
// ぽー
assert!;
Boolean flag
true
always signify: use the public key of this private keycompressed
(33 bytes).false
always signify: use the public key of this private keyuncompressed
(65 bytes).
Obs: the use of uncompressed public keys is deprecated and discouraged. For new private keys always choose the true
flag.
Normalization
This crate handle the normalization (nfc
) of the passphrase as specified on bip-0038
.
use ;
assert_eq!;
Testing
Please always run cargo test
with --release
flag. Without the optimizations of a release build running tests can consume long time (the encryption algorithm is, by design, heavy on cpu).
Usage
You can use this crate in your project by adding the following to your Cargo.toml
:
[]
= "1.0.0"
For more details and examples please go to the documentation