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

Function test_utils_fq12_square_valid_data

bitvm/src/chunk/taps_mul.rs:409–453  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

407
408 #[test]
409 fn test_utils_fq12_square_valid_data() {
410 let mut prng = ChaCha20Rng::seed_from_u64(0);
411 let f = ark_bn254::Fq12::rand(&mut prng);
412 let f_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, f.c1 / f.c0);
413
414 let h = f * f;
415 let h_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, h.c1 / h.c0);
416
417 let (hint_out, is_valid_input, h_scr, mut mul_hints) = utils_fq12_square(f_n.c1);
418 assert_eq!(h_n.c1, hint_out);
419 assert!(is_valid_input);
420 let f_n_c1 = DataType::Fp6Data(f_n.c1);
421 let h_n_c1 = DataType::Fp6Data(h_n.c1);
422
423 let f6_hints = f_n_c1.to_witness(ElementType::Fp6);
424 let h6_hints = h_n_c1.to_witness(ElementType::Fp6);
425 mul_hints.extend_from_slice(&f6_hints);
426 mul_hints.extend_from_slice(&h6_hints);
427
428 let tap_len = h_scr.len();
429 let scr = script! {
430 for h in mul_hints {
431 {h.push()}
432 }
433 {h_scr}
434 OP_VERIFY
435 {Fq6::push(hint_out)}
436 {Fq6::equalverify()}
437 {Fq6::push(f_n.c1)}
438 {Fq6::equalverify()}
439 OP_TRUE
440 };
441 let res = execute_script(scr);
442 if res.final_stack.len() > 1 {
443 for i in 0..res.final_stack.len() {
444 println!("{i:} {:?}", res.final_stack.get(i));
445 }
446 }
447 assert!(res.success);
448 assert!(res.final_stack.len() == 1);
449 println!(
450 "utils_fq12_square disprovable(false) script {} stack {:?}",
451 tap_len, res.stats.max_nb_stack_items
452 );
453 }
454
455 #[test]
456 fn test_utils_fq12_square_valid_data_zero() {

Callers

nothing calls this directly

Calls 4

utils_fq12_squareFunction · 0.85
execute_scriptFunction · 0.85
to_witnessMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected