| 188 | |
| 189 | #[allow(clippy::too_many_arguments)] |
| 190 | pub fn hinted_mul_lc2( |
| 191 | a_depth: u32, |
| 192 | a: ark_bn254::Fq, |
| 193 | b_depth: u32, |
| 194 | b: ark_bn254::Fq, |
| 195 | c_depth: u32, |
| 196 | c: ark_bn254::Fq, |
| 197 | d_depth: u32, |
| 198 | d: ark_bn254::Fq, |
| 199 | ) -> (Script, Vec<Hint>) { |
| 200 | assert!(a_depth > b_depth && b_depth > c_depth && c_depth > d_depth); |
| 201 | |
| 202 | let mut hints = Vec::new(); |
| 203 | |
| 204 | let modulus = &Fq::modulus_as_bigint(); |
| 205 | |
| 206 | let x = BigInt::from_str(&a.to_string()).unwrap(); |
| 207 | let y = BigInt::from_str(&b.to_string()).unwrap(); |
| 208 | let z = BigInt::from_str(&c.to_string()).unwrap(); |
| 209 | let w = BigInt::from_str(&d.to_string()).unwrap(); |
| 210 | |
| 211 | let q = (x * z + y * w) / modulus; |
| 212 | |
| 213 | let script = script! { |
| 214 | for _ in 0..Self::N_LIMBS { |
| 215 | OP_DEPTH OP_1SUB OP_ROLL // hints |
| 216 | } |
| 217 | // { Fq::push(ark_bn254::Fq::from_str(&q.to_string()).unwrap()) } |
| 218 | { Fq::roll(a_depth + 1) } |
| 219 | { Fq::roll(b_depth + 2) } |
| 220 | { Fq::roll(c_depth + 3) } |
| 221 | { Fq::roll(d_depth + 4) } |
| 222 | { Fq::tmul_lc2() } |
| 223 | }; |
| 224 | hints.push(Hint::BigIntegerTmulLC2(q)); |
| 225 | |
| 226 | (script, hints) |
| 227 | } |
| 228 | |
| 229 | // Assumes tmul hint (1 BigInteger) at the top of stack |
| 230 | // and operands (a, b, c, d) at stack depths (a_depth, b_depth, c_depth, d_depth) |