Crate scalarff

Source
Expand description

A minimal, opinionated, library for working with scalar finite fields.

Curated scalar finite field implementations from the best cryptography libraries. Provides a FieldElement trait for working with residues, and a to_biguint method for arbitrary precision operations on the real representations of field elements.

This library makes no guarantees about the timing of underlying field operations. This library should be considered vulnerable to timing attacks.

By default this library does not include any field implementations. Manually enable support for fields by enabling the corresponding feature below:

  • alt_bn128 - (aka Bn254)
  • curve25519
  • oxfoi - (aka goldilocks)

Example usage:

[dependencies]
scalarff = { version = "0.7.0", features = ["curve25519", "oxfoi"] }
use scalarff::FieldElement; // Bring the trait in scope
// Import 1 or more concrete instances
use scalarff::Curve25519FieldElement;
use scalarff::OxfoiFieldElement;

Modules§

matrix
A vector/matrix structure for doing arithmetic on sets of FieldElement. Matrices can be 1 dimensional for representing vectors.
timing
A simple module for timing functions and printing information.

Macros§

scalar_ring
The provided modulus should be a number < 2^64. This function creates a commutative ring with the provided modulus. This ring may be considered a field if the modulus is prime. Expects FieldElement to be in scope

Structs§

BigUint
A big unsigned integer type.

Traits§

FieldElement
A generic representation of a scalar finite field element. For use in internal module logic. Supports field operations using builtin operators (*-+/) and other convenience traits. Handles serialization and deserialization to a reasonable string representation.