Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into support-for-more-ba…
Browse files Browse the repository at this point in the history
…ckends
  • Loading branch information
mmagician committed Mar 13, 2024
2 parents eca3815 + f980e76 commit 9d75d8b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion curves/bls12_377/scripts/bls12_isogeny_computer.sage
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def bls12_377_hash_to_G2(e2_p6S_iso, data):
# e26_order = Ell2_6.order()
# for i in primes(30):
# if e26_order % i == 0:
# print("order is divisable by ", i)
# print("order is divisible by ", i)

def find_non_square():
quad_non_res = 0x01ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d44300000008508bffffffffffc
Expand Down
4 changes: 2 additions & 2 deletions curves/bls12_381/src/curves/g2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const DOUBLE_P_POWER_ENDOMORPHISM_COEFF_0: Fq2 = Fq2::new(
Fq::ZERO
);

/// psi(P) is the untwist-Frobenius-twist endomorhism on E'(Fq2)
/// psi(P) is the untwist-Frobenius-twist endomorphism on E'(Fq2)
fn p_power_endomorphism(p: &Affine<Config>) -> Affine<Config> {
// The p-power endomorphism for G2 is defined as follows:
// 1. Note that G2 is defined on curve E': y^2 = x^3 + 4(u+1).
Expand Down Expand Up @@ -295,7 +295,7 @@ fn double_p_power_endomorphism(p: &Projective<Config>) -> Projective<Config> {
res
}

// Parametres from the [IETF draft v16, section E.3](https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-3-isogeny-map-for-bls12-381).
// Parameters from the [IETF draft v16, section E.3](https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-16.html#name-3-isogeny-map-for-bls12-381).
impl WBConfig for Config {
type IsogenousCurve = g2_swu_iso::SwuIsoConfig;

Expand Down
2 changes: 1 addition & 1 deletion ec/src/hashing/curve_maps/curve_map_parameter_helper.sage
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def find_z_sswu(F, A, B):
ctr += 1

# Finds the smallest z in term of non-zero bit
# in sage representation for consturcting
# in sage representation for constructing
# elligator2 map for a curve defined over field F.
# Argument:
# - F, a field object, e.g., F = GF(2^255 - 19)
Expand Down
2 changes: 1 addition & 1 deletion ec/src/hashing/curve_maps/elligator2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ mod test {
Elligator2Map::<TestElligator2MapToCurveConfig>::check_parameters().unwrap();

let mut map_range: Vec<Affine<TestElligator2MapToCurveConfig>> = vec![];
// We are mapping all elemnts of the field to the curve, verifying that
// We are mapping all elements of the field to the curve, verifying that
// map is not constant on that set.
for current_field_element in 0..101 {
map_range.push(
Expand Down
2 changes: 1 addition & 1 deletion ff/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This crate contains two types of traits:

The available field traits are:

- [`AdditiveGroup`](/ff/src/lib.rs) - Interface for additive groups that have a "scalar multiplication" operation with respect to the `Scalar` associated type. This applies to to prime-order fields, field extensions, and elliptic-curve groups used in cryptography.
- [`AdditiveGroup`](https://github.com/arkworks-rs/algebra/blob/master/ff/src/fields/mod.rs#L46) - Interface for additive groups that have a "scalar multiplication" operation with respect to the `Scalar` associated type. This applies to to prime-order fields, field extensions, and elliptic-curve groups used in cryptography.
- [`Field`](https://github.com/arkworks-rs/algebra/blob/master/ff/src/fields/mod.rs#L161) - Interface for a generic finite field.
- [`FftField`](https://github.com/arkworks-rs/algebra/blob/master/ff/src/fields/fft_friendly.rs#L2) - Exposes methods that allow for performing efficient FFTs on field elements.
- [`PrimeField`](https://github.com/arkworks-rs/algebra/blob/master/ff/src/fields/prime.rs#L27) - Field with a prime `p` number of elements, also referred to as `Fp`.
Expand Down
7 changes: 3 additions & 4 deletions ff/src/fields/models/fp/montgomery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ pub trait MontConfig<const N: usize>: 'static + Sync + Send + Sized {
}
r[N - 1] = carry1 + carry2;
}
(a.0).0 = r;
(a.0).0.copy_from_slice(&r);
}
a.subtract_modulus();
} else {
Expand Down Expand Up @@ -290,7 +290,7 @@ pub trait MontConfig<const N: usize>: 'static + Sync + Send + Sized {
let mut carry2 = 0;
for i in 0..N {
let k = r[i].wrapping_mul(Self::INV);
let mut carry = 0;
carry = 0;
fa::mac_discard(r[i], k, Self::MODULUS.0[0], &mut carry);
for j in 1..N {
r[j + i] = fa::mac_with_carry(r[j + i], k, Self::MODULUS.0[j], &mut carry);
Expand Down Expand Up @@ -508,12 +508,11 @@ pub trait MontConfig<const N: usize>: 'static + Sync + Send + Sized {
#[inline]
pub const fn can_use_no_carry_mul_optimization<T: MontConfig<N>, const N: usize>() -> bool {
// Checking the modulus at compile time
let top_bit_is_zero = T::MODULUS.0[N - 1] >> 63 == 0;
let mut all_remaining_bits_are_one = T::MODULUS.0[N - 1] == u64::MAX >> 1;
crate::const_for!((i in 1..N) {
all_remaining_bits_are_one &= T::MODULUS.0[N - i - 1] == u64::MAX;
});
top_bit_is_zero && !all_remaining_bits_are_one
modulus_has_spare_bit::<T, N>() && !all_remaining_bits_are_one
}

#[inline]
Expand Down

0 comments on commit 9d75d8b

Please sign in to comment.