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

Wallet Signer calculates wrong account when provided 64-byte private key buffer #2926

Closed
ritave opened this issue Apr 24, 2022 · 1 comment
Closed
Assignees
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@ritave
Copy link

ritave commented Apr 24, 2022

Ethers Version

5.6.4

Search Terms

wallet, sign

Describe the Problem

Please see the code snippet, it's all explained there.

My expected behaviour would be to throw an error when the provided private key is not the correct size.

Thank you to @Mrtenz for debugging the error.

Code Snippet

// Version used: @metamask/key-tree@3.0.1
import { BIP44CoinTypeNode } from '@metamask/key-tree';
import { Wallet } from 'ethers';

const node = new BIP44CoinTypeNode([
      `bip39:toilet year elite cabin army same grocery ridge ticket identify gift adapt`,
      `bip32:44'`,
      `bip32:60'`,
    ]);
// The current publicly released key-tree returns a 64-byte buffer with first 32-bytes being the private key
// And second 32-bytes being the chain code
const key = node.deriveBIP44AddressKey({ account: 0, change: 0, address_index: 0});

let wallet = new Wallet(key);
// Wrong address returned: 0xe08356b9A7ADDCc13Dc4F4768b55a870217F716A
console.log(wallet.address);

wallet = new Wallet(key.slice(0, 32));
// Expected address returned: 0x67AA6d3C483c8461f00483d09d506A83D696d17a
console.log(wallet.address);

Contract ABI

No response

Errors

No response

Environment

Browser (Chrome, Safari, etc)

Environment (Other)

No response

@ritave ritave added the investigate Under investigation and may be a bug. label Apr 24, 2022
@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Apr 24, 2022
@ricmoo
Copy link
Member

ricmoo commented May 3, 2022

Fixed in 5.6.5 (See 7b299dd).

Thanks! :)

@ricmoo ricmoo closed this as completed May 3, 2022
@ricmoo ricmoo added bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. and removed investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. labels May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants