Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7b49928
placeholder for SmallFp
z-tech Sep 4, 2025
daa99f7
migrate smallfp implementation from blendy
benbencik Sep 24, 2025
0fadbb9
add tests
benbencik Sep 24, 2025
3d6636e
add benchmarks
benbencik Sep 25, 2025
f7de469
add square root precomputation
benbencik Oct 2, 2025
4d835f4
split sampling method into cases
benbencik Oct 3, 2025
4ba1448
fix mul overflow issue
benbencik Oct 3, 2025
d1937cc
extend testing suite (some tests failing)
benbencik Oct 3, 2025
a1a3343
rewrite sampling function
benbencik Oct 3, 2025
9cc57f5
fix overflowing bug in multiplication
benbencik Oct 3, 2025
be2664d
fix the computation for bit size
benbencik Oct 3, 2025
e39da81
consider (de)serialization of small elements
benbencik Oct 4, 2025
3c7daf9
rewrite computation for two adic root of unity
benbencik Oct 4, 2025
8a907d8
use safe mul to avoid overflows in compile-time
benbencik Oct 4, 2025
ea4cce2
update the smallfp tests
benbencik Oct 4, 2025
db896d3
Merge branch 'smallfp-test' into small_fp
benbencik Oct 4, 2025
2945217
rewrite mul_assing to handle overflows correctly
benbencik Oct 5, 2025
582ac3d
move tests and benches to test-curves
benbencik Oct 8, 2025
b91c704
update doccomments
benbencik Oct 8, 2025
f2f3fb1
use the provided bench templates for fields
benbencik Oct 9, 2025
f8c81e8
Merge branch 'master' into small_fp
benbencik Oct 9, 2025
176fc97
add info about small fields to readme
benbencik Oct 9, 2025
0cad96a
add pending PR 1044
benbencik Oct 9, 2025
742bb39
fix markdown linter error
benbencik Oct 9, 2025
4ccddce
add mont multiplication fastpath
benbencik Oct 10, 2025
42d99e9
clean unused type
benbencik Oct 12, 2025
6976823
specify mont mul impl at compile time
benbencik Oct 12, 2025
7a7f18b
add inlinging for arithmetic ops
benbencik Oct 12, 2025
f59fa7d
replace modulo operation in addition
benbencik Oct 12, 2025
676a7c3
Merge branch 'master' into small_fp
z-tech Oct 13, 2025
d663208
remove branching from mont multiplicaiton
benbencik Oct 13, 2025
2a6e5e3
Merge branch 'master' into small_fp
z-tech Oct 14, 2025
8acdef2
update utils helper functions
benbencik Oct 14, 2025
391f0ba
specify supported moduli
benbencik Oct 14, 2025
234bd8f
reduce duplicity in tests
benbencik Oct 15, 2025
ae8cf5c
delete smallfp tests and trait
benbencik Oct 15, 2025
1055fe1
delete smallfp in ff
benbencik Oct 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- (`ark-poly`) Add fast polynomial division
- (`ark-ec`) Improve GLV scalar multiplication performance by skipping leading zeroes.
- (`ark-poly`) Make `SparsePolynomial.coeffs` field public
- [\#1044](https://github.com/arkworks-rs/algebra/pull/1044) Add implementation for small field with native integer types

### Breaking changes

Expand Down
29 changes: 29 additions & 0 deletions ff-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use syn::{Expr, ExprLit, Item, ItemFn, Lit, Meta};

mod montgomery;
mod small_fp;

Check failure on line 15 in ff-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check no_std

file not found for module `small_fp`

Check failure on line 15 in ff-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

file not found for module `small_fp`

Check failure on line 15 in ff-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test assembly

file not found for module `small_fp`
mod unroll;

pub(crate) mod utils;
Expand Down Expand Up @@ -74,6 +75,34 @@
.into()
}

/// Derive the `SmallFpConfig` trait for small prime fields.
///
/// The attributes available to this macro are:
/// * `modulus`: Specify the prime modulus underlying this prime field.
/// * `generator`: Specify the generator of the multiplicative subgroup.
/// * `backend`: Specify either "standard" or "montgomery" backend.
#[proc_macro_derive(SmallFpConfig, attributes(modulus, generator, backend))]
pub fn small_fp_config(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(input).unwrap();

let modulus: u128 = fetch_attr("modulus", &ast.attrs)
.expect("Please supply a modulus attribute")
.parse()
.expect("Modulus should be a number");

let generator: u128 = fetch_attr("generator", &ast.attrs)
.expect("Please supply a generator attribute")
.parse()
.expect("Generator should be a number");

let backend: String = fetch_attr("backend", &ast.attrs)
.expect("Please supply a backend attribute")
.parse()
.expect("Backend should be a string");

small_fp::small_fp_config_helper(modulus, generator, backend, ast.ident).into()
}

const ARG_MSG: &str = "Failed to parse unroll threshold; must be a positive integer";

/// Attribute used to unroll for loops found inside a function block.
Expand Down
2 changes: 1 addition & 1 deletion ff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ hex.workspace = true
default = []
std = [ "ark-std/std", "ark-serialize/std" ]
parallel = [ "std", "rayon", "ark-std/parallel", "ark-serialize/parallel" ]
asm = []
asm = []
Loading