Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDWallet.privateKey().raw returns 31 byte key instead of 32-byte #168

Open
DmitryBespalov opened this issue Jun 17, 2019 · 1 comment
Open

Comments

@DmitryBespalov
Copy link
Contributor

This code returns private key data with a length of 31 byte, which is not correct. The data doesn't have leading zero byte.

        let mnemonic = "half try deer tray hockey ball notable abstract affair main desert session"
        let seed = Mnemonic.createSeed(mnemonic: mnemonic)
        let hdWallet = HDWallet(seed: seed, network: Network.private(chainID: 0, testUse: false))
        let privateKey = try! hdWallet.privateKey(at: 1).raw

The expected private key is 0x007179e85007a04d2a9cae63be80326aa2c218f75394b7d37ccd1b660c8b180d but the actual is 0x7179e85007a04d2a9cae63be80326aa2c218f75394b7d37ccd1b660c8b180d .

@sachin-chauhan-dev
Copy link

Facing similar issue. Web3j creates complete 32 byte private key with zero padding with the same mnemonics but EthereumKit doesn't. Because of this invalid signatures are getting created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants