Hey folks,
I've been coding a super fast version of secp256k1 from scratch using C++ and CUDA. It’s got optional optimizations for x86-64 and RISC-V.
Main goal? Max out performance and keep things efficient. Not about breaking cryptography or recovering keys.
High-Performance secp256k1 Implementation Discussion
20 replies 284 views
Totally with you on that! Your take on Fermat-based inversion and side-channel risks is spot on.
Right now, this library is all about performance research. Some of the optimization paths aim for speed, not constant-time execution, especially in controlled setups. But yeah, we’re planning for side-channel resistance next.
Just added OpenCL support for ESP32 and optimized a few more parts.
🔥 Here’s what UltrafastSecp256k1 is all about:
A zero-dependency, multi-platform secp256k1 stack that covers everything in the Bitcoin and EVM space, from basic arithmetic to complex multi-party protocols.
falcon2019Full Member
Posts: 90 · Reputation: 425
#5Mar 21, 2019, 04:02 PM
The core engine includes:
- Field and point arithmetic
- GLV endomorphism acceleration
- Precomputation tables
- Deterministic nonces
- Low-S normalization.
For assembly and SIMD, we’ve got:
- x64 assembly
- ARM64 inline assembly
- RISC-V + RVV
- Batch inversion
- AVX2 / AVX-512 operations.
Your repo looks solid! I noticed your block batch inversion is something I’ve never seen in public code before. Took me weeks to get something similar sorted out, and debugging those sync issues was a nightmare.
gwei_blockNewbie
Posts: 185 · Reputation: 37
#8Mar 22, 2019, 06:16 PM
What hardware did you use for testing the RISC-V version?
And can this run on Metal for Apple silicon? That'd be a first for a secp256k1 library.
I’ve been using the Milk-V Mars device for testing. I also plan to port it to the ESP32 RISC-V version I ordered.
I’ve tested on various platforms like STM32 and Android too. It just works everywhere without extra libraries.
Your multiple consecutive posts are kinda annoying and against the rules here. Just edit your last post instead.
Your topic is cool, don’t mess it up with spam.
Thanks for the heads up, I’ll keep that in mind.
This project sounds super intriguing! Just curious, what AI tools are you using to help speed up development?
I’m relying on my 20 years of experience and various models to quickly analyze and find performance bottlenecks. Makes it easier to create platform-specific assembly code.
Benchmark results against libsecp256k1 for BIP-352 pipeline are up.
Hey, I checked your CUDA code, but it seems like you’re not using precomputed tables for ECMULT.
With those, you could speed up the k.G process significantly. Just a thought.
Appreciate the tip! I’m focused on optimizing the CPU and MCU side first.
GPU optimizations are next, and I’m wrapping up a self-audit system for code quality.
UltrafastSecp256k1 v3.21 just dropped!
Key updates include:
- Constant-time SafeGCD scalar inverse
- Quicker constant-time ECDSA signing
- Stricter BIP-340 parsing
- Improved audit infrastructure.
You’re welcome! Glad I could help you achieve that 13x speedup.
Latest on UltrafastSecp256k1 v3.3:
- Implemented GPU CABI across all languages
- Added Ethereum ZK layer
- 17-67x speedup for batch ops
- OpenCL optimizations
- Security updates and bug fixes.
ben.matrixNewbie
Posts: 3523 · Reputation: 35
#20Mar 26, 2019, 05:48 AM
Update on the Continuous Adversarial Audit Standard:
Instead of a costly third-party audit, I’ve set up a continuous system that runs on every commit with tons of assertions and security tests.
Related topics
- Issues with ripemd160 on Ubuntu 22 9
- New Bitcoin Improvement Proposal with $100 Reward 9
- Clipboard Vulnerabilities in Cryptocurrency Transactions 8
- Understanding the Differences Between Traditional and Simplified Chinese Mnemonics 6
- Running Bitcoin Core on a Laptop with Limited Storage 20
- Exploring Blockstream's Satellite Tech and Its Potential 22