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

Method hinted_mul_lc4

bitvm/src/bn254/fq.rs:273–336  ·  view source on GitHub ↗
(
        a_depth: u32,
        a: ark_bn254::Fq,
        b_depth: u32,
        b: ark_bn254::Fq,
        c_depth: u32,
        c: ark_bn254::Fq,
        d_depth: u32,
        d: ark_bn254::Fq,

     

Source from the content-addressed store, hash-verified

271
272 #[allow(clippy::too_many_arguments)]
273 pub fn hinted_mul_lc4(
274 a_depth: u32,
275 a: ark_bn254::Fq,
276 b_depth: u32,
277 b: ark_bn254::Fq,
278 c_depth: u32,
279 c: ark_bn254::Fq,
280 d_depth: u32,
281 d: ark_bn254::Fq,
282
283 e_depth: u32,
284 e: ark_bn254::Fq,
285 f_depth: u32,
286 f: ark_bn254::Fq,
287 g_depth: u32,
288 g: ark_bn254::Fq,
289 h_depth: u32,
290 h: ark_bn254::Fq,
291 ) -> (Script, Vec<Hint>) {
292 assert!(
293 a_depth > b_depth
294 && b_depth > c_depth
295 && c_depth > d_depth
296 && d_depth > e_depth
297 && e_depth > f_depth
298 && f_depth > g_depth
299 && g_depth > h_depth
300 );
301
302 let mut hints = Vec::new();
303
304 let modulus = &Fq::modulus_as_bigint();
305
306 let x1 = BigInt::from_str(&a.to_string()).unwrap();
307 let y1 = BigInt::from_str(&b.to_string()).unwrap();
308 let z1 = BigInt::from_str(&c.to_string()).unwrap();
309 let w1 = BigInt::from_str(&d.to_string()).unwrap();
310
311 let x2 = BigInt::from_str(&e.to_string()).unwrap();
312 let y2 = BigInt::from_str(&f.to_string()).unwrap();
313 let z2 = BigInt::from_str(&g.to_string()).unwrap();
314 let w2 = BigInt::from_str(&h.to_string()).unwrap();
315
316 let q = (x1 * x2 + y1 * y2 + z1 * z2 + w1 * w2) / modulus;
317
318 let script = script! {
319 for _ in 0..Self::N_LIMBS {
320 OP_DEPTH OP_1SUB OP_ROLL // hints
321 }
322 // { fq_push(ark_bn254::Fq::from_str(&q.to_string()).unwrap()) }
323 { Fq::roll(a_depth + 1) }
324 { Fq::roll(b_depth + 2) }
325 { Fq::roll(c_depth + 3) }
326 { Fq::roll(d_depth + 4) }
327 { Fq::roll(e_depth + 5) }
328 { Fq::roll(f_depth + 6) }
329 { Fq::roll(g_depth + 7) }
330 { Fq::roll(h_depth + 8) }

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected