add bip39ToSeed password param

This commit is contained in:
Jaco Greeff
2019-03-23 18:32:52 +01:00
parent b7cbdb432f
commit 06f2e0eb31
9 changed files with 14 additions and 17 deletions
+4
View File
@@ -1,3 +1,7 @@
# 0.5.1
- Add password argument to bip39ToSeed
# 0.4.1
- Add bip39ToSeed
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "0.4.1"
"version": "0.5.0"
}
-8
View File
@@ -1,8 +0,0 @@
# 0.2.0
- Add soft key derivation functions
- Rename exposed functions to camelCase
# 0.1.0
- Initial version
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/wasm-crypto",
"version": "0.4.1",
"version": "0.5.0",
"author": "Jaco Greeff <jacogr@gmail.com>",
"files": [
"crypto-polyfill.js",
+1 -1
View File
@@ -5,7 +5,7 @@
export function bip39Generate (words: 12 | 15 | 18 | 21 | 24): string;
export function bip39ToEntropy (phrase: string): Uint8Array;
export function bip39ToMiniSecret (phrase: string, password: string): Uint8Array;
export function bip39ToSeed (phrase: string): Uint8Array;
export function bip39ToSeed (phrase: string, password: string): Uint8Array;
export function bip39Validate (phrase: string): boolean;
export function blake2b (data: Uint8Array, key: Uint8Array, byteSize: number): Uint8Array;
export function keccak256 (data: Uint8Array): Uint8Array;
+4 -3
View File
@@ -78,9 +78,10 @@ pub fn ext_bip39_to_mini_secret(phrase: &str, password: &str) -> Vec<u8> {
///
/// Returns a 32-byte seed
#[wasm_bindgen]
pub fn ext_bip39_to_seed(phrase: &str) -> Vec<u8> {
pub fn ext_bip39_to_seed(phrase: &str, password: &str) -> Vec<u8> {
let mnemonic = Mnemonic::from_phrase(phrase, Language::English).unwrap();
Seed::new(&mnemonic, "")
Seed::new(&mnemonic, password)
.as_bytes()[..32]
.to_vec()
}
@@ -273,7 +274,7 @@ pub mod tests {
fn can_bip39_seed() {
let phrase = "seed sock milk update focus rotate barely fade car face mechanic mercy";
let seed = hex!("3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027");
let result = ext_bip39_to_seed(phrase);
let result = ext_bip39_to_seed(phrase, "");
assert_eq!(result[..], seed[..]);
}
+1 -1
View File
@@ -39,7 +39,7 @@ function bip39ToMiniSecret () {
}
function bip39ToSeed () {
const RESULT = u8aToHex(crypto.bip39ToSeed('seed sock milk update focus rotate barely fade car face mechanic mercy'));
const RESULT = u8aToHex(crypto.bip39ToSeed('seed sock milk update focus rotate barely fade car face mechanic mercy', ''));
console.log('\SEE', RESULT);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/wasm-dalek-ed25519",
"version": "0.4.1",
"version": "0.5.0",
"author": "Jaco Greeff <jacogr@gmail.com>",
"files": [
"index.d.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/wasm-schnorrkel",
"version": "0.4.1",
"version": "0.5.0",
"collaborators": [
"Jaco Greeff <jacogr@gmail.com>",
"kianenigma <Kian.peymani@gmail.com>"