Skip to content

Commit

Permalink
fix: cleanup formatting and interlinking in docs presentation a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlcibiades committed Sep 2, 2024
1 parent 13b81e3 commit 6aa1d1e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/fields/fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ macro_rules! define_finite_prime_field {
/// Type alias for constant-time arithmetic on Montgomery form integers modulo p
type $output = crypto_bigint::modular::ConstMontyForm<$mod_struct, { $mod_struct::LIMBS }>;

/// Represents an element of the finite prime field
/// Represents an element in the base field 𝔽ₚ or the r-torsion subgroup 𝔽ᵣ.
///
/// This is the actual struct that serves as our finite field implementation, containing
/// the modulus of the field, as well as the output type that contains the internal
Expand Down
4 changes: 2 additions & 2 deletions src/fields/fp12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const FROBENIUS_COEFF_FP12_C1: &[Fp2; 12] = &[
]),
];

/// Represents an element of the 𝔽ₚ¹² field.
/// Represents an element the dodecic (𝔽ₚ¹²) extension of the base field (𝔽ₚ)
///
/// Elements are represented as a₀ + a₁w, where a₀ and a₁ are elements of 𝔽ₚ⁶,
/// and w is the solution to w² = v in 𝔽ₚ¹².
Expand Down Expand Up @@ -224,7 +224,7 @@ impl<'a, 'b> Mul<&'b Fp12> for &'a Fp12 {
/// The product of the two 𝔽ₚ¹² elements
///
/// # References
/// * Algorithm 20 from https://eprint.iacr.org/2010/354.pdf
/// * Algorithm 20 from <https://eprint.iacr.org/2010/354.pdf>
#[inline]
fn mul(self, other: &'b Fp12) -> Self::Output {
let t0 = self.0[0] * other.0[0];
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fp2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const FP2_TWIST_CURVE_CONSTANT: Fp2 = Fp2::new(&[
])),
]);

/// Type alias for the quadratic extension of the base field
/// Represents an element in the quadratic extension (𝔽ₚ²) of the base field (𝔽ₚ).
pub type Fp2 = FieldExtension<2, 2, Fp>;

// there are some specific things that must be defined as
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fp6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const FROBENIUS_COEFF_FP6_C2: &[Fp2; 6] = &[
]),
];

/// Type alias for the sextic (𝔽ₚ⁶) extension of the base field (𝔽ₚ)
/// Represents an element the sextic (𝔽ₚ⁶) extension of the base field (𝔽ₚ)
pub type Fp6 = FieldExtension<6, 3, Fp2>;

impl Fp6 {
Expand Down
26 changes: 20 additions & 6 deletions src/groups/g2.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Implementation of the 𝔾₂ group for BN254 elliptic curve.
//!
//! This module defines 𝔾₂ = (r)E(𝔽ₚ²), where E is the BN254 elliptic curve over the quadratic
//! extension field 𝔽ₚ². Unlike 𝔾₁, the prime order subgroup is not the entire curve, which
//! extension field 𝔽ₚ². Unlike [`crate::groups::g1::G1Affine`], the prime order subgroup is not the entire curve, which
//! introduces additional security considerations and complexity. This introduces many security
//! considerations in regard to generating points on the correct subgroup for instance.
//!
//! This is the source of many headaches.
//!
//! There is an unfortunate combination of factors here to consider regarding the representation of
//! group elements. Because, as mentioned in `group.rs`, of the fact that the point at infinity
//! group elements. Because, as mentioned in [`crate::groups::group`], of the fact that the point at infinity
//! has no unique representation in affine coordinates, all arithmetic must be performed in
//! projective coordinates. However, there are many formulae that we will use in the subgroup
//! checks that require explicit expressions in affine coordinates. Therefore, all arithmetic
Expand Down Expand Up @@ -151,7 +151,21 @@ impl GroupTrait<2, 2, Fp2> for G2Affine {
Self::new_unchecked([x_endo, y_endo]).expect("Endomorphism failed")
}

/// Generates a random point in the r-torsion subgroup of 𝔾₂ group.
/// Generates a random point in the r-torsion subgroup of 𝔾₂.
///
/// This function first generates a random point on the twist curve E'(𝔽ₚ²),
/// then applies cofactor clearing to ensure the result is in the r-torsion subgroup.
/// It is then passed through the [`Self::new`] function to ensure it passes the curve and
/// subgroup checks.
///
/// # Examples
///
/// ```
/// use sylow::*;
/// use crypto_bigint::rand_core::OsRng;
/// let mut rng = OsRng;
/// let random_point = G2Projective::rand(&mut rng);
/// ```
fn rand<R: CryptoRngCore>(rng: &mut R) -> Self {
Self::from(G2Projective::rand(rng))
}
Expand Down Expand Up @@ -256,7 +270,7 @@ impl G2Affine {
///
/// # Arguments
///
/// * `v` - An array of two Fp2 elements representing the x and y coordinates of the point
/// * `v` - An array of two [`Fp2`] elements representing the x and y coordinates of the point
///
/// # Returns
///
Expand Down Expand Up @@ -331,7 +345,7 @@ impl G2Affine {
///
/// * `CtOption<G2Projective>` - A point on the curve or the point at infinity, if the evaluation is valid
///
/// Note: Returns a [`G2Projective`], since this is the version of the elements on which
/// Note: Returns a [`crate::groups::g2::G2Projective`], since this is the version of the elements on which
/// arithmetic can be performed.
/// Thus, we define this method though on the affine representation
/// which requires 64 fewer bytes to instantiate for the same point.
Expand Down Expand Up @@ -426,7 +440,7 @@ impl G2Projective {
///
/// # Arguments
///
/// * `v` - An array of three Fp2 elements representing the x, y, and z coordinates of the point
/// * `v` - An array of three [`Fp2`] elements representing the x, y, and z coordinates of the point
///
/// # Returns
///
Expand Down

0 comments on commit 6aa1d1e

Please sign in to comment.