ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

add secp256k1 key type #4172

Closed inverted-capital closed 2 years ago

inverted-capital commented 2 years ago

In the docs we are promised the secp256k1 key type being available, but it is not. Is there some error with doing this ?

welcome[bot] commented 2 years ago

Thank you for submitting this PR! A maintainer will be here shortly to review it. We are super grateful, but we are also overloaded! Help us by making sure that:

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment. Next steps:

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. We are very grateful for your contribution!

lidel commented 2 years ago

Triage notes:

It happens to be listed there because IPFS nodes reuse libp2p keystore, and libp2p's specs for peerid list these key types:

        RSA = 0;
    Ed25519 = 1;
    Secp256k1 = 2;
    ECDSA = 3;

afaik no IPFS implementation uses anything other than RSA and Ed25519, so allowing it here may open interoperability issues, especially in the context of IPNS specificiation which uses the same keystore, but does not explicitly list which key types should be supported by minimal IPNS implementation.

I'm marking this is blocked until we clarify the specs, at least IPNS one.


@inverted-capital mind elaborating why do you want to use secp256k1? is there a practical need (if so, it is useful for us to understand it, so we can adjust specs, if it is generic enough) or did you fill it only for completeness?

inverted-capital commented 2 years ago

Thanks for the review @lidel - we are using the private key to provide other forms of digital signing, and the scp256k1 key fills application specific needs for us. We would like to reuse the IPFS key management systems, and we would like only one secret key in our application, so it is convenient if they are the same. We think some of our preference for this algorithm overlap with what is useful to IPFS, namely:

  1. audited and dependency free JS implementation in @noble/secp256k1
  2. Very fast signing performance - less than 0.5ms in our benchmarks
  3. Short key and signature lengths making it easier on the eye when reading data that is signed in this fashion, or when reading the public keys.

So this pull request is not based on some feature of IPFS that we need, but our more general preference and trust the algorithm and implementation.