Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

replace libsecp256k1 with k256 crate #163

Closed
dcmiddle opened this issue Nov 9, 2020 · 9 comments
Closed

replace libsecp256k1 with k256 crate #163

dcmiddle opened this issue Nov 9, 2020 · 9 comments
Assignees

Comments

@dcmiddle
Copy link
Contributor

dcmiddle commented Nov 9, 2020

@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
Copy link
Contributor

tarcieri commented Nov 9, 2020

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
Copy link
Contributor

Awesome. No problem with the recommendation.

@dcmiddle
Copy link
Contributor Author

dcmiddle commented Nov 9, 2020

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
Copy link
Contributor

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

@hartm
Copy link
Contributor

hartm commented Nov 11, 2020

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!

@dcmiddle dcmiddle self-assigned this Nov 11, 2020
@brianorwhatever
Copy link

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
Copy link
Contributor

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

@brianorwhatever
Copy link

@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

@tarcieri
Copy link
Contributor

tarcieri commented Oct 29, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants