fn node_sigs_to_pubkey_sig_pairs<H>(
    registry: Arc<dyn RegistryClient>,
    node_sigs: BTreeMap<NodeId, IndividualMultiSigOf<H>>,
    key_purpose: KeyPurpose,
    registry_version: RegistryVersion,
) -> CryptoResult<(Vec<(CspPublicKey, CspSignature)>, AlgorithmId)>
where
    H: Signable,
{
    let mut algorithm_set = BTreeSet::<AlgorithmId>::new();
    let pubkey_sig_pairs = {
        let pubkey_sig_pairs: CryptoResult<Vec<(CspPublicKey, CspSignature)>> = node_sigs
            .iter()
            .map(|(node_id, individual_sig)| {
                let pk_proto = key_from_registry(
                    Arc::clone(&registry),
                    node_id.to_owned(),
                    key_purpose,
                    registry_version,
                )?;
                let algorithm_id = AlgorithmId::from(pk_proto.algorithm);
                algorithm_set.insert(algorithm_id);

                let csp_pk = CspPublicKey::try_from(pk_proto)?;
                let csp_sig = CspSignature::try_from(individual_sig)?;

                Ok((csp_pk, csp_sig))
            })
            .collect();
        // Using ? directly on collect() does not have the intended effect, so it is
        // applied to the result below. Alternatively, the ? could be applied further
        // below, but then algorithm inconsistency errors would take priority over
        // missing/invalid keys from the registry.
        pubkey_sig_pairs?
    };

    let algorithm = {
        if algorithm_set.len() != 1 {
            return Err(CryptoError::InconsistentAlgorithms {
                algorithms: algorithm_set,
                key_purpose,
                registry_version,
            });
        }
        *algorithm_set
            .iter()
            .next()
            .expect("Set was unexpectedly empty")
    };

    Ok((pubkey_sig_pairs, algorithm))
}
/// This helper method performs the following two tasks:
/// 1. maps node-specific multisigs to corresponding CSP (pubkey, sig) pairs
///    by querying the registry
/// 2. ensures that the public key's algorithm IDs are all equal
///
/// Returns the pairs together with the unique algorithm ID.
///
/// Returns an error if
/// - a node's public key is not found in the registry
/// - one of the public keys fetched from the registry is invalid
/// - the public key's algorithms are not all equal
/// - one of the given signatures is not valid
This helper method performs the following two tasks:
1. maps node-specific multisigs to corresponding CSP (pubkey, sig) pairs
by querying the registry
2. ensures that the public key's algorithm IDs are all equal

Returns the pairs together with the unique algorithm ID.

Returns an error if
a node's public key is not found in the registry
one of the public keys fetched from the registry is invalid
the public key's algorithms are not all equal
one of the given signatures is not valid
This helper method performs the following two tasks : 1 . maps node - specific multisigs to corresponding CSP ( pubkey sig ) pairs by querying the registry 2 . ensures that the public key ' s algorithm IDs are all equal Returns the pairs together with the unique algorithm ID . Returns an error if a node ' s public key is not found in the registry one of the public keys fetched from the registry is invalid the public key ' s algorithms are not all equal one of the given signatures is not valid
fn node_sigs_to_pubkey_sig_pairs<H>(
    registry: Arc<dyn RegistryClient>,
    node_sigs: BTreeMap<NodeId, IndividualMultiSigOf<H>>,
    key_purpose: KeyPurpose,
    registry_version: RegistryVersion,
) -> CryptoResult<(Vec<(CspPublicKey, CspSignature)>, AlgorithmId)>
where
    H: Signable,
{
    let mut algorithm_set = BTreeSet::<AlgorithmId>::new();
    let pubkey_sig_pairs = {
        let pubkey_sig_pairs: CryptoResult<Vec<(CspPublicKey, CspSignature)>> = node_sigs
            .iter()
            .map(|(node_id, individual_sig)| {
                let pk_proto = key_from_registry(
                    Arc::clone(&registry),
                    node_id.to_owned(),
                    key_purpose,
                    registry_version,
                )?;
                let algorithm_id = AlgorithmId::from(pk_proto.algorithm);
                algorithm_set.insert(algorithm_id);
                let csp_pk = CspPublicKey::try_from(pk_proto)?;
                let csp_sig = CspSignature::try_from(individual_sig)?;
                Ok((csp_pk, csp_sig))
            })
            .collect();
        // Using ? directly on collect() does not have the intended effect, so it is
        // applied to the result below. Alternatively, the ? could be applied further
        // below, but then algorithm inconsistency errors would take priority over
        // missing/invalid keys from the registry.
        pubkey_sig_pairs?
    };
    let algorithm = {
        if algorithm_set.len() != 1 {
            return Err(CryptoError::InconsistentAlgorithms {
                algorithms: algorithm_set,
                key_purpose,
                registry_version,
            });
        }
        *algorithm_set
            .iter()
            .next()
            .expect("Set was unexpectedly empty")
    };
    Ok((pubkey_sig_pairs, algorithm))
}
fn node_sigs_to_pubkey_sig_pairs < H > ( registry : Arc < dyn RegistryClient > , node_sigs : BTreeMap < NodeId , IndividualMultiSigOf < H > > , key_purpose : KeyPurpose , registry_version : RegistryVersion , ) -> CryptoResult < ( Vec < ( CspPublicKey , CspSignature ) > , AlgorithmId ) > where H : Signable , { let mut algorithm_set = BTreeSet :: < AlgorithmId > :: new ( ) ; let pubkey_sig_pairs = { let pubkey_sig_pairs : CryptoResult < Vec < ( CspPublicKey , CspSignature ) > > = node_sigs . iter ( ) . map ( | ( node_id , individual_sig ) | { let pk_proto = key_from_registry ( Arc :: clone ( & registry ) , node_id . to_owned ( ) , key_purpose , registry_version , ) ? ; let algorithm_id = AlgorithmId :: from ( pk_proto . algorithm ) ; algorithm_set . insert ( algorithm_id ) ; let csp_pk = CspPublicKey :: try_from ( pk_proto ) ? ; let csp_sig = CspSignature :: try_from ( individual_sig ) ? ; Ok ( ( csp_pk , csp_sig ) ) } ) . collect ( ) ; // Using ? directly on collect() does not have the intended effect, so it is // applied to the result below. Alternatively, the ? could be applied further // below, but then algorithm inconsistency errors would take priority over // missing/invalid keys from the registry. pubkey_sig_pairs ? } ; let algorithm = { if algorithm_set . len ( ) != 1 { return Err ( CryptoError :: InconsistentAlgorithms { algorithms : algorithm_set , key_purpose , registry_version , } ) ; } * algorithm_set . iter ( ) . next ( ) . expect ( " " ) } ; Ok ( ( pubkey_sig_pairs , algorithm ) ) }
This helper method performs the following two tasks:
1. maps node-specific multisigs to corresponding CSP (pubkey, sig) pairs
by querying the registry
2. ensures that the public key's algorithm IDs are all equal
This helper method performs the following two tasks : 1 . maps node - specific multisigs to corresponding CSP ( pubkey sig ) pairs by querying the registry 2 . ensures that the public key ' s algorithm IDs are all equal
registry
Arc<dyn RegistryClient>
node_sigs
BTreeMap<NodeId, IndividualMultiSigOf<H>>
key_purpose
KeyPurpose
registry_version
RegistryVersion
registry
Arc<dyn RegistryClient>
node_sigs
BTreeMap<NodeId, IndividualMultiSigOf<H>>
key_purpose
KeyPurpose
registry_version
RegistryVersion