hyperledger-archives / ursa

Hyperledger Ursa (a shared cryptographic library) has moved to end-of-life status, with the components of Ursa still in use moved to their relevant Hyperledger projects (AnonCreds, Indy, Aries and Iroha).
https://wiki.hyperledger.org/display/ursa
Apache License 2.0
321 stars 142 forks source link

replace libsecp256k1 with k256 crate #163

Closed dcmiddle closed 1 year ago

dcmiddle commented 3 years ago

@tarcieri mentions in #162 an alternative to libsecp256k1. I think the selection of the libsecp256k1 was for minimalist builds for e.g. mobile devices. Performance differential should be evaluated as well. Please discuss other criteria to evaluate. Current: https://crates.io/crates/libsecp256k1 Proposed: https://crates.io/crates/k256

tarcieri commented 3 years ago

Here are some benchmarks I performed, comparing k256 to libsecp256k1 to the secp256k1 C library wrapper:

https://github.com/tarcieri/rust-secp256k1-ecdsa-bench

image

k256 notably implements quite a few optimizations, including lazy normalization and endomorphisms.

I'll have a blog post up about it tomorrow.

mikelodder7 commented 3 years ago

Awesome. No problem with the recommendation.

dcmiddle commented 3 years ago

Fwiw, I was able to reproduce those performance numbers on my local system.

Note that the k256 readme does warn users it has not been independently audited. That said I don't see any indication that libsecp256k1 has been audited either. From a security perspective perhaps the only readily apparent difference is that k256 is a younger project (looks like as of Jan of this year) with presumably less battlehardening (libsecp256k1 has been around since Nov 2017).

My sense though is even with that, it is preferable to move to k256

tarcieri commented 3 years ago

Blog post is up with some additional information/background: https://iqlusion.blog/k256-crate-pure-rust-projective-secp256k1-library

hartm commented 3 years ago

This looks like a nice library. It probably makes sense for us to switch. I guess we can discuss this in more detail at the meeting tomorrow. Thanks @tarcieri and @dcmiddle for bringing this up!

brianorwhatever commented 2 years ago

This k256 crate appears to be breaking the portable build (maybe more i'm not sure..) I have no rust experience but am taking a look..

tarcieri commented 2 years ago

@brianorwhatever please let me know what problems you're experiencing

brianorwhatever commented 2 years ago

@tarcieri please see https://github.com/hyperledger/ursa/issues/193 for the error log. I think there is just slight tweaks in how some of the methods work. I started poking at some of them and my inexperience in rust blocked me pretty quickly

tarcieri commented 2 years ago

Yeah, looks like some incorrect paths when referencing/invoking various types/methods.