Skip to content

Commit

Permalink
Merge branch 'master' into new-group-infra
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush committed Jul 24, 2023
2 parents e903a97 + 13fd33e commit a8b872e
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bench-templates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion ec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion ec/src/models/short_weierstrass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ec/src/models/short_weierstrass/serialization_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion ec/src/scalar_mul/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion ff-asm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion ff-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion ff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
28 changes: 28 additions & 0 deletions ff/src/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ pub trait Field:
+ From<u32>
+ From<u16>
+ From<u8>
+ From<i128>
+ From<i64>
+ From<i32>
+ From<i16>
+ From<i8>
+ From<bool>
+ Product<Self>
{
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion poly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
23 changes: 23 additions & 0 deletions poly/src/domain/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Fr>::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::<Fr>::new(1<<10).unwrap();
/// let new_evals = large_domain.fft(&coeffs);
/// ```
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
pub enum GeneralEvaluationDomain<F: FftField> {
/// Radix-2 domain
Expand Down
2 changes: 1 addition & 1 deletion serialize-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion serialize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion test-curves/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion test-templates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a8b872e

Please sign in to comment.