Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k-nuth/secp256k1
Optimized C library for EC operations on curve secp256k1
https://github.com/k-nuth/secp256k1
Last synced: 2 days ago
JSON representation
Optimized C library for EC operations on curve secp256k1
- Host: GitHub
- URL: https://github.com/k-nuth/secp256k1
- Owner: k-nuth
- Created: 2020-01-28T19:23:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-02T10:37:23.000Z (about 1 year ago)
- Last Synced: 2023-11-02T11:29:54.729Z (about 1 year ago)
- Language: C
- Homepage:
- Size: 2.39 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# secp256k1 ![Github Releases][badge.release] ![Build status][badge.GhA] ![Telegram][badge.telegram] ![Slack][badge.slack]
> Optimized C library for EC operations on curve secp256k1.
Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.
This library is intended to be the highest quality publicly available library for cryptography on the secp256k1 curve. However, the primary focus of its development has been for usage in the Bitcoin system and usage unlike Bitcoin's may be less well tested, verified, or suffer from a less well thought out interface. Correct usage requires some care and consideration that the library is fit for your application's purpose.
Features:
* secp256k1 ECDSA signing/verification and key generation.
* Additive and multiplicative tweaking of secret/public keys.
* Serialization/parsing of secret keys, public keys, signatures.
* Constant time, constant memory access signing and public key generation.
* Derandomized ECDSA (via RFC6979 or with a caller provided function.)
* Very efficient implementation.
* Suitable for embedded systems.
* Optional module for public key recovery.
* Optional module for ECDH key exchange (experimental).Experimental features have not received enough scrutiny to satisfy the standard of quality of this library but are made available for testing and review by the community. The APIs of these features should not be considered stable.
Implementation details
----------------------* General
* No runtime heap allocation.
* Extensive testing infrastructure.
* Structured to facilitate review and analysis.
* Intended to be portable to any system with a C89 compiler and uint64_t support.
* No use of floating types.
* Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.")
* Field operations
* Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1).
* Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys).
* Using 10 26-bit limbs (including hand-optimized assembly for 32-bit ARM, by Wladimir J. van der Laan).
* Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman).
* Scalar operations
* Optimized implementation without data-dependent branches of arithmetic modulo the curve's order.
* Using 4 64-bit limbs (relying on __int128 support in the compiler).
* Using 8 32-bit limbs.
* Group operations
* Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7).
* Use addition between points in Jacobian and affine coordinates where possible.
* Use a unified addition/doubling formula where necessary to avoid data-dependent branches.
* Point/x comparison without a field inversion by comparison in the Jacobian coordinate space.
* Point multiplication for verification (a*P + b*G).
* Use wNAF notation for point multiplicands.
* Use a much larger window for multiples of G, using precomputed multiples.
* Use Shamir's trick to do the multiplication with the public key and the generator simultaneously.
* Optionally (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones.
* Point multiplication for signing
* Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions.
* Intended to be completely free of timing sidechannels for secret-key operations (on reasonable hardware/toolchains)
* Access the table with branch-free conditional moves so memory access is uniform.
* No data-dependent branches
* Optional runtime blinding which attempts to frustrate differential power analysis.
* The precomputed tables add and eventually subtract points for which no known scalar (secret key) is known, preventing even an attacker with control over the secret key used to control the data internally.Getting started
---------------Installing the library is as simple as:
1. Install and configure the Knuth build helper:
```
$ pip install kthbuild --user --upgrade$ conan config install https://github.com/k-nuth/ci-utils/raw/master/conan/config2023.zip
```2. Install the appropriate library:
```
$ conan install --requires=secp256k1/0.19.0 --update
```For more more detailed instructions, please refer to our [documentation](https://kth.cash/docs/).
## About this library
This library can be used stand-alone, but it is probably convenient for you to use one of our main projects, [look over here](https://github.com/k-nuth/kth/).
## Issues
Each of our modules has its own Github repository, but in case you want to create an issue, please do so in our [main repository](https://github.com/k-nuth/kth/issues).
[badge.Travis]: https://travis-ci.org/k-nuth/secp256k1.svg?branch=master
[badge.Appveyor]: https://ci.appveyor.com/api/projects/status/github/k-nuth/secp256k1?svg=true&branch=master
[badge.Cirrus]: https://api.cirrus-ci.com/github/k-nuth/secp256k1.svg?branch=master
[badge.GhA]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fk-nuth%2Fsecp256k1%2Fbadge&style=for-the-badge[badge.version]: https://badge.fury.io/gh/k-nuth%2Fsecp256k1.svg
[badge.release]: https://img.shields.io/github/v/release/k-nuth/secp256k1?display_name=tag&style=for-the-badge&color=00599C&logo=c
[badge.cpp]: https://img.shields.io/badge/C++-23-blue.svg?logo=c%2B%2B&style=for-the-badge
[badge.telegram]: https://img.shields.io/badge/telegram-badge-blue.svg?logo=telegram&style=for-the-badge
[badge.slack]: https://img.shields.io/badge/slack-badge-orange.svg?logo=slack&style=for-the-badge