/// A method which is extracting partial proofs of secret knowledge for particular secrets with their
/// respective public images given. Useful for distributed signature applications.
/// See DistributedSigSpecification for examples of usage.
A method which is extracting partial proofs of secret knowledge for particular secrets with their
respective public images given. Useful for distributed signature applications.
See DistributedSigSpecification for examples of usage.
A method which is extracting partial proofs of secret knowledge for particular secrets with their respective public images given . Useful for distributed signature applications . See DistributedSigSpecification for examples of usage .
pub fn bag_for_multi_sig(
    sigma_tree: SigmaBoolean,
    real_propositions: &[SigmaBoolean],
    simulated_propositions: &[SigmaBoolean],
    proof: &[u8],
) -> Result<HintsBag, SigParsingError> {
    let ut = compute_commitments(parse_sig_compute_challenges(&sigma_tree, proof.to_owned())?);
    // Traversing node of sigma tree
    fn traverse_node(
        tree: UncheckedTree,
        real_propositions: &[SigmaBoolean],
        simulated_propositions: &[SigmaBoolean],
        position: NodePosition,
        bag: &mut HintsBag,
    ) -> Result<(), SigParsingError> {
        match tree {
            UncheckedTree::UncheckedConjecture(unchecked_conjecture) => {
                let items: SigmaConjectureItems<UncheckedTree> =
                    unchecked_conjecture.children_ust();
                items
                    .iter()
                    .enumerate()
                    .try_for_each(|(i, x)| -> Result<(), SigParsingError> {
                        traverse_node(
                            x.clone(),
                            real_propositions,
                            simulated_propositions,
                            position.child(i),
                            bag,
                        )?;
                        Ok(())
                    })?;
            }
            UncheckedTree::UncheckedLeaf(leaf) => {
                match leaf.commitment_opt() {
                    Some(commitment) => {
                        let real_found = real_propositions.contains(&leaf.proposition());
                        let simulated_found = simulated_propositions.contains(&leaf.proposition());
                        if real_found || simulated_found {
                            if real_found {
                                let real_commitment: Hint = Hint::CommitmentHint(
                                    CommitmentHint::RealCommitment(RealCommitment {
                                        image: leaf.proposition(),
                                        commitment,
                                        position: position.clone(),
                                    }),
                                );
                                let real_secret_proof: Hint = Hint::SecretProven(
                                    SecretProven::RealSecretProof(RealSecretProof {
                                        image: leaf.proposition(),
                                        challenge: leaf.challenge(),
                                        unchecked_tree: UncheckedTree::UncheckedLeaf(leaf),
                                        position,
                                    }),
                                );
                                bag.add_hint(real_commitment);
                                bag.add_hint(real_secret_proof);
                            } else {
                                let simulated_commitment: Hint = Hint::CommitmentHint(
                                    CommitmentHint::SimulatedCommitment(SimulatedCommitment {
                                        image: leaf.proposition(),
                                        commitment,
                                        position: position.clone(),
                                    }),
                                );
                                let simulated_secret_proof: Hint = Hint::SecretProven(
                                    SecretProven::SimulatedSecretProof(SimulatedSecretProof {
                                        image: leaf.proposition(),
                                        challenge: leaf.challenge(),
                                        unchecked_tree: UncheckedTree::UncheckedLeaf(leaf),
                                        position,
                                    }),
                                );
                                bag.add_hint(simulated_commitment);
                                bag.add_hint(simulated_secret_proof);
                            }
                        }
                    }
                    None => {
                        return Err(SigParsingError::Unexpected("empty commitment"));
                    }
                };
            }
        }
        Ok(())
    }
    let mut bag: HintsBag = HintsBag::empty();
    traverse_node(
        ut,
        real_propositions,
        simulated_propositions,
        NodePosition::crypto_tree_prefix(),
        &mut bag,
    )?;
    Ok(bag)
}
pub fn bag_for_multi_sig ( sigma_tree : SigmaBoolean , real_propositions : & [ SigmaBoolean ] , simulated_propositions : & [ SigmaBoolean ] , proof : & [ u8 ] , ) -> Result < HintsBag , SigParsingError > { let ut = compute_commitments ( parse_sig_compute_challenges ( & sigma_tree , proof . to_owned ( ) ) ? ) ; // Traversing node of sigma tree fn traverse_node ( tree : UncheckedTree , real_propositions : & [ SigmaBoolean ] , simulated_propositions : & [ SigmaBoolean ] , position : NodePosition , bag : & mut HintsBag , ) -> Result < ( ) , SigParsingError > { match tree { UncheckedTree :: UncheckedConjecture ( unchecked_conjecture ) => { let items : SigmaConjectureItems < UncheckedTree > = unchecked_conjecture . children_ust ( ) ; items . iter ( ) . enumerate ( ) . try_for_each ( | ( i , x ) | -> Result < ( ) , SigParsingError > { traverse_node ( x . clone ( ) , real_propositions , simulated_propositions , position . child ( i ) , bag , ) ? ; Ok ( ( ) ) } ) ? ; } UncheckedTree :: UncheckedLeaf ( leaf ) => { match leaf . commitment_opt ( ) { Some ( commitment ) => { let real_found = real_propositions . contains ( & leaf . proposition ( ) ) ; let simulated_found = simulated_propositions . contains ( & leaf . proposition ( ) ) ; if real_found || simulated_found { if real_found { let real_commitment : Hint = Hint :: CommitmentHint ( CommitmentHint :: RealCommitment ( RealCommitment { image : leaf . proposition ( ) , commitment , position : position . clone ( ) , } ) , ) ; let real_secret_proof : Hint = Hint :: SecretProven ( SecretProven :: RealSecretProof ( RealSecretProof { image : leaf . proposition ( ) , challenge : leaf . challenge ( ) , unchecked_tree : UncheckedTree :: UncheckedLeaf ( leaf ) , position , } ) , ) ; bag . add_hint ( real_commitment ) ; bag . add_hint ( real_secret_proof ) ; } else { let simulated_commitment : Hint = Hint :: CommitmentHint ( CommitmentHint :: SimulatedCommitment ( SimulatedCommitment { image : leaf . proposition ( ) , commitment , position : position . clone ( ) , } ) , ) ; let simulated_secret_proof : Hint = Hint :: SecretProven ( SecretProven :: SimulatedSecretProof ( SimulatedSecretProof { image : leaf . proposition ( ) , challenge : leaf . challenge ( ) , unchecked_tree : UncheckedTree :: UncheckedLeaf ( leaf ) , position , } ) , ) ; bag . add_hint ( simulated_commitment ) ; bag . add_hint ( simulated_secret_proof ) ; } } } None => { return Err ( SigParsingError :: Unexpected ( " " ) ) ; } } ; } } Ok ( ( ) ) } let mut bag : HintsBag = HintsBag :: empty ( ) ; traverse_node ( ut , real_propositions , simulated_propositions , NodePosition :: crypto_tree_prefix ( ) , & mut bag , ) ? ; Ok ( bag ) }
A method which is extracting partial proofs of secret knowledge for particular secrets with their
respective public images given.
A method which is extracting partial proofs of secret knowledge for particular secrets with their respective public images given .
sigma_tree
SigmaBoolean
real_propositions
&[SigmaBoolean]
simulated_propositions
&[SigmaBoolean]
proof
&[u8]