From 1791197a4b9674ece0bf77f9e37d67b13f7fa2b4 Mon Sep 17 00:00:00 2001 From: sashass1315 Date: Tue, 7 Oct 2025 19:57:14 +0300 Subject: [PATCH] Implement cube root of unity for Grumpkin Fq in HonkCurve --- co-noir/co-builder/src/honk_curve.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/co-noir/co-builder/src/honk_curve.rs b/co-noir/co-builder/src/honk_curve.rs index c755ea0db..0d239bfa3 100644 --- a/co-noir/co-builder/src/honk_curve.rs +++ b/co-noir/co-builder/src/honk_curve.rs @@ -200,7 +200,18 @@ impl HonkCurve for short_weierstrass::Projective val } fn get_cube_root_of_unity() -> Self::BaseField { - todo!("cube root of unity for grumpkin::Fq") + // Compute λ = (-1 + sqrt(-3)) / 2 in the base field + let minus_three = -ark_grumpkin::Fq::from(3u64); + let sqrt_minus_three = minus_three + .sqrt() + .expect("sqrt(-3) must exist in grumpkin::Fq"); + let two_inv = ark_grumpkin::Fq::from(2u64).inverse().unwrap(); + let lambda = (-ark_grumpkin::Fq::one() + sqrt_minus_three) * two_inv; + + debug_assert!(lambda != ark_grumpkin::Fq::one()); + debug_assert_eq!(lambda.pow([3u64]), ark_grumpkin::Fq::one()); + + lambda } fn get_bb_infinity_default() -> Self::BaseField {