EthereumKit icon indicating copy to clipboard operation
EthereumKit copied to clipboard

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

Open DmitryBespalov opened this issue 5 years ago • 1 comments

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 .

DmitryBespalov avatar Jun 17 '19 13:06 DmitryBespalov

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.

sachin-chauhan-dev avatar Jul 17 '19 13:07 sachin-chauhan-dev