This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Substrate BIP-39 generate different seeds between Polkadot-API and Subkey #14631
Open
Description
Is there an existing issue?
- I have searched the existing issues
Experiencing problems? Have you tried our Stack Exchange first?
- This is not a support question.
Description of bug
The implementation of Substrate BIP39 is not consistent between polkadot-api and subkey for numerical junctions that have more than 64bits, example:
Using polkadot-api keyring:
import { Keyring } from '@polkadot/keyring';
const keyring = new Keyring({ type: 'sr25519', ss58Format: 42 });
const account = keyring.createFromUri("//18446744073709551616");
console.log(account.address);
// Output: 5FsxbdTHtNSLE5HCLzzGVB2oEzxZB6QJuakiHSoTNWEXD1qj
Using subkey:
$ subkey inspect --scheme=Sr25519 --network=substrate "//18446744073709551616"
Secret Key URI `//18446744073709551616` is account:
Network ID: substrate
Secret seed: 0xe95232125504305f665b8e8c891e1e1e87fcbb0b4eff38a9e100862207d2ce97
Public key (hex): 0x11ea83f6705f1e3bd3b50695227a1c64dccd5c368648f17eb80f093695028daa
Account ID: 0x11ea83f6705f1e3bd3b50695227a1c64dccd5c368648f17eb80f093695028daa
Public key (SS58): 5CUCLVQzLh5oxNanu3699rqaxmkiQG4kNNd4WCDfJWiqwuYk
SS58 Address: 5CUCLVQzLh5oxNanu3699rqaxmkiQG4kNNd4WCDfJWiqwuYk
This section of the documentation says:
purely numeric items are interpreted as integers, non-numeric items as strings.
However it doesn't define a max bitlength for the numerical value, the Javascript implementation consider integers of any size:
const RE_NUMBER = /^\d+$/;
RE_NUMBER.test(code)
? new BN(code, 10)
: code
While the Rust implementation only accepts u64
:
let res = if let Ok(n) = str::parse::<u64>(code) {
// number
DeriveJunction::soft(n)
} else {
// something else
DeriveJunction::soft(code)
};
Which implementation is the right one?
Steps to reproduce
No response
Metadata
Assignees
Labels
No labels
Activity