MetaMask / key-tree

MIT License
50 stars 17 forks source link

BREAKING: Remove specification field in favour of SLIP-10 path type #124

Closed Mrtenz closed 1 year ago

Mrtenz commented 1 year ago

This replaces the specification field added in #120, with a new path type slip10:. This means that you can now use something like ["slip10:44'", "slip10:60'", /* ... */] as derivation path, as well as the current bip32: derivation paths. This simplifies the BIP-32 derivation logic, and separates SLIP-10 and BIP-32 specific logic to a separate file.

While BIP-32 and SLIP-10 are mostly the same, there are some subtle differences. Projects that require full compatibility with one or the other spec can now choose based on the path type.

Example

This works:

const node = SLIP10Node.fromExtendedKey({
  /* ... */,
  curve: 'secp256k1',
});

node.derive([`slip10:0'`, `slip10:1`]);

This also works:

const node = SLIP10Node.fromExtendedKey({
  /* ... */,
  curve: 'secp256k1',
});

node.derive([`bip32:0'`, `bip32:1`]);

This does not work anymore:

const node = SLIP10Node.fromExtendedKey({
  /* ... */,
  curve: 'ed25519', // <-- Note the curve
});

node.derive([`bip32:0'`, `bip32:1`]);

Breaking changes