Procedural macro for fixed-exponent variable-base modular exponentiation

Uses the addchain crate to obtain an addition chain for the exponent,
and then generates the corresponding constant-time square-and-multiply
algorithm.
This commit is contained in:
Jack Grigg
2019-12-19 22:10:10 -06:00
parent 2df2a2b2f2
commit 232fb4b7a3
4 changed files with 75 additions and 1 deletions

View File

@@ -10,6 +10,8 @@ use quote::quote;
use quote::TokenStreamExt;
use std::str::FromStr;
mod pow_fixed;
#[proc_macro_derive(PrimeField, attributes(PrimeFieldModulus, PrimeFieldGenerator))]
pub fn prime_field(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
// Parse the type definition