| 337 | |
| 338 | #[allow(clippy::too_many_arguments)] |
| 339 | pub fn hinted_mul_lc2_keep_elements( |
| 340 | a_depth: u32, |
| 341 | a: ark_bn254::Fq, |
| 342 | b_depth: u32, |
| 343 | b: ark_bn254::Fq, |
| 344 | c_depth: u32, |
| 345 | c: ark_bn254::Fq, |
| 346 | d_depth: u32, |
| 347 | d: ark_bn254::Fq, |
| 348 | ) -> (Script, Vec<Hint>) { |
| 349 | assert!(a_depth > b_depth && b_depth > c_depth && c_depth > d_depth); |
| 350 | |
| 351 | let mut hints = Vec::new(); |
| 352 | |
| 353 | let modulus = &Fq::modulus_as_bigint(); |
| 354 | |
| 355 | let x = BigInt::from_str(&a.to_string()).unwrap(); |
| 356 | let y = BigInt::from_str(&b.to_string()).unwrap(); |
| 357 | let z = BigInt::from_str(&c.to_string()).unwrap(); |
| 358 | let w = BigInt::from_str(&d.to_string()).unwrap(); |
| 359 | |
| 360 | let q = (x * z + y * w) / modulus; |
| 361 | |
| 362 | let script = script! { |
| 363 | for _ in 0..Self::N_LIMBS { |
| 364 | OP_DEPTH OP_1SUB OP_ROLL // hints |
| 365 | } |
| 366 | // { Fq::push(ark_bn254::Fq::from_str(&q.to_string()).unwrap()) } |
| 367 | { Fq::copy(a_depth + 1) } |
| 368 | { Fq::copy(b_depth + 2) } |
| 369 | { Fq::copy(c_depth + 3) } |
| 370 | { Fq::copy(d_depth + 4) } |
| 371 | { Fq::tmul_lc2() } |
| 372 | }; |
| 373 | hints.push(Hint::BigIntegerTmulLC2(q)); |
| 374 | |
| 375 | (script, hints) |
| 376 | } |
| 377 | |
| 378 | // Same as hinted_mul_lc2_keep_elements(), except retains operands (a, b, c, d) on stack |
| 379 | #[allow(clippy::too_many_arguments)] |