Crate p256k1

source ·
Expand description

p256k1

ci crates.io

Rust wrappers around libsecp256k1 to expose unwrapped points and scalars with multi-exponentiation

p256k1 is a library providing group operations on secp256k1, a prime order Weierstrass curve.

p256k1 provides access to curve points in Jacobian coordinates, which allows for very fast operations. Standard math operators are implemented to allow writing code which closely resembles the underlying math. The BitXor operator is used for scalar exponentiation, using a fast square and multiply algorithm; this provides a very natural and intuitive API. Fast multi-exponentiation is provided using the standard Pippenger algorithm.

Use

To import p256k1, add the following to the dependencies section of your project’s Cargo.toml:

p256k1 = "3"

Dependencies

Stable rust with a working cargo. Also need llvm to build secp256k1 and link the wrappers.

Ubuntu

$ apt install llvm

MacOS with brew

After installing llvm, be sure to follow the instructions on updating .zshrc so llvm can be used by the build system.

$ brew install llvm

Modules

secp256k1 context operations
ECDSA operations
Point operations on the secp256k1 curve
Scalar arithmetic modulo the group order