From 62e3a77c86eb817da6043d6e1126fe9a884d63c6 Mon Sep 17 00:00:00 2001 From: David Nevado Date: Mon, 23 Dec 2024 08:42:54 +0100 Subject: [PATCH] Fix broken docs (#185) * chore: fmt * fix: docs * chore: clippy --- benches/curve.rs | 4 +--- benches/hash_to_curve.rs | 3 +-- src/bn256/fq12.rs | 6 +++--- src/curve.rs | 1 + src/ff_ext/inverse.rs | 6 +++--- src/ff_ext/jacobi.rs | 6 +++--- src/pluto_eris/fp12.rs | 7 ++++--- src/pluto_eris/mod.rs | 6 +++--- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/benches/curve.rs b/benches/curve.rs index c954baa5..cb647651 100644 --- a/benches/curve.rs +++ b/benches/curve.rs @@ -8,12 +8,10 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; use ff::Field; use group::prime::PrimeCurveAffine; -use halo2curves::bn256::G1; +use halo2curves::{bn256::G1, CurveExt}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; -use halo2curves::CurveExt; - fn bench_curve_ops(c: &mut Criterion, name: &'static str) { { let mut rng = XorShiftRng::seed_from_u64(3141519u64); diff --git a/benches/hash_to_curve.rs b/benches/hash_to_curve.rs index 57f0a781..eda2ac78 100644 --- a/benches/hash_to_curve.rs +++ b/benches/hash_to_curve.rs @@ -8,8 +8,7 @@ use std::iter; use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; -use halo2curves::bn256::G1; -use halo2curves::CurveExt; +use halo2curves::{bn256::G1, CurveExt}; use rand::SeedableRng; use rand_core::RngCore; use rand_xorshift::XorShiftRng; diff --git a/src/bn256/fq12.rs b/src/bn256/fq12.rs index e14b6e93..3b515a84 100644 --- a/src/bn256/fq12.rs +++ b/src/bn256/fq12.rs @@ -4,9 +4,9 @@ use crate::ff_ext::{ ExtField, }; -/// -GAMMA is a quadratic non-residue in Fp6. Fp12 = Fp6[X]/(X^2 + GAMMA) -/// We introduce the variable w such that w^2 = -GAMMA -// GAMMA = - v +// -GAMMA is a quadratic non-residue in Fp6. Fp12 = Fp6[X] / (X^2 + GAMMA) +// We introduce the variable w such that w^2 = -GAMMA +// GAMMA = -v /// An element of Fq12, represented by c0 + c1 * w. pub type Fq12 = QuadExtField; diff --git a/src/curve.rs b/src/curve.rs index 1740f640..f4b1b8b2 100644 --- a/src/curve.rs +++ b/src/curve.rs @@ -42,6 +42,7 @@ pub trait CurveExt: /// distributed elements in the group, given domain prefix `domain_prefix`. /// /// This method is suitable for use as a random oracle. + #[allow(clippy::type_complexity)] fn hash_to_curve<'a>(domain_prefix: &'a str) -> Box Self + 'a>; /// Returns whether or not this element is on the curve; should diff --git a/src/ff_ext/inverse.rs b/src/ff_ext/inverse.rs index 116eaf24..95a5088a 100644 --- a/src/ff_ext/inverse.rs +++ b/src/ff_ext/inverse.rs @@ -244,9 +244,9 @@ impl Mul> for i64 { /// recommended: /// - D. Bernstein, B.-Y. Yang, "Fast constant-time gcd computation and modular /// inversion", -/// https://gcd.cr.yp.to/safegcd-20190413.pdf +/// /// - P. Wuille, "The safegcd implementation in libsecp256k1 explained", -/// https://github.com/bitcoin-core/secp256k1/blob/master/doc/safegcd_implementation.md +/// pub struct BYInverter { /// Modulus modulus: CInt<62, L>, @@ -395,7 +395,7 @@ impl BYInverter { /// multiplicative inverse modulo a power of two. For better /// understanding the implementation, the following paper is recommended: /// J. Hurchalla, "An Improved Integer Multiplicative Inverse (modulo 2^w)", - /// https://arxiv.org/pdf/2204.04342.pdf + /// const fn inv(value: u64) -> i64 { let x = value.wrapping_mul(3) ^ 2; let y = 1u64.wrapping_sub(x.wrapping_mul(value)); diff --git a/src/ff_ext/jacobi.rs b/src/ff_ext/jacobi.rs index 0f658565..113ee6f3 100644 --- a/src/ff_ext/jacobi.rs +++ b/src/ff_ext/jacobi.rs @@ -44,7 +44,7 @@ impl LInt { #[inline] fn sum(first: u64, second: u64, carry: bool) -> (u64, bool) { // The implementation is inspired with the "carrying_add" function from this - // source: https://github.com/rust-lang/rust/blob/master/library/core/src/num/uint_macros.rs + // source: let (second, carry) = second.overflowing_add(carry as u64); let (first, high) = first.overflowing_add(second); (first, carry || high) @@ -330,9 +330,9 @@ fn jacobinary(mut n: u64, mut d: u64, mut t: u64) -> i64 { /// differences have been commented; the aforesaid Pornin's method and the used /// ideas of M. Hamburg were given here: /// - T. Pornin, "Optimized Binary GCD for Modular Inversion", -/// https://eprint.iacr.org/2020/972.pdf +/// /// - M. Hamburg, "Computing the Jacobi symbol using Bernstein-Yang", -/// https://eprint.iacr.org/2021/1271.pdf +/// pub fn jacobi(n: &[u64], d: &[u64]) -> i64 { // Instead of the variable "j" taking the values from {-1, 1} and satisfying // at the end of the outer loop iteration the equation J = "j" * ("n" / |"d"|) diff --git a/src/pluto_eris/fp12.rs b/src/pluto_eris/fp12.rs index b792e31c..7b87f9aa 100644 --- a/src/pluto_eris/fp12.rs +++ b/src/pluto_eris/fp12.rs @@ -6,9 +6,10 @@ use crate::ff_ext::{ ExtField, }; -/// -GAMMA is a quadratic non-residue in Fp6. Fp12 = Fp6[X]/(X^2 + GAMMA) -/// We introduce the variable w such that w^2 = -GAMMA -/// GAMMA = - v +// -GAMMA is a quadratic non-residue in Fp6. Fp12 = Fp6[X]/(X^2 + GAMMA) +// We introduce the variable w such that w^2 = -GAMMA +// GAMMA = - v +/// An element of Fp12, represented by c0 + c1 * v. pub type Fp12 = QuadExtField; impl QuadExtFieldArith for Fp12 { diff --git a/src/pluto_eris/mod.rs b/src/pluto_eris/mod.rs index b5bd0c27..b0be4e85 100644 --- a/src/pluto_eris/mod.rs +++ b/src/pluto_eris/mod.rs @@ -3,9 +3,9 @@ //! Implementation of the Pluto / Eris half-pairing cycle of prime order //! elliptic curves. //! -//! Supporting evidence: https://github.com/daira/pluto-eris -//! Field constant derivation: https://github.com/davidnevadoc/ec-constants/tree/main/pluto_eris -//! Pairing constants derivation: https://github.com/John-Gong-Math/pluto_eris/blob/main/pluto_pairing.ipynb +//! Supporting evidence: +//! Field constant derivation: +//! Pairing constants derivation: mod curve; mod engine; mod fp;