aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Bug]Why do not mod parent Private

Open SuperEdison opened this issue 2 years ago • 1 comments

🐛 Bug

export const CKDPriv = ({ key, chainCode }: Keys, index: number): Keys => {
  const buffer = new ArrayBuffer(4);
  new DataView(buffer).setUint32(0, index);
  const indexBytes = new Uint8Array(buffer);
  const zero = new Uint8Array([0]);
  const data = new Uint8Array([...zero, ...key, ...indexBytes]);

  const I = hmac.create(sha512, chainCode).update(data).digest();
  const IL = I.slice(0, 32);
  const IR = I.slice(32);
  return {
    key: IL,
    chainCode: IR,
  };
};

but bitcoin use parentPriv.add(newPriv).mod(ECKey.CURVE.getN());

SuperEdison avatar Oct 31 '22 08:10 SuperEdison

If submitting a bug report, please tell us in detail what the bug is.

"But Bitcoin uses [...]" does not qualify as a bug report.

Note that we are not Bitcoin: we do not use ECDSA signatures over secp256k1 curves. We used Ed25519 signatures. HD wallets for Ed25519 operate slightly differently than HD wallets for Bitcoin.

alinush avatar Oct 31 '22 20:10 alinush

Aptos HD wallet generation rules are different from Bitcoin generation rules

SuperEdison avatar Nov 24 '22 06:11 SuperEdison