Skip to main content

Crate elliptic_curve_tools

Crate elliptic_curve_tools 

Source
Expand description

Extra Rust Crypto elliptic-curve adaptors, functions, and macros

There are some methods that can be applied to many different elliptic curves fields and groups.

This crate provides multi-exponentiation functions and serde serialization for different types of scalars and groups, including fixed-size array, Vec, and Box<[_]> collections. These require the alloc or std feature.

Curves still on the group/ff 0.13 traits (curve25519-dalek, ed448-goldilocks, bls12-381 forks, …) can use these functions through the legacy feature and its legacy module.

To permit serializing a PrimeField

use elliptic_curve_tools::prime_field;
use elliptic_curve::PrimeField;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct PrimeFieldWrapper<F: PrimeField>( #[serde(with = "prime_field")] F);

To permit serializing a Group

use elliptic_curve_tools::group;
use elliptic_curve::{Group, group::GroupEncoding};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct GroupWrapper<G: Group + GroupEncoding>( #[serde(with = "group")] G);

Other collections can also be serialized like

  • Fixed sized arrays like [PrimeField; 32] or [Group + GroupEncoding; 32]

Modules§

groupalloc or std
Serialize and deserialize a group element.
group_arrayalloc or std
Serialize and deserialize a group element array.
group_boxed_slicealloc or std
Serialize and deserialize a group element boxed slice.
group_vecalloc or std
Serialize and deserialize a group element vector.
legacylegacy
Bridge for curves still on the group/ff 0.13 traits.
prime_fieldalloc or std
Serialize and deserialize a prime field element.
prime_field_arrayalloc or std
Serialize and deserialize a prime field element array.
prime_field_boxed_slicealloc or std
Serialize and deserialize a prime field element boxed slice.
prime_field_vecalloc or std
Serialize and deserialize a prime field element vector.

Structs§

InsufficientScratchalloc or std
Error returned by the in-place multiexp methods when a caller-supplied Scratch is too small for the requested number of pairs.
LengthMismatchalloc or std
Error returned when a Precomputed basis and the supplied scalars differ in length.
Precomputedalloc or std
A fixed basis of group elements with precomputed Straus tables.
Scratchalloc or std
Pre-allocated scratch space for the allocation-free multiexp methods (SumOfProducts::sum_of_products_inplace and SumOfProducts::sum_of_products_vartime_inplace).

Enums§

ScratchBufferalloc or std
Identifies which buffer of a Scratch was undersized.

Traits§

SumOfProducts
A trait for a group that can compute the sum of products of a slice of group elements and a slice of scalars. The length of the slices must be equal.