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

Function test_chunk_frob_fp12

bitvm/src/chunk/taps_ext_miller.rs:501–567  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

499
500 #[test]
501 fn test_chunk_frob_fp12() {
502 let mut prng = ChaCha20Rng::seed_from_u64(1);
503 let f = ark_bn254::Fq12::rand(&mut prng);
504 let f_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, f.c1 / f.c0);
505
506 for (power, should_corrupt_output_hash) in [
507 (1, true),
508 (2, true),
509 (3, true),
510 (1, false),
511 (2, false),
512 (3, false),
513 ] {
514 // data points
515 let (hout, input_is_valid, hout_scr, hout_hints) = chunk_frob_fp12(f_n.c1, power);
516 assert!(input_is_valid);
517 let hout = DataType::Fp6Data(hout);
518 let f_n_c1_elem = DataType::Fp6Data(f_n.c1);
519
520 let mut output_hash = hout.to_hash();
521 if should_corrupt_output_hash {
522 if let CompressedStateObject::Hash(r) = output_hash {
523 let random_hash = extern_hash_nibbles(vec![r, r]);
524 output_hash = CompressedStateObject::Hash(random_hash);
525 }
526 }
527 let bitcom_scr = script! {
528 {output_hash.as_hint_type().push()}
529 {Fq::toaltstack()}
530 {f_n_c1_elem.to_hash().as_hint_type().push()}
531 {Fq::toaltstack()}
532 };
533
534 let hash_scr = script! {
535 {hash_messages(vec![ElementType::Fp6, ElementType::Fp6])}
536 OP_TRUE
537 };
538
539 let tap_len = hash_scr.len() + hout_scr.len();
540
541 let scr = script! {
542 for h in hout_hints {
543 {h.push()}
544 }
545 for h in f_n_c1_elem.to_witness(ElementType::Fp6) {
546 {h.push()}
547 }
548 {bitcom_scr}
549 {hout_scr}
550 {hash_scr}
551 };
552
553 let res = execute_script(scr);
554 if res.final_stack.len() > 1 {
555 for i in 0..res.final_stack.len() {
556 println!("{i:} {:?}", res.final_stack.get(i));
557 }
558 }

Callers

nothing calls this directly

Calls 5

chunk_frob_fp12Function · 0.85
extern_hash_nibblesFunction · 0.85
execute_scriptFunction · 0.85
to_hashMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected