#secret-sharing #zero-knowledge-proofs #verifiable #big-integer #scheme #commitment #ecdh

sn_curv

Curv contains an extremely simple interface to onboard new elliptic curves. Use this library for general purpose elliptic curve cryptography

1 unstable release

0.10.1 Mar 19, 2024

#2233 in Cryptography

Download history 818/week @ 2024-08-10 1304/week @ 2024-08-17 1532/week @ 2024-08-24 1610/week @ 2024-08-31 1708/week @ 2024-09-07 2260/week @ 2024-09-14 2040/week @ 2024-09-21 2170/week @ 2024-09-28 1933/week @ 2024-10-05 2868/week @ 2024-10-12 3664/week @ 2024-10-19 2584/week @ 2024-10-26 2732/week @ 2024-11-02 2320/week @ 2024-11-09 1213/week @ 2024-11-16 1401/week @ 2024-11-23

7,847 downloads per month
Used in 10 crates (3 directly)

MIT license

375KB
8K SLoC

Curv

Curv contains an extremely simple interface to onboard new elliptic curves. Use this library for general purpose elliptic curve cryptography.

The library has a built in support for some useful operations/primitives such as verifiable secret sharing, commitment schemes, zero knowledge proofs, and simple two party protocols such as ECDH and coin flip. The library comes with serialize/deserialize support to be used in higher level code to implement networking.

Usage

To use curv crate, add the following to your Cargo.toml:

[dependencies]
sn_curv = "0.10.1"

The crate will be available under curv name, e.g.:

use curv::elliptic::curves::*;

Currently Supported Elliptic Curves

Curve low level library curve description
Secp256k1 rust-secp256k1 bitcoin wiki
P-256 RustCrypto NIST.FIPS.186.4
Ed25519 cryptoxide BDLSY11
Ristretto curve25519-dalek ristretto group
BLS12-381 bls12-381 BLS12-381 For The Rest Of Us

Security

The library was audited by Kudelski security on Feb19. The report can be found here. No critical issue were found and all issues found were fixed.

The code was reviewed independently by few other cryptographers. Special thanks goes to Claudio Orlandi from Aarhus University.

In general security of the library is strongly dependent on the security of the low level libraries used. We chose only libraries that are used as part of other big projects and went through heavy audit/review.

The library is not immune to side channel attacks but considerable effort was given to try and catch as many such attacks as possible (see audit report).

Build

Use cargo build to build everything including curve implementations, cryptoprimitives, BigInt, etc.

Big integer implementation

The library supports a couple of bigint implementations and can easily switch between them. You can choose any one which you prefer by specifying a feature:

  • rust-gmp-kzen, uses GMP bindings, requires GMP to be installed on a machine. Used by default.

  • num-bigint, Rust's pure implementation of big integer. In order to use it, put in Cargo.toml:

    [dependencies.sn_curv]
    version = "0.8"
    default-features = false
    features = ["num-bigint"]
    

    Warning: num-bigint support is experimental and should not be used in production. For this bigint implementation, we use prime numbers generator which is not considered secure.

Examples

The library includes some basic examples to get you going. To run them: cargo run --example EXAMPLE_NAME -- CURVE_NAME for example: cargo run --example proof_of_knowledge_of_dlog -- secp256k1

Docs

To build docs, use:

cargo doc
RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps --open

License

Curv is released under the terms of the MIT license. See LICENSE for more information.

Contributing

Please feel free to clone and modify this project. Pull requests are welcome.

Dependencies

~14MB
~207K SLoC