pub fn embed_commit_verify_suite<MSG, CMT>(
        messages: Vec<MSG>,
        container: &mut CMT::Container,
    ) where
        MSG: AsRef<[u8]> + Eq,
        CMT: EmbedCommitVerify<MSG> + Eq + Hash + Debug,
    {
        messages.iter().fold(
            HashSet::<CMT>::with_capacity(messages.len()),
            |mut acc, msg| {
                let commitment = CMT::embed_commit(container, msg).unwrap();

                // Commitments MUST be deterministic: each message should
                // produce unique commitment
                (1..10).for_each(|_| {
                    assert_eq!(
                        CMT::embed_commit(container, msg).unwrap(),
                        commitment
                    );
                });

                // Testing verification
                assert!(commitment.verify(container, msg).unwrap());

                messages.iter().for_each(|m| {
                    // Testing that commitment verification succeeds only
                    // for the original message and fails for the rest
                    assert_eq!(
                        commitment.verify(container, m).unwrap(),
                        m == msg
                    );
                });

                acc.iter().for_each(|cmt| {
                    // Testing that verification against other commitments
                    // returns `false`
                    assert!(!cmt.verify(container, msg).unwrap());
                });

                // Detecting collision
                assert!(acc.insert(commitment));

                acc
            },
        );
    }
/// Runs round-trip of commitment-embed-verify for a given set of messages
/// and provided container
Runs round-trip of commitment-embed-verify for a given set of messages
and provided container
Runs round - trip of commitment - embed - verify for a given set of messages and provided container
pub fn embed_commit_verify_suite<MSG, CMT>(
        messages: Vec<MSG>,
        container: &mut CMT::Container,
    ) where
        MSG: AsRef<[u8]> + Eq,
        CMT: EmbedCommitVerify<MSG> + Eq + Hash + Debug,
    {
        messages.iter().fold(
            HashSet::<CMT>::with_capacity(messages.len()),
            |mut acc, msg| {
                let commitment = CMT::embed_commit(container, msg).unwrap();
                // Commitments MUST be deterministic: each message should
                // produce unique commitment
                (1..10).for_each(|_| {
                    assert_eq!(
                        CMT::embed_commit(container, msg).unwrap(),
                        commitment
                    );
                });
                // Testing verification
                assert!(commitment.verify(container, msg).unwrap());
                messages.iter().for_each(|m| {
                    // Testing that commitment verification succeeds only
                    // for the original message and fails for the rest
                    assert_eq!(
                        commitment.verify(container, m).unwrap(),
                        m == msg
                    );
                });
                acc.iter().for_each(|cmt| {
                    // Testing that verification against other commitments
                    // returns `false`
                    assert!(!cmt.verify(container, msg).unwrap());
                });
                // Detecting collision
                assert!(acc.insert(commitment));
                acc
            },
        );
    }
pub fn embed_commit_verify_suite < MSG , CMT > ( messages : Vec < MSG > , container : & mut CMT :: Container , ) where MSG : AsRef < [ u8 ] > + Eq , CMT : EmbedCommitVerify < MSG > + Eq + Hash + Debug , { messages . iter ( ) . fold ( HashSet :: < CMT > :: with_capacity ( messages . len ( ) ) , | mut acc , msg | { let commitment = CMT :: embed_commit ( container , msg ) . unwrap ( ) ; // Commitments MUST be deterministic: each message should // produce unique commitment ( 1 .. 10 ) . for_each ( | _ | { assert_eq ! ( CMT embed_commit ( container msg ) unwrap ( ) commitment ) ; } ) ; // Testing verification assert ! ( commitment verify ( container msg ) unwrap ( ) ) ; messages . iter ( ) . for_each ( | m | { // Testing that commitment verification succeeds only // for the original message and fails for the rest assert_eq ! ( commitment verify ( container m ) unwrap ( ) m msg ) ; } ) ; acc . iter ( ) . for_each ( | cmt | { // Testing that verification against other commitments // returns `false` assert ! ( cmt verify ( container msg ) unwrap ( ) ) ; } ) ; // Detecting collision assert ! ( acc insert ( commitment ) ) ; acc } , ) ; }
Runs round-trip of commitment-embed-verify for a given set of messages
and provided container
Runs round - trip of commitment - embed - verify for a given set of messages and provided container
messages
Vec<MSG>
container
&mut CMT::Container
messages
Vec<MSG>
container
&mut CMT::Container