Crate sylow

Source
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

Β§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 𝔽ᡣ.
G2PreComputed
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
MillerLoopResult
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Β§

GroupError
Errors that can occur when working with group elements.

TraitsΒ§

Expander
Defines the message expansion and conversion to field element functions
FieldExtensionTrait
Defines operations for field extensions in elliptic curve cryptography.
GroupTrait
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