EthereumKit
EthereumKit copied to clipboard
HDWallet.privateKey().raw returns 31 byte key instead of 32-byte
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
.
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.