Expand description
Β§Sylow: Elliptic Curve Cryptography Suite for BN254
Sylow is a Rust library implementing elliptic curve cryptography for the BN254 (alt-bn128) curve. It provides efficient implementations of finite fields, elliptic curve groups, and pairing-based cryptography, suitable for applications in a blockchain environment, in zero-knowledge proving, and in other cryptographic systems.
Β§Quick Start
Add Sylow to your Cargo.toml
:
[dependencies]
sylow = "0.1.0"
Β§Key Features
- Finite field arithmetic (π½β, π½βΒ², π½ββΆ, π½βΒΉΒ²)
- Elliptic curve group operations (πΎβ, πΎβ, πΎβ)
- Highly optimized optimal ate pairing
- BLS signature scheme
- Hash-to-curve functionality
Β§Basic Usage
Hereβs an example of generating a key pair, signing a message, and verifying the signature:
use sylow::{KeyPair, sign, verify};
// Generate a new key pair
let key_pair = KeyPair::generate();
// Sign a message
let message = b"Hello, Sylow!";
let signature = sign(&key_pair.secret_key, message).expect("Signing failed");
// Verify the signature
let is_valid = verify(&key_pair.public_key, message, &signature).expect("Verification failed");
assert!(is_valid, "Signature verification failed");
Β§Core Components
Fp
,Fp2
,Fp6
,Fp12
: Finite field implementationsG1Projective
,G2Projective
: Elliptic curve group elementspairing()
: Bilinear pairing operationKeyPair
: BLS key pair generationsign
,verify
: BLS signature operations
Β§Performance and Security
Sylow uses optimized algorithms and constant-time implementations to ensure both efficiency and security. It follows best practices outlined in RFC 9380 for operations like hashing to curve points.
Β§Further Reading
For more detailed information, examples, and advanced usage, please refer to the full documentation and the GitHub repository.
StructsΒ§
- Fp
- Represents an element in the base field π½β or the r-torsion subgroup π½α΅£.
- Fr
- Represents an element in the base field π½β or the r-torsion subgroup π½α΅£.
- G2Pre
Computed - Precomputed data for efficient Miller loop calculations on πΎβ points.
- Gt
- Represents an element of the target group πΎβ in the BN254 pairing.
- KeyPair
- Represents a pair of secret and public keys for BLS signatures
- Miller
Loop Result - Represents the result of a Miller loop computation in pairing-based cryptography.
- XMDExpander
- Implements the XMD (Expand Message XOF) function, which produces a uniformly random byte string using a hash function that outputs a fixed-length of b bits.
- XOFExpander
- Implements the XOF (Expand Message XOF) function, which produces a uniformly random byte string using an extendable output function (XOF) H.
EnumsΒ§
- Group
Error - Errors that can occur when working with group elements.
TraitsΒ§
- Expander
- Defines the message expansion and conversion to field element functions
- Field
Extension Trait - Defines operations for field extensions in elliptic curve cryptography.
- Group
Trait - Defines the basic operations for elliptic curve group elements.
FunctionsΒ§
- glued_
miller_ loop - Performs a batched pairing calculation for multiple pairs of πΎβ and πΎβ points.
- glued_
pairing - The driver code for the glued miller loop execution, see comments above.
- pairing
- Computes the optimal ate pairing for a pair of points on the BN254 curve.
- sign
- Signs a message using the BLS signature scheme
- verify
- Verifies a BLS signature
Type AliasesΒ§
- Fp2
- Represents an element in the quadratic extension (π½βΒ²) of the base field (π½β).
- Fp6
- Represents an element the sextic (π½ββΆ) extension of the base field (π½β)
- Fp12
- Represents an element the dodecic (π½βΒΉΒ²) extension of the base field (π½β)
- G1Affine
- Affine representation of a point in the πΎβ group
- G1Projective
- Projective representation of a point in the πΎβ group
- G2Affine
- Affine representation of a point in the πΎβ group on the quadratic extension field
- G2Projective
- Projective representation of a point on the πΎβ group on the quadratic extension field