MCPcopy Create free account
hub / github.com/BitVM/BitVM / hinted_mul_keep_element

Method hinted_mul_keep_element

bitvm/src/bn254/fq.rs:157–187  ·  view source on GitHub ↗
(
        mut a_depth: u32,
        mut a: ark_bn254::Fq,
        mut b_depth: u32,
        mut b: ark_bn254::Fq,
    )

Source from the content-addressed store, hash-verified

155 }
156
157 pub fn hinted_mul_keep_element(
158 mut a_depth: u32,
159 mut a: ark_bn254::Fq,
160 mut b_depth: u32,
161 mut b: ark_bn254::Fq,
162 ) -> (Script, Vec<Hint>) {
163 assert_ne!(a_depth, b_depth);
164 if a_depth > b_depth {
165 (a_depth, b_depth) = (b_depth, a_depth);
166 (a, b) = (b, a);
167 }
168
169 let mut hints = Vec::new();
170 let x = BigInt::from_str(&a.to_string()).unwrap();
171 let y = BigInt::from_str(&b.to_string()).unwrap();
172 let modulus = &Fq::modulus_as_bigint();
173 let q = (x * y) / modulus;
174
175 let script = script! {
176 for _ in 0..Self::N_LIMBS {
177 OP_DEPTH OP_1SUB OP_ROLL // hints
178 }
179 // { Fq::push(ark_bn254::Fq::from_str(&q.to_string()).unwrap()) }
180 { Fq::copy(a_depth + 1) }
181 { Fq::copy(b_depth + 2) }
182 { Fq::tmul() }
183 };
184 hints.push(Hint::BigIntegerTmulLC1(q));
185
186 (script, hints)
187 }
188
189 #[allow(clippy::too_many_arguments)]
190 pub fn hinted_mul_lc2(

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected