Closed lehnberg closed 5 years ago
Found this comment by apoelstra regarding this new implementation https://old.reddit.com/r/Bitcoin/comments/8c21mo/we_made_bulletproofs_twice_as_fast_with_rust_and/dxcr2xi/ maybe the one @ignopeverell refers to
Probably worth explicitly stating that this is a very non-trivial change, and not something we can dismissively plan to hardfork. Some things to think about:
A few unordered thoughts:
It would be insane to produce bulletproofs with research-quality code; or code in a language like Rust with many extremely aggressive compiler optimizations that basically can't be overridden without UB. It is less insane to validate Bulletproofs this way because you don't care about constant-timeness, but even more dangerous, because the risk changes from "will this leak secret data from actively-monitored users" to "will this cause a permanent unexpected chain fork".
In Bitcoin when we moved from OpenSSL to libsecp256k1, we moved signing over many years before we moved verification; and actually we only changed verification to libsecp after we'd discovered that OpenSSL had latent consensus bugs all by itself. Of course, if you are deliberately hardforking and completely changing the curve, backward compatibility isn't a concern, but my point is that verification/consensus logic is scary.
The bulk of the speedup from the Dalek code (~75% IIRC) comes from their use of AVX2, which could be also done in libsecp. The rest comes from a combination of their cheaper curve operations and Rust, but it's hard to tell what's what because you can't just "turn off" either one the way you can with AVX2. Unfortunately I think the majority comes from cheaper curve operations ("unfortunate" because while it's possible to write a BP verifier in Rust, it's not possible to get curve25519-dalek-style additions for secp256k1).
In general, the curve25519-dalek community is very open to exposing basic cryptographic primitives to allow people to "roll their own crypto". This makes sense for code written by cryptographers for cryptographers, but I'd be hesitant to use such code in production because there are many considerations (e.g. sidechannel hardening, anti-footgun API design) which require a production-oriented mindset (plus they're boring, both from a research perspective and a programmer's perspective). Not to mention the temptation to do cryptographically dangerous things in user-level code when your library hards you the sharp tools to do so.
Speed update: https://medium.com/@hdevalence/even-faster-edwards-curves-with-ifma-8b1e576a00e9
Intel’s AVX512 instruction set includes an extension, AVX512-IFMA, aimed at accelerating integer arithmetic. I wrote a new curve25519-dalek backend in Rust, using these instructions to implement the parallel formula strategy. This gives another performance gain of about 1.5x relative to my AVX2 implementation, or 2.3x relative to ed25519-donna, and it seems likely that it’s the fastest Curve25519 implementation ever. More interestingly, it almost closes the performance gap (for now) between Curve25519 and the newer and faster FourQ curve from Microsoft Research, even when FourQ uses the (patented) endomorphism speedup
I think we can consider this investigated for now
Overview
Related Gitter chat: