/// Returns the individual public key for the given `node_id` and `dkg_id` from
/// the store if present and otherwise calculates and stores it.
///
/// Note regarding concurrency: checking whether a public key is already
/// available in the store is done with a read lock while inserting a
/// key into the store is done with a write lock. This non-atomic approach
/// is intentional because we expect reads to happen more often and not
/// a problem because multiple threads would calculate and store the same key.
///
/// # Errors
/// * CryptoError::ThresholdSigDataNotFound if the public coefficients for
///   `dkg_id` are missing in the store
/// * CryptoError::ThresholdSigDataNotFound if the index for `node_id` for
///   `dkg_id` is missing in the store
///
/// # Panics
/// The method panics if calculating the individual public key fails. This
/// currently happens in the following two cases:
/// * the public coefficients are not of type `AlgorithmId::ThresBls12_381` (as
///   indicated by a `CryptoError::InvalidArgument`("unsupported algorithm"))
/// * conversion of the public coefficients to a BLS12-381 public key fails (as
///   indicated by a `CryptoError::MalformedPublicKey`("Invalid public key"))
/// Given that both cases indicate that the implementations of DKG and threshold
/// signatures are not aligned and also a caller could not recover from this, we
/// panic.
Returns the individual public key for the given `node_id` and `dkg_id` from
the store if present and otherwise calculates and stores it.

Note regarding concurrency: checking whether a public key is already
available in the store is done with a read lock while inserting a
key into the store is done with a write lock. This non-atomic approach
is intentional because we expect reads to happen more often and not
a problem because multiple threads would calculate and store the same key.
Returns the individual public key for the given ` node_id ` and ` dkg_id ` from the store if present and otherwise calculates and stores it . Note regarding concurrency : checking whether a public key is already available in the store is done with a read lock while inserting a key into the store is done with a write lock . This non - atomic approach is intentional because we expect reads to happen more often and not a problem because multiple threads would calculate and store the same key .
fn lazily_calculated_public_key_from_store<C: ThresholdSignatureCspClient>(
    lockable_threshold_sig_data_store: &LockableThresholdSigDataStore,
    threshold_sig_csp_client: &C,
    dkg_id: DkgId,
    node_id: NodeId,
) -> CryptoResult<CspThresholdSigPublicKey> {
    match public_key_from_store(lockable_threshold_sig_data_store, dkg_id, node_id) {
        Some(public_key) => Ok(public_key),
        None => calculate_and_store_public_key_or_panic(
            lockable_threshold_sig_data_store,
            threshold_sig_csp_client,
            dkg_id,
            node_id,
        ),
    }
}
fn lazily_calculated_public_key_from_store < C : ThresholdSignatureCspClient > ( lockable_threshold_sig_data_store : & LockableThresholdSigDataStore , threshold_sig_csp_client : & C , dkg_id : DkgId , node_id : NodeId , ) -> CryptoResult < CspThresholdSigPublicKey > { match public_key_from_store ( lockable_threshold_sig_data_store , dkg_id , node_id ) { Some ( public_key ) => Ok ( public_key ) , None => calculate_and_store_public_key_or_panic ( lockable_threshold_sig_data_store , threshold_sig_csp_client , dkg_id , node_id , ) , } }
Returns the individual public key for the given `node_id` and `dkg_id` from
the store if present and otherwise calculates and stores it.
Returns the individual public key for the given ` node_id ` and ` dkg_id ` from the store if present and otherwise calculates and stores it .
lockable_threshold_sig_data_store
&LockableThresholdSigDataStore
threshold_sig_csp_client
&C
dkg_id
DkgId
node_id
NodeId
errors
:ThresholdSigDataNotFound if the public coefficients for
`dkg_id` are missing in the store
CryptoError::ThresholdSigDataNotFound if the index for `node_id` for
`dkg_id` is missing in the store
: ThresholdSigDataNotFound if the public coefficients for ` dkg_id ` are missing in the store CryptoError :: ThresholdSigDataNotFound if the index for ` node_id ` for ` dkg_id ` is missing in the store
panics
The method panics if calculating the individual public key fails. This
currently happens in the following two cases:
the public coefficients are not of type `AlgorithmId::ThresBls12_381` (as
indicated by a `CryptoError::InvalidArgument`("unsupported algorithm"))
conversion of the public coefficients to a BLS12-381 public key fails (as
indicated by a `CryptoError::MalformedPublicKey`("Invalid public key"))
Given that both cases indicate that the implementations of DKG and threshold
signatures are not aligned and also a caller could not recover from this, we
panic.
The method panics if calculating the individual public key fails . This currently happens in the following two cases : the public coefficients are not of type ` AlgorithmId :: ThresBls12_381 ` ( as indicated by a ` CryptoError :: InvalidArgument ` ( " unsupported algorithm " )) conversion of the public coefficients to a BLS12 - 381 public key fails ( as indicated by a ` CryptoError :: MalformedPublicKey ` ( " Invalid public key " )) Given that both cases indicate that the implementations of DKG and threshold signatures are not aligned and also a caller could not recover from this we panic .