Closed PeterBenc closed 6 months ago
At first glance this looks great. I will be doing a proper review next week, thanks for your patience!
@Mrtenz have you had time to look into cip3
?
PS: all relevant links are in the PR description :)
@Mrtenz have you had time to look into
cip3
? PS: all relevant links are in the PR description :)
Not yet, sorry about that. Will make time to look into this more this week!
Can you rebase your branch?
@Mrtenz the last couple of issues should be resolved. Should I squash the commits or do you want to do it yourself?
src/index.ts
is missing coverage(?), and you need to run yarn lint:fix
. Looks good to me other than that!
Should be fixed
Should I squash the commits into some reasonable chunks, would that be relevant for audit too? do you want to do it yourself? Let me know :)
No need to. We want to do an audit for some other smaller changes since the last audit anyway, so I will just squash when merging this PR.
What is the current state of things and why does it need to change?
secp256k1
anded25519
getBip32Entropy
) are different from keys that would standard Cardano wallet give, for the same mnemonicmetamask-snaps
andmetamask-extension
repos, which are ready, awaiting feedback on this)What is the solution your changes offer and how does it work?
For this reasons
we add a new derivation
curve
, calleded25519Bip32
, this curve implements a slight modification of how standarded25519
is used in SLIP10.we add a new
deriver
, calledcip3Icarus
which derives keys according toCIP3
(which is the standard for Cardano)from the interface point of view, these changes allow us to call
which returns keys consistent with Cardano derivation standard
A longer explanation, also present in the code
CIP-3 defines standards for deriving keys on Cardano.
Key attributes
Root/Master key is derived from entropy, not seed. For this implementation we work with Icarus standard as it is the most widely used. See https://github.com/cardano-foundation/CIPs/blob/09d7d8ee1bd64f7e6b20b5a6cae088039dce00cb/CIP-0003/Icarus.md.
HD node consists of a 64 byte private key, 32 byte public key and 32 byte chain code. See https://github.com/cardano-foundation/CIPs/blob/09d7d8ee1bd64f7e6b20b5a6cae088039dce00cb/CIP-0003/CIP-0003.md#master-key-generation.
For derivation of BIP32 HD nodes, it uses modified implementation of ed25519 called BIP32-Ed25519. See https://input-output-hk.github.io/adrestia/static/Ed25519_BIP.pdf.
Are there any issues or other links reviewers should consult to understand this pull request better? For instance:
All sources are referenced in the code, and explained quite extensively, namely
Reference implementations