fn verify_keygen_args(
    threshold: NumberOfNodes,
    share_indices: &[bool],
) -> Result<(), InvalidArgumentError> {
    if NodeIndex::try_from(share_indices.len()).is_err() {
        return Err(InvalidArgumentError {
            message: format!(
                "Too many share indices: (share_indices.len()={} !<= {}=max)",
                share_indices.len(),
                NodeIndex::max_value()
            ),
        });
    }
    let number_of_eligible_nodes = NumberOfNodes::from(
        NodeIndex::try_from(share_indices.iter().filter(|x| **x).count())
            .expect("Cannot fail because this is less than the total number of nodes"),
    );
    if threshold > number_of_eligible_nodes {
        return Err(InvalidArgumentError {
            message: format!(
                "Threshold too high: (threshold={} !<= {}=num_shares)",
                threshold.get(),
                number_of_eligible_nodes,
            ),
        });
    }
    Ok(())
}
/// Verifies that the keygen args are satisfiable.
///
/// # Arguments
/// * `share_indices` - a vector with one entry per receiver.  The entry is true
///   iff the receiver is eligible to receive a threshold key.
/// * `threshold` - the minimum number of individual signatures that can be
///   combined into a valid threshold signature.
/// # Errors
/// This returns an error if:
/// * The number of share indices is too large to be stored as type
///   NumberOfNodes.
/// * The number of eligible receivers is below the threshold; under these
///   circumstances the receivers could never generate a valid threshold key.
Verifies that the keygen args are satisfiable.
Verifies that the keygen args are satisfiable .
fn verify_keygen_args(
    threshold: NumberOfNodes,
    share_indices: &[bool],
) -> Result<(), InvalidArgumentError> {
    if NodeIndex::try_from(share_indices.len()).is_err() {
        return Err(InvalidArgumentError {
            message: format!(
                "Too many share indices: (share_indices.len()={} !<= {}=max)",
                share_indices.len(),
                NodeIndex::max_value()
            ),
        });
    }
    let number_of_eligible_nodes = NumberOfNodes::from(
        NodeIndex::try_from(share_indices.iter().filter(|x| **x).count())
            .expect("Cannot fail because this is less than the total number of nodes"),
    );
    if threshold > number_of_eligible_nodes {
        return Err(InvalidArgumentError {
            message: format!(
                "Threshold too high: (threshold={} !<= {}=num_shares)",
                threshold.get(),
                number_of_eligible_nodes,
            ),
        });
    }
    Ok(())
}
fn verify_keygen_args ( threshold : NumberOfNodes , share_indices : & [ bool ] , ) -> Result < ( ) , InvalidArgumentError > { if NodeIndex :: try_from ( share_indices . len ( ) ) . is_err ( ) { return Err ( InvalidArgumentError { message : format ! ( " " share_indices len ( ) NodeIndex max_value ( ) ) , } ) ; } let number_of_eligible_nodes = NumberOfNodes :: from ( NodeIndex :: try_from ( share_indices . iter ( ) . filter ( | x | * * x ) . count ( ) ) . expect ( " " ) , ) ; if threshold > number_of_eligible_nodes { return Err ( InvalidArgumentError { message : format ! ( " " threshold get ( ) number_of_eligible_nodes ) , } ) ; } Ok ( ( ) ) }
Verifies that the keygen args are satisfiable.
Verifies that the keygen args are satisfiable .
threshold
NumberOfNodes
share_indices
&[bool]
threshold
NumberOfNodes
share_indices
&[bool]
errors
This returns an error if:
The number of share indices is too large to be stored as type
NumberOfNodes.
The number of eligible receivers is below the threshold; under these
circumstances the receivers could never generate a valid threshold key.
This returns an error if : The number of share indices is too large to be stored as type NumberOfNodes . The number of eligible receivers is below the threshold ; under these circumstances the receivers could never generate a valid threshold key .