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Β§

  • Represents an element in the base field π”½β‚š or the r-torsion subgroup 𝔽ᡣ.
  • Represents an element in the base field π”½β‚š or the r-torsion subgroup 𝔽ᡣ.
  • Precomputed data for efficient Miller loop calculations on 𝔾₂ points.
  • Represents an element of the target group π”Ύβ‚œ in the BN254 pairing.
  • Represents a pair of secret and public keys for BLS signatures
  • Represents the result of a Miller loop computation in pairing-based cryptography.
  • 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.
  • Implements the XOF (Expand Message XOF) function, which produces a uniformly random byte string using an extendable output function (XOF) H.

EnumsΒ§

  • Errors that can occur when working with group elements.

TraitsΒ§

  • Defines the message expansion and conversion to field element functions
  • Defines operations for field extensions in elliptic curve cryptography.
  • Defines the basic operations for elliptic curve group elements.

FunctionsΒ§

  • Performs a batched pairing calculation for multiple pairs of 𝔾₁ and 𝔾₂ points.
  • The driver code for the glued miller loop execution, see comments above.
  • Computes the optimal ate pairing for a pair of points on the BN254 curve.
  • Signs a message using the BLS signature scheme
  • Verifies a BLS signature

Type AliasesΒ§

  • Represents an element in the quadratic extension (π”½β‚šΒ²) of the base field (π”½β‚š).
  • Represents an element the sextic (π”½β‚šβΆ) extension of the base field (π”½β‚š)
  • Represents an element the dodecic (π”½β‚šΒΉΒ²) extension of the base field (π”½β‚š)
  • Affine representation of a point in the 𝔾₁ group
  • Projective representation of a point in the 𝔾₁ group
  • Affine representation of a point in the 𝔾₂ group on the quadratic extension field
  • Projective representation of a point on the 𝔾₂ group on the quadratic extension field