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).

Home Page:https://wiki.hyperledger.org/display/ursa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

replace libsecp256k1 with k256 crate

dcmiddle opened this issue · comments

commented

@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

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.

Awesome. No problem with the recommendation.

commented

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

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

commented

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!

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..

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

@tarcieri please see #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

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