Remove bip39ToSeed (#80)

* Cleanups, no mnemonic to seed (only minisecret)

* Remove bip39ToSeed
This commit is contained in:
Jaco Greeff
2020-05-31 14:42:13 +02:00
committed by GitHub
parent 1e2caa35ce
commit ef6db82c52
8 changed files with 1457 additions and 913 deletions

View File

@@ -10,7 +10,7 @@ jobs:
matrix:
step: ['build:release']
name: ${{ matrix.step }}
if: "! contains(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/wasm'"
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/wasm'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@@ -20,15 +20,13 @@ jobs:
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
GH_PAT: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn ${{ matrix.step }}
dummy:
name: Dummy
if: "contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
steps:
- name: dummy

View File

@@ -1,83 +1,89 @@
# 1.2.1 Feb 29, 2020
# CHANGELOG
## 1.3.0-beta.x
- Remove `bip39ToSeed`, we only use the `bip39ToMiniSecret` variant in Substrate
## 1.2.1 Feb 29, 2020
- Adjust build process for smaller wasm bundle outputs (~50K dropped from base bundle)
- Unpin nightly from nightly-2020-02-17 version
- Swap to yarn 2 and add support for use by yarn 2 projects
# 1.1.1 Feb 24, 2020
## 1.1.1 Feb 24, 2020
- **Important** The sr25519 interface dropped the use of `verify_simple_preaudit_deprecated` for signature verification, instead it now uses `verify_simple`. Only schnorrkel 0.8+ signatures will now pass verification. This is a follow-up of the 0.1 signing support that was dropped in a previous version.
- Rework schnorrkel signatures test vectors based on the above change (Rust, WASM and ASM.js tests)
- Rust nightly pinned to last-known-working 2020-02-17 on CI (compiler issues, should to be reverted in a future release)
# 1.0.1 Feb 15, 2020
## 1.0.1 Feb 15, 2020
- No functionality changes from 0.20.1. The interfaces here are stable in the current iteration.
# 0.20.1 Jan 30, 2020
## 0.20.1 Jan 30, 2020
- Pull in schnorrkel 0.8.5 for full Substrate 2.x compatibility
# 0.14.1 Sep 09, 2019
## 0.14.1 Sep 09, 2019
- No functionality changes at all, everything done is "under the hood" to give the codebase better maintainability
# 0.13.1 Jul 20, 2019
## 0.13.1 Jul 20, 2019
- Added an asm.js fallback which is active for React Native via the `"react-native"` entry in `package.json`. Ensure that you run the build step with the `NODE_OPTIONS=--max_old_space_size=8192` flags, since the asm.js bundle is large. (For RN the full command would therefore be `NODE_OPTIONS=--max_old_space_size=8192 npm start`)
# 0.12.1 Jul 17, 2019
## 0.12.1 Jul 17, 2019
- Remove deprecated `@polkadot/wasm-schnorrkel` & `@polkadot/wasm-dalek-ed25519` source (all combined in `@polkadot/wasm-crypto`, was kept for historical purposes)
- Security dependency bumps
- Updated Rust `hex-literal` for recent versions of the compiler (used in tests only)
# 0.11.1 May 31, 2019
## 0.11.1 May 31, 2019
- Security dependency bumps
# 0.10.1 May 09, 2019
## 0.10.1 May 09, 2019
- w3f/schnorrkel updated to 0.1.1 as per substrate
- Added known subkey signature test (Rust & JS)
# 0.9.1 Apr 29, 2019
## 0.9.1 Apr 29, 2019
- Dependency bumps
# 0.8.1 Mar 31, 2019
## 0.8.1 Mar 31, 2019
- Pull ed25519 & sr25519 into `@polkadot/wasm-crypto` as well (smaller final size)
- Disable build/publish of `wasm-dalek-ed25519` & `wasm-schnorrkel`
- Improve error messaging, instead of `__wasm_malloc of null`
# 0.7.1 Mar 30, 2019
## 0.7.1 Mar 30, 2019
- Fix build scripts to properly attach errors in the log (dropped in 0.6.1)
# 0.6.1 Mar 27, 2019
## 0.6.1 Mar 27, 2019
- Log init errors for both non-WebAssembly usage as well as WebAssembly errors
# 0.5.1 Mar 23, 2019
## 0.5.1 Mar 23, 2019
- Add password argument to bip39ToSeed
# 0.4.1 Mar 23, 2019
## 0.4.1 Mar 23, 2019
- Add bip39ToSeed
# 0.3.1 Mar 23, 2019
## 0.3.1 Mar 23, 2019
- Add wasm-dalek-ed25519 for all used crypto there
- Add keccak256
- Try secp256k1 (bloating code, not used atm)
# 0.2.1 Mar 20, 2019
## 0.2.1 Mar 20, 2019
- Add basic crypto functions, creation of wasm-crypto package
- blake2, bip39, sha2, xxhash
# 0.1.1 Mar 18, 2019
## 0.1.1 Mar 18, 2019
- Initial release

View File

@@ -19,6 +19,6 @@
},
"devDependencies": {
"@babel/core": "^7.9.6",
"@polkadot/dev": "^0.54.1"
"@polkadot/dev": "^0.55.6"
}
}

View File

@@ -20,7 +20,7 @@
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"@polkadot/dev": "^0.54.1",
"@polkadot/dev": "^0.55.6",
"@polkadot/util": "^2.10.1",
"override-require": "^1.1.1"
},

View File

@@ -48,20 +48,6 @@ pub fn ext_bip39_to_mini_secret(phrase: &str, password: &str) -> Vec<u8> {
result[..32].to_vec()
}
/// Creates a see from a bip-39 phrase
///
/// @phrase: mnemonic phrase
///
/// Returns a 32-byte seed
#[wasm_bindgen]
pub fn ext_bip39_to_seed(phrase: &str, password: &str) -> Vec<u8> {
let mnemonic = Mnemonic::from_phrase(phrase, Language::English).unwrap();
Seed::new(&mnemonic, password)
.as_bytes()[..32]
.to_vec()
}
/// Validates a bip39 phrase
///
/// * phrase: mnemonic phrase
@@ -99,15 +85,6 @@ pub mod tests {
assert_eq!(result[..], mini[..]);
}
#[test]
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, "");
assert_eq!(result[..], seed[..]);
}
#[test]
fn can_bip39_generate() {
let phrase = ext_bip39_generate(12);

View File

@@ -5,7 +5,6 @@
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, password: string): Uint8Array;
export function bip39Validate (phrase: string): boolean;
export function ed25519KeypairFromSeed (seed: Uint8Array): Uint8Array;

View File

@@ -39,18 +39,9 @@ function bip39_toMiniSecret (wasm) {
assert(RESULT === '0x4313249608fe8ac10fd5886c92c4579007272cb77c21551ee5b8d60b78041685', 'ERROR: Invalid bip39 mini secret');
}
function bip39_toSeed (wasm) {
const RESULT = u8aToHex(wasm.bip39ToSeed('seed sock milk update focus rotate barely fade car face mechanic mercy', ''));
console.log('\tSEE', RESULT);
assert(RESULT === '0x3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027', 'ERROR: Invalid bip39 mini secret');
}
module.exports = {
bip39_generate,
bip39_toEntropy,
bip39_toMiniSecret,
bip39_toSeed,
bip39_validate
};

2285
yarn.lock

File diff suppressed because it is too large Load Diff