(
hint_in_c: Vec<ark_ff::BigInt<4>>,
)
| 298 | } |
| 299 | |
| 300 | pub(crate) fn chunk_hash_c_inv( |
| 301 | hint_in_c: Vec<ark_ff::BigInt<4>>, |
| 302 | ) -> (ark_bn254::Fq6, bool, Script, Vec<Hint>) { |
| 303 | assert_eq!(hint_in_c.len(), 6); |
| 304 | |
| 305 | let mock_f = ark_bn254::Fq6::ONE; |
| 306 | let are_valid_fps = hint_in_c |
| 307 | .iter() |
| 308 | .filter(|f| **f < ark_bn254::Fq::MODULUS) |
| 309 | .count() |
| 310 | == hint_in_c.len(); |
| 311 | |
| 312 | let f = if are_valid_fps { |
| 313 | let fvec = hint_in_c |
| 314 | .iter() |
| 315 | .map(|f| ark_bn254::Fq::from(*f)) |
| 316 | .collect::<Vec<ark_bn254::Fq>>(); |
| 317 | let tmp = ark_bn254::Fq6::new( |
| 318 | ark_bn254::Fq2::new(fvec[0], fvec[1]), |
| 319 | ark_bn254::Fq2::new(fvec[2], fvec[3]), |
| 320 | ark_bn254::Fq2::new(fvec[4], fvec[5]), |
| 321 | ); |
| 322 | |
| 323 | tmp.neg() |
| 324 | } else { |
| 325 | mock_f |
| 326 | }; |
| 327 | |
| 328 | let ops_scr = script! { |
| 329 | // [] [fneghash, fqs] |
| 330 | for _ in 0..6 { |
| 331 | {Fq::fromaltstack()} |
| 332 | } |
| 333 | // [fqs] [fneghash] |
| 334 | {Fq6::copy(0)} |
| 335 | // [fqs, fqs] [fneghash] |
| 336 | for _ in 0..6 { |
| 337 | { Fq::is_valid() } |
| 338 | OP_TOALTSTACK |
| 339 | } |
| 340 | {1} |
| 341 | for _ in 0..6 { |
| 342 | OP_FROMALTSTACK |
| 343 | OP_BOOLAND |
| 344 | } |
| 345 | // are_valid_fps -> 1 -> verify_final_hash |
| 346 | // not_valid_fps -> 0 -> skip verify_final_hash |
| 347 | // [fqs, 0/1] [fneghash] |
| 348 | OP_IF |
| 349 | // [fs] [fneghash] |
| 350 | for _ in 0..6 { |
| 351 | {Fq::roll(5)} |
| 352 | {Fq::neg(0)} |
| 353 | } |
| 354 | // [-fs] [fneghash] |
| 355 | {1} // verify_final_hash |
| 356 | // [-fs, 1] [fneghash] |
| 357 | OP_ELSE |
no test coverage detected