/// Generating commitment for ergo-tree that is reduced to crypto
/// corresponds to an input box and with public key that prepared in input as
/// `generate_for`
Generating commitment for ergo-tree that is reduced to crypto
corresponds to an input box and with public key that prepared in input as
`generate_for`
Generating commitment for ergo - tree that is reduced to crypto corresponds to an input box and with public key that prepared in input as ` generate_for `
pub fn generate_commitments_for(
    sigma_tree: SigmaBoolean,
    generate_for: &[SigmaBoolean],
) -> HintsBag {
    fn traverse_node(
        sb: SigmaBoolean,
        bag: &mut HintsBag,
        position: NodePosition,
        generate_for: &[SigmaBoolean],
    ) {
        let sb_clone = sb.clone();
        match sb {
            SigmaBoolean::SigmaConjecture(sc) => match sc {
                SigmaConjecture::Cand(c_and) => {
                    let items: SigmaConjectureItems<SigmaBoolean> = c_and.items;
                    items.iter().enumerate().for_each(|(i, x)| {
                        traverse_node(x.clone(), bag, position.child(i), generate_for);
                    })
                }
                SigmaConjecture::Cor(cor) => {
                    let items: SigmaConjectureItems<SigmaBoolean> = cor.items;
                    items.iter().enumerate().for_each(|(i, x)| {
                        traverse_node(x.clone(), bag, position.child(i), generate_for);
                    })
                }
                SigmaConjecture::Cthreshold(c_threshold) => {
                    let items: SigmaConjectureItems<SigmaBoolean> = c_threshold.children;
                    items.iter().enumerate().for_each(|(i, x)| {
                        traverse_node(x.clone(), bag, position.child(i), generate_for);
                    })
                }
            },
            SigmaBoolean::ProofOfKnowledge(kt) => {
                if generate_for.contains(&sb_clone) {
                    let kt_clone = kt.clone();
                    if let SigmaProofOfKnowledgeTree::ProveDlog(_pdl) = kt {
                        let (r, a) = dlog_interactive_prover::first_message();
                        let own_commitment: Hint =
                            Hint::CommitmentHint(CommitmentHint::OwnCommitment(OwnCommitment {
                                image: SigmaBoolean::ProofOfKnowledge(kt_clone.clone()),
                                secret_randomness: r,
                                commitment: FirstProverMessage::FirstDlogProverMessage(a.clone()),
                                position: position.clone(),
                            }));
                        let real_commitment: Hint =
                            Hint::CommitmentHint(CommitmentHint::RealCommitment(RealCommitment {
                                image: SigmaBoolean::ProofOfKnowledge(kt_clone),
                                commitment: FirstProverMessage::FirstDlogProverMessage(a),
                                position,
                            }));
                        bag.add_hint(real_commitment);
                        bag.add_hint(own_commitment);
                    } else if let SigmaProofOfKnowledgeTree::ProveDhTuple(pdht) = kt {
                        let (a, b) = dht_interactive_prover::first_message(&pdht);
                        let own_commitment: Hint =
                            Hint::CommitmentHint(CommitmentHint::OwnCommitment(OwnCommitment {
                                image: SigmaBoolean::ProofOfKnowledge(kt_clone.clone()),
                                secret_randomness: a,
                                commitment: FirstProverMessage::FirstDhtProverMessage(b.clone()),
                                position: position.clone(),
                            }));
                        let real_commitment: Hint =
                            Hint::CommitmentHint(CommitmentHint::RealCommitment(RealCommitment {
                                image: SigmaBoolean::ProofOfKnowledge(kt_clone),
                                commitment: FirstProverMessage::FirstDhtProverMessage(b),
                                position,
                            }));
                        bag.add_hint(real_commitment);
                        bag.add_hint(own_commitment);
                    }
                }
            }
            _ => (),
        }
    }
    let mut bag = HintsBag::empty();
    traverse_node(
        sigma_tree,
        &mut bag,
        NodePosition::crypto_tree_prefix(),
        generate_for,
    );
    bag
}
pub fn generate_commitments_for ( sigma_tree : SigmaBoolean , generate_for : & [ SigmaBoolean ] , ) -> HintsBag { fn traverse_node ( sb : SigmaBoolean , bag : & mut HintsBag , position : NodePosition , generate_for : & [ SigmaBoolean ] , ) { let sb_clone = sb . clone ( ) ; match sb { SigmaBoolean :: SigmaConjecture ( sc ) => match sc { SigmaConjecture :: Cand ( c_and ) => { let items : SigmaConjectureItems < SigmaBoolean > = c_and . items ; items . iter ( ) . enumerate ( ) . for_each ( | ( i , x ) | { traverse_node ( x . clone ( ) , bag , position . child ( i ) , generate_for ) ; } ) } SigmaConjecture :: Cor ( cor ) => { let items : SigmaConjectureItems < SigmaBoolean > = cor . items ; items . iter ( ) . enumerate ( ) . for_each ( | ( i , x ) | { traverse_node ( x . clone ( ) , bag , position . child ( i ) , generate_for ) ; } ) } SigmaConjecture :: Cthreshold ( c_threshold ) => { let items : SigmaConjectureItems < SigmaBoolean > = c_threshold . children ; items . iter ( ) . enumerate ( ) . for_each ( | ( i , x ) | { traverse_node ( x . clone ( ) , bag , position . child ( i ) , generate_for ) ; } ) } } , SigmaBoolean :: ProofOfKnowledge ( kt ) => { if generate_for . contains ( & sb_clone ) { let kt_clone = kt . clone ( ) ; if let SigmaProofOfKnowledgeTree :: ProveDlog ( _pdl ) = kt { let ( r , a ) = dlog_interactive_prover :: first_message ( ) ; let own_commitment : Hint = Hint :: CommitmentHint ( CommitmentHint :: OwnCommitment ( OwnCommitment { image : SigmaBoolean :: ProofOfKnowledge ( kt_clone . clone ( ) ) , secret_randomness : r , commitment : FirstProverMessage :: FirstDlogProverMessage ( a . clone ( ) ) , position : position . clone ( ) , } ) ) ; let real_commitment : Hint = Hint :: CommitmentHint ( CommitmentHint :: RealCommitment ( RealCommitment { image : SigmaBoolean :: ProofOfKnowledge ( kt_clone ) , commitment : FirstProverMessage :: FirstDlogProverMessage ( a ) , position , } ) ) ; bag . add_hint ( real_commitment ) ; bag . add_hint ( own_commitment ) ; } else if let SigmaProofOfKnowledgeTree :: ProveDhTuple ( pdht ) = kt { let ( a , b ) = dht_interactive_prover :: first_message ( & pdht ) ; let own_commitment : Hint = Hint :: CommitmentHint ( CommitmentHint :: OwnCommitment ( OwnCommitment { image : SigmaBoolean :: ProofOfKnowledge ( kt_clone . clone ( ) ) , secret_randomness : a , commitment : FirstProverMessage :: FirstDhtProverMessage ( b . clone ( ) ) , position : position . clone ( ) , } ) ) ; let real_commitment : Hint = Hint :: CommitmentHint ( CommitmentHint :: RealCommitment ( RealCommitment { image : SigmaBoolean :: ProofOfKnowledge ( kt_clone ) , commitment : FirstProverMessage :: FirstDhtProverMessage ( b ) , position , } ) ) ; bag . add_hint ( real_commitment ) ; bag . add_hint ( own_commitment ) ; } } } _ => ( ) , } } let mut bag = HintsBag :: empty ( ) ; traverse_node ( sigma_tree , & mut bag , NodePosition :: crypto_tree_prefix ( ) , generate_for , ) ; bag }
Generating commitment for ergo-tree that is reduced to crypto
corresponds to an input box and with public key that prepared in input as
`generate_for`
Generating commitment for ergo - tree that is reduced to crypto corresponds to an input box and with public key that prepared in input as ` generate_for `
sigma_tree
SigmaBoolean
generate_for
&[SigmaBoolean]