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

Function test_accumulate_rows

bitvm/src/bn254/msm.rs:432–474  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

430
431 #[test]
432 fn test_accumulate_rows() {
433 let mut prng = ChaCha20Rng::seed_from_u64(1);
434 let q = ark_bn254::G1Affine::rand(&mut prng);
435 let fq = ark_bn254::Fr::rand(&mut prng);
436 let window = WINDOW_G1_MSM as usize;
437 let mut prev = ark_bn254::G1Affine::identity();
438 let all_rows = accumulate_addition_chain_for_a_scalar_mul(prev, q, fq, window);
439
440 let expected_msm = (q * fq).into_affine();
441 let calculated_msm = all_rows[all_rows.len() - 1].0;
442 assert_eq!(expected_msm, calculated_msm);
443
444 for (row_out, row_scr, row_hints) in all_rows {
445 let tap_len = row_scr.len();
446 let scr = script! {
447 // [hints, t, scalar]
448 for h in &row_hints {
449 {h.push()}
450 }
451 {G1Affine::push(prev)}
452 {Fr::push(fq)}
453 {row_scr}
454 {G1Affine::push(row_out)}
455 {G1Affine::equalverify()}
456 {G1Affine::push(prev) }
457 {G1Affine::equalverify()}
458 OP_TRUE
459 };
460
461 let res = execute_script(scr);
462 if res.final_stack.len() > 1 {
463 for i in 0..res.final_stack.len() {
464 println!("{i:} {:?}", res.final_stack.get(i));
465 }
466 }
467 prev = row_out;
468 assert!(res.success);
469 println!(
470 "accumulate_addition_terms {:?} max_stat {:?}",
471 tap_len, res.stats.max_nb_stack_items
472 );
473 }
474 }
475
476 #[test]
477 fn test_accumulate_multiple_rows() {

Callers

nothing calls this directly

Calls 3

execute_scriptFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected