#derive #num #macro #ff

macro ff-derive-num

Procedural macro library to add the Num trait to Field implementations for ff

3 releases

0.1.2 Jun 12, 2021
0.1.1 Jun 12, 2021
0.1.0 Jun 12, 2021

#816 in Rust patterns

MIT/Apache

7KB
112 lines

ff-derive-num

This crate provides a derive macro for num-traits::Num and associated traits for ff::Field implementations derived with the ff-derive crate.

Example

use ff::PrimeField;         // ff should be used with the "derive" feature!
use ff_derive_num::Num;

#[derive(PrimeField,Num)]
#[PrimeFieldModulus = "70386805592835581672624750593"]
#[PrimeFieldGenerator = "17"]
#[PrimeFieldReprEndianness = "little"]
pub struct Ft([u64; 2]);

Copyright 2021 Riad S. Wahby

You may choose either the Apache-2.0 license or the MIT license.

Unless you explicitly state otherwise, any contribution you submit will also be dual-licensed.


lib.rs:

Derive ::num_traits::Num and associated traits for ::ff::Field types derived using ::ff_derive

example

use ff::PrimeField;         // ff should be used with the "derive" feature!
use ff_derive_num::Num;

#[derive(PrimeField,Num)]
#[PrimeFieldModulus = "70386805592835581672624750593"]
#[PrimeFieldGenerator = "17"]
#[PrimeFieldReprEndianness = "little"]
pub struct Ft([u64; 2]);

Dependencies

~0.4–0.8MB
~20K SLoC

,`