Skip to content

Commit

Permalink
Add support for 448-bit integers and fields. (#261)
Browse files Browse the repository at this point in the history
These are needed for the Pluto and Eris curves (https://github.com/daira/pluto-eris).

Signed-off-by: Daira Hopwood <daira@jacaranda.org>

Co-authored-by: Weikeng Chen <w.k@berkeley.edu>
  • Loading branch information
daira and weikengchen authored Apr 16, 2021
1 parent e504bda commit 8b8ba22
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions ff/src/biginteger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bigint_impl!(BigInteger128, 2);
bigint_impl!(BigInteger256, 4);
bigint_impl!(BigInteger320, 5);
bigint_impl!(BigInteger384, 6);
bigint_impl!(BigInteger448, 7);
bigint_impl!(BigInteger768, 12);
bigint_impl!(BigInteger832, 13);

Expand Down
6 changes: 6 additions & 0 deletions ff/src/biginteger/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ fn test_biginteger384() {
test_biginteger(B::new([0u64; 6]));
}

#[test]
fn test_biginteger448() {
use crate::biginteger::BigInteger448 as B;
test_biginteger(B::new([0u64; 7]));
}

#[test]
fn test_biginteger768() {
use crate::biginteger::BigInteger768 as B;
Expand Down
4 changes: 3 additions & 1 deletion ff/src/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,15 @@ impl<Slice: AsRef<[u64]>> Iterator for BitIteratorLE<Slice> {
}

use crate::biginteger::{
BigInteger256, BigInteger320, BigInteger384, BigInteger64, BigInteger768, BigInteger832,
BigInteger256, BigInteger320, BigInteger384, BigInteger448, BigInteger64, BigInteger768,
BigInteger832,
};

impl_field_bigint_conv!(Fp64, BigInteger64, Fp64Parameters);
impl_field_bigint_conv!(Fp256, BigInteger256, Fp256Parameters);
impl_field_bigint_conv!(Fp320, BigInteger320, Fp320Parameters);
impl_field_bigint_conv!(Fp384, BigInteger384, Fp384Parameters);
impl_field_bigint_conv!(Fp448, BigInteger448, Fp448Parameters);
impl_field_bigint_conv!(Fp768, BigInteger768, Fp768Parameters);
impl_field_bigint_conv!(Fp832, BigInteger832, Fp832Parameters);

Expand Down
3 changes: 2 additions & 1 deletion ff/src/fields/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use num_traits::{One, Zero};
use crate::{
biginteger::{
arithmetic as fa, BigInteger as _BigInteger, BigInteger256, BigInteger320, BigInteger384,
BigInteger64, BigInteger768, BigInteger832,
BigInteger448, BigInteger64, BigInteger768, BigInteger832,
},
bytes::{FromBytes, ToBytes},
fields::{FftField, Field, FpParameters, LegendreSymbol, PrimeField, SquareRootField},
Expand All @@ -22,6 +22,7 @@ impl_Fp!(Fp64, Fp64Parameters, BigInteger64, BigInteger64, 1);
impl_Fp!(Fp256, Fp256Parameters, BigInteger256, BigInteger256, 4);
impl_Fp!(Fp320, Fp320Parameters, BigInteger320, BigInteger320, 5);
impl_Fp!(Fp384, Fp384Parameters, BigInteger384, BigInteger384, 6);
impl_Fp!(Fp448, Fp448Parameters, BigInteger448, BigInteger448, 7);
impl_Fp!(Fp768, Fp768Parameters, BigInteger768, BigInteger768, 12);
impl_Fp!(Fp832, Fp832Parameters, BigInteger832, BigInteger832, 13);

Expand Down

0 comments on commit 8b8ba22

Please sign in to comment.