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

Function test_chunk_hinted_square

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

Source from the content-addressed store, hash-verified

497
498 #[test]
499 fn test_chunk_hinted_square() {
500 let mut prng = ChaCha20Rng::seed_from_u64(0);
501 let f = ark_bn254::Fq12::rand(&mut prng);
502 let f_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, f.c1 / f.c0);
503
504 let h = f * f;
505 let h_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, h.c1 / h.c0);
506
507 let (hint_out, input_is_valid, h_scr, mul_hints) = chunk_fq12_square(f_n.c1);
508 assert_eq!(h_n.c1, hint_out);
509 assert!(input_is_valid);
510
511 let f_n_c1 = DataType::Fp6Data(f_n.c1);
512 let h_n_c1 = DataType::Fp6Data(h_n.c1);
513 let hint_out = DataType::Fp6Data(hint_out);
514
515 let mut preimage_hints = vec![];
516 let f6_hints = f_n_c1.to_witness(ElementType::Fp6);
517 let h6_hints = h_n_c1.to_witness(ElementType::Fp6);
518 preimage_hints.extend_from_slice(&f6_hints);
519 preimage_hints.extend_from_slice(&h6_hints);
520
521 let bitcom_scr = script! {
522 {hint_out.to_hash().as_hint_type().push()}
523 {Fq::toaltstack()}
524 {f_n_c1.to_hash().as_hint_type().push()}
525 {Fq::toaltstack()}
526 };
527
528 let hash_scr = script! {
529 {hash_messages(vec![ElementType::Fp6, ElementType::Fp6])}
530 OP_TRUE
531 };
532
533 let tap_len = h_scr.len() + hash_scr.len();
534 let scr = script! {
535 for h in mul_hints {
536 {h.push()}
537 }
538 for h in preimage_hints {
539 {h.push()}
540 }
541 {bitcom_scr}
542 {h_scr}
543 {hash_scr}
544 };
545 let res = execute_script(scr);
546 if res.final_stack.len() > 1 {
547 for i in 0..res.final_stack.len() {
548 println!("{i:} {:?}", res.final_stack.get(i));
549 }
550 }
551 assert!(!res.success);
552 assert!(res.final_stack.len() == 1);
553 println!(
554 "chunk_fq12_square disprovable(false) script {} stack {:?}",
555 tap_len, res.stats.max_nb_stack_items
556 );

Callers

nothing calls this directly

Calls 4

chunk_fq12_squareFunction · 0.85
execute_scriptFunction · 0.85
to_witnessMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected