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

Function corrupt_at_random_index

bitvm/src/chunk/api.rs:721–749  ·  view source on GitHub ↗
(proof_asserts: &mut Assertions)

Source from the content-addressed store, hash-verified

719 println!("DONE");
720
721 fn corrupt_at_random_index(proof_asserts: &mut Assertions) {
722 let mut rng = rand::thread_rng();
723 let index = rng.gen_range(0..NUM_PUBS + NUM_U256 + NUM_HASH);
724 let mut scramble: [u8; 32] = [0u8; 32];
725 scramble[32 / 2] = 37;
726 let mut scramble2: [u8; BLAKE3_HASH_LENGTH] = [0u8; BLAKE3_HASH_LENGTH];
727 scramble2[BLAKE3_HASH_LENGTH / 2] = 37;
728 println!("demo: manually corrupt assertion at index at {:?}", index);
729 if index < NUM_PUBS {
730 if index == 0 {
731 if proof_asserts.0[0] == scramble {
732 scramble[16] += 1;
733 }
734 proof_asserts.0[0] = scramble;
735 }
736 } else if index < NUM_PUBS + NUM_U256 {
737 let index = index - NUM_PUBS;
738 if proof_asserts.1[index] == scramble {
739 scramble[16] += 1;
740 }
741 proof_asserts.1[index] = scramble;
742 } else if index < NUM_PUBS + NUM_U256 + NUM_HASH {
743 let index = index - NUM_PUBS - NUM_U256;
744 if proof_asserts.2[index] == scramble2 {
745 scramble2[10] += 1;
746 }
747 proof_asserts.2[index] = scramble2;
748 }
749 }
750 }
751
752 #[test]

Callers 1

full_e2e_executionFunction · 0.85

Calls

no outgoing calls

Tested by 1

full_e2e_executionFunction · 0.68