fn modify_joinsplit_data(
    joinsplit_data: &mut JoinSplitData<Groth16Proof>,
    modification: JoinSplitModification,
) {
    match modification {
        JoinSplitModification::CorruptSignature => {
            let mut sig_bytes: [u8; 64] = joinsplit_data.sig.into();
            // Flip a bit from an arbitrary byte of the signature.
            sig_bytes[10] ^= 0x01;
            joinsplit_data.sig = sig_bytes.into();
        }
        JoinSplitModification::CorruptProof => {
            let joinsplit = joinsplit_data
                .joinsplits_mut()
                .next()
                .expect("must have a JoinSplit");
            {
                // A proof is composed of three field elements, the first and last having 48 bytes.
                // (The middle one has 96 bytes.) To corrupt the proof without making it malformed,
                // simply swap those first and last elements.
                let (first, rest) = joinsplit.zkproof.0.split_at_mut(48);
                first.swap_with_slice(&mut rest[96..144]);
            }
        }
        JoinSplitModification::ZeroProof => {
            let joinsplit = joinsplit_data
                .joinsplits_mut()
                .next()
                .expect("must have a JoinSplit");
            joinsplit.zkproof.0 = [0; 192];
        }
    }
}
/// Modify a [`JoinSplitData`] following the given modification type.
Modify a [`JoinSplitData`] following the given modification type.
Modify a [ ` JoinSplitData ` ] following the given modification type .
fn modify_joinsplit_data(
    joinsplit_data: &mut JoinSplitData<Groth16Proof>,
    modification: JoinSplitModification,
) {
    match modification {
        JoinSplitModification::CorruptSignature => {
            let mut sig_bytes: [u8; 64] = joinsplit_data.sig.into();
            // Flip a bit from an arbitrary byte of the signature.
            sig_bytes[10] ^= 0x01;
            joinsplit_data.sig = sig_bytes.into();
        }
        JoinSplitModification::CorruptProof => {
            let joinsplit = joinsplit_data
                .joinsplits_mut()
                .next()
                .expect("must have a JoinSplit");
            {
                // A proof is composed of three field elements, the first and last having 48 bytes.
                // (The middle one has 96 bytes.) To corrupt the proof without making it malformed,
                // simply swap those first and last elements.
                let (first, rest) = joinsplit.zkproof.0.split_at_mut(48);
                first.swap_with_slice(&mut rest[96..144]);
            }
        }
        JoinSplitModification::ZeroProof => {
            let joinsplit = joinsplit_data
                .joinsplits_mut()
                .next()
                .expect("must have a JoinSplit");
            joinsplit.zkproof.0 = [0; 192];
        }
    }
}
fn modify_joinsplit_data ( joinsplit_data : & mut JoinSplitData < Groth16Proof > , modification : JoinSplitModification , ) { match modification { JoinSplitModification :: CorruptSignature => { let mut sig_bytes : [ u8 ; 64 ] = joinsplit_data . sig . into ( ) ; // Flip a bit from an arbitrary byte of the signature. sig_bytes [ 10 ] ^= 0x01 ; joinsplit_data . sig = sig_bytes . into ( ) ; } JoinSplitModification :: CorruptProof => { let joinsplit = joinsplit_data . joinsplits_mut ( ) . next ( ) . expect ( " " ) ; { // A proof is composed of three field elements, the first and last having 48 bytes. // (The middle one has 96 bytes.) To corrupt the proof without making it malformed, // simply swap those first and last elements. let ( first , rest ) = joinsplit . zkproof . 0 . split_at_mut ( 48 ) ; first . swap_with_slice ( & mut rest [ 96 .. 144 ] ) ; } } JoinSplitModification :: ZeroProof => { let joinsplit = joinsplit_data . joinsplits_mut ( ) . next ( ) . expect ( " " ) ; joinsplit . zkproof . 0 = [ 0 ; 192 ] ; } } }
Modify a [`JoinSplitData`] following the given modification type.
Modify a [ ` JoinSplitData ` ] following the given modification type .
joinsplit_data
&mut JoinSplitData<Groth16Proof>
modification
JoinSplitModification