diff --git a/bench-templates/Cargo.toml b/bench-templates/Cargo.toml index 914692d7f..baadd2058 100644 --- a/bench-templates/Cargo.toml +++ b/bench-templates/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/algebra/" keywords = ["cryptography", "finite-fields", "elliptic-curves", "pairing"] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63" diff --git a/ec/Cargo.toml b/ec/Cargo.toml index 039d33fea..a3b89744b 100644 --- a/ec/Cargo.toml +++ b/ec/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-ec/" keywords = ["cryptography", "elliptic-curves", "pairing"] categories = ["cryptography"] include = ["Cargo.toml", "src", "doc", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63" diff --git a/ec/src/models/short_weierstrass/mod.rs b/ec/src/models/short_weierstrass/mod.rs index 03183a8ee..20bf7029c 100644 --- a/ec/src/models/short_weierstrass/mod.rs +++ b/ec/src/models/short_weierstrass/mod.rs @@ -65,7 +65,7 @@ pub trait SWCurveConfig: super::CurveConfig { /// Check if the provided curve point is in the prime-order subgroup. /// /// The default implementation multiplies `item` by the order `r` of the - /// prime-order subgroup, and checks if the result is one. + /// prime-order subgroup, and checks if the result is zero. /// Implementors can choose to override this default impl /// if the given curve has faster methods /// for performing this check (for example, via leveraging curve diff --git a/ec/src/models/short_weierstrass/serialization_flags.rs b/ec/src/models/short_weierstrass/serialization_flags.rs index 13eb1c8de..c2c9c0b41 100644 --- a/ec/src/models/short_weierstrass/serialization_flags.rs +++ b/ec/src/models/short_weierstrass/serialization_flags.rs @@ -5,11 +5,11 @@ use ark_serialize::Flags; /// The default flags (empty) should not change the binary representation. #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum SWFlags { - /// Represents a point with positive y-coordinate by setting the MSB to 1. + /// Represents a point with positive y-coordinate by setting all bits to 0. YIsPositive = 0, /// Represents the point at infinity by setting the setting the last-but-one bit to 1. PointAtInfinity = 1 << 6, - /// Represents a point with negative y-coordinate by setting all bits to 0. + /// Represents a point with negative y-coordinate by setting the MSB to 1. YIsNegative = 1 << 7, } diff --git a/ec/src/scalar_mul/mod.rs b/ec/src/scalar_mul/mod.rs index 1ae3a1e99..295597576 100644 --- a/ec/src/scalar_mul/mod.rs +++ b/ec/src/scalar_mul/mod.rs @@ -4,8 +4,8 @@ pub mod wnaf; pub mod fixed_base; pub mod variable_base; -use crate::PrimeGroup; use crate::short_weierstrass::{Affine, Projective, SWCurveConfig}; +use crate::PrimeGroup; use ark_ff::{AdditiveGroup, Zero}; use ark_std::{ ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign}, diff --git a/ff-asm/Cargo.toml b/ff-asm/Cargo.toml index 4e2680073..5ca8c4474 100644 --- a/ff-asm/Cargo.toml +++ b/ff-asm/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-ff-asm/" keywords = ["cryptography", "finite-fields", "assembly" ] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.60" diff --git a/ff-macros/Cargo.toml b/ff-macros/Cargo.toml index 2bd7dd464..7aef85931 100644 --- a/ff-macros/Cargo.toml +++ b/ff-macros/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-ff-asm/" keywords = ["cryptography", "finite-fields", "assembly" ] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.60" diff --git a/ff/Cargo.toml b/ff/Cargo.toml index c4c806975..3336c15f4 100644 --- a/ff/Cargo.toml +++ b/ff/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-ff/" keywords = ["cryptography", "finite-fields" ] categories = ["cryptography"] include = ["Cargo.toml", "build.rs", "src", "doc", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63" diff --git a/ff/src/fields/mod.rs b/ff/src/fields/mod.rs index ecb5005c4..d43cb1207 100644 --- a/ff/src/fields/mod.rs +++ b/ff/src/fields/mod.rs @@ -129,6 +129,11 @@ pub trait Field: + From + From + From + + From + + From + + From + + From + + From + From + Product { @@ -404,6 +409,29 @@ mod no_std_tests { } } + #[test] + pub fn test_from_ints() { + let felt2 = Fr::one() + Fr::one(); + let felt16 = felt2 * felt2 * felt2 * felt2; + + assert_eq!(Fr::from(1u8), Fr::one()); + assert_eq!(Fr::from(1u16), Fr::one()); + assert_eq!(Fr::from(1u32), Fr::one()); + assert_eq!(Fr::from(1u64), Fr::one()); + assert_eq!(Fr::from(1u128), Fr::one()); + assert_eq!(Fr::from(-1i8), -Fr::one()); + assert_eq!(Fr::from(-1i64), -Fr::one()); + + assert_eq!(Fr::from(0), Fr::zero()); + + assert_eq!(Fr::from(-16i32), -felt16); + assert_eq!(Fr::from(16u32), felt16); + assert_eq!(Fr::from(16i64), felt16); + + assert_eq!(Fr::from(-2i128), -felt2); + assert_eq!(Fr::from(2u16), felt2); + } + #[test] fn test_from_into_biguint() { let mut rng = ark_std::test_rng(); diff --git a/poly/Cargo.toml b/poly/Cargo.toml index 111066840..8c740de55 100644 --- a/poly/Cargo.toml +++ b/poly/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-poly/" keywords = ["cryptography", "finite-fields", "fft", "polynomials"] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63" diff --git a/poly/src/domain/general.rs b/poly/src/domain/general.rs index b58aefd5e..a6ef06327 100644 --- a/poly/src/domain/general.rs +++ b/poly/src/domain/general.rs @@ -22,6 +22,29 @@ use ark_std::{ /// Defines a domain over which finite field (I)FFTs can be performed. /// Generally tries to build a radix-2 domain and falls back to a mixed-radix /// domain if the radix-2 multiplicative subgroup is too small. +/// +/// # Examples +/// +/// ``` +/// use ark_poly::{GeneralEvaluationDomain, EvaluationDomain}; +/// use ark_poly::{univariate::DensePolynomial, Polynomial, DenseUVPolynomial}; +/// use ark_ff::FftField; +/// +/// // The field we are using is FFT-friendly, with 2-adicity of 32. +/// // We can efficiently evaluate polynomials over this field on up to 2^32 points. +/// use ark_test_curves::bls12_381::Fr; +/// +/// let small_domain = GeneralEvaluationDomain::::new(4).unwrap(); +/// let evals = vec![Fr::from(1u8), Fr::from(2u8), Fr::from(3u8), Fr::from(4u8)]; +/// // From a vector of evaluations, we can recover the polynomial. +/// let coeffs = small_domain.ifft(&evals); +/// let poly = DensePolynomial::from_coefficients_vec(coeffs.clone()); +/// assert_eq!(poly.degree(), 3); +/// +/// // We could also evaluate this polynomial at a large number of points efficiently, e.g. for Reed-Solomon encoding. +/// let large_domain = GeneralEvaluationDomain::::new(1<<10).unwrap(); +/// let new_evals = large_domain.fft(&coeffs); +/// ``` #[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)] pub enum GeneralEvaluationDomain { /// Radix-2 domain diff --git a/serialize-derive/Cargo.toml b/serialize-derive/Cargo.toml index 50182e67e..7e7497332 100644 --- a/serialize-derive/Cargo.toml +++ b/serialize-derive/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/algebra/" keywords = ["cryptography", "finite-fields", "elliptic-curves", "serialization"] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.60" diff --git a/serialize/Cargo.toml b/serialize/Cargo.toml index 27f1bdff2..26f3912ab 100644 --- a/serialize/Cargo.toml +++ b/serialize/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-serialize/" keywords = ["cryptography", "serialization" ] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63" diff --git a/test-curves/Cargo.toml b/test-curves/Cargo.toml index 358fdc2ba..4d8448fd9 100644 --- a/test-curves/Cargo.toml +++ b/test-curves/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-test-curves/" keywords = ["cryptography", "serialization" ] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63" diff --git a/test-templates/Cargo.toml b/test-templates/Cargo.toml index ccd12fecd..fc5c52363 100644 --- a/test-templates/Cargo.toml +++ b/test-templates/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/ark-curve-tests/" keywords = ["cryptography", "finite-fields", "elliptic-curves" ] categories = ["cryptography"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.63"