fn create_forward_secure_key_pair(
        &mut self,
        algorithm_id: AlgorithmId,
        node_id: NodeId,
    ) -> Result<(CspFsEncryptionPublicKey, CspFsEncryptionPop), ni_dkg_errors::CspDkgCreateFsKeyError>
    {
        debug!(self.logger; crypto.method_name => "create_forward_secure_key_pair");

        // Get state
        let seed = Randomness::from(self.rng_write_lock().gen::<[u8; 32]>());
        // Specialise
        let result = match algorithm_id {
            AlgorithmId::NiDkg_Groth20_Bls12_381 => {
                // Call lib:
                let key_set = clib::create_forward_secure_key_pair(seed, node_id.get().as_slice());

                // Generalise over fs key variants:
                let public_key = CspFsEncryptionPublicKey::Groth20_Bls12_381(key_set.public_key);
                let pop = CspFsEncryptionPop::Groth20WithPop_Bls12_381(key_set.pop);
                let key_set = CspFsEncryptionKeySet::Groth20WithPop_Bls12_381(key_set);
                Ok((public_key, pop, key_set))
            }
            other => Err(ni_dkg_errors::CspDkgCreateFsKeyError::UnsupportedAlgorithmId(other)),
        };
        let (public_key, pop, key_set) = result?;

        // Update state:
        let key_id = forward_secure_key_id(&public_key);
        if let Err(err) = self.sks_write_lock().insert(
            key_id,
            CspSecretKey::FsEncryption(key_set),
            Some(NIDKG_FS_SCOPE),
        ) {
            match err {
              SecretKeyStoreError::DuplicateKeyId(_key_id) =>
                panic!(
                    "Could not insert key as the KeyId is already in use.  This suggests an insecure RNG."
                ),
            };
        };

        // FIN:
        Ok((public_key, pop))
    }
/// Creates a key pair for encrypting threshold key shares in transmission
/// from dealers to receivers.
Creates a key pair for encrypting threshold key shares in transmission
from dealers to receivers.
Creates a key pair for encrypting threshold key shares in transmission from dealers to receivers .
fn create_forward_secure_key_pair(
        &mut self,
        algorithm_id: AlgorithmId,
        node_id: NodeId,
    ) -> Result<(CspFsEncryptionPublicKey, CspFsEncryptionPop), ni_dkg_errors::CspDkgCreateFsKeyError>
    {
        debug!(self.logger; crypto.method_name => "create_forward_secure_key_pair");
        // Get state
        let seed = Randomness::from(self.rng_write_lock().gen::<[u8; 32]>());
        // Specialise
        let result = match algorithm_id {
            AlgorithmId::NiDkg_Groth20_Bls12_381 => {
                // Call lib:
                let key_set = clib::create_forward_secure_key_pair(seed, node_id.get().as_slice());
                // Generalise over fs key variants:
                let public_key = CspFsEncryptionPublicKey::Groth20_Bls12_381(key_set.public_key);
                let pop = CspFsEncryptionPop::Groth20WithPop_Bls12_381(key_set.pop);
                let key_set = CspFsEncryptionKeySet::Groth20WithPop_Bls12_381(key_set);
                Ok((public_key, pop, key_set))
            }
            other => Err(ni_dkg_errors::CspDkgCreateFsKeyError::UnsupportedAlgorithmId(other)),
        };
        let (public_key, pop, key_set) = result?;
        // Update state:
        let key_id = forward_secure_key_id(&public_key);
        if let Err(err) = self.sks_write_lock().insert(
            key_id,
            CspSecretKey::FsEncryption(key_set),
            Some(NIDKG_FS_SCOPE),
        ) {
            match err {
              SecretKeyStoreError::DuplicateKeyId(_key_id) =>
                panic!(
                    "Could not insert key as the KeyId is already in use.  This suggests an insecure RNG."
                ),
            };
        };
        // FIN:
        Ok((public_key, pop))
    }
fn create_forward_secure_key_pair ( & mut self , algorithm_id : AlgorithmId , node_id : NodeId , ) -> Result < ( CspFsEncryptionPublicKey , CspFsEncryptionPop ) , ni_dkg_errors :: CspDkgCreateFsKeyError > { debug ! ( self logger crypto method_name " " ) ; // Get state let seed = Randomness :: from ( self . rng_write_lock ( ) . gen :: < [ u8 ; 32 ] > ( ) ) ; // Specialise let result = match algorithm_id { AlgorithmId :: NiDkg_Groth20_Bls12_381 => { // Call lib: let key_set = clib :: create_forward_secure_key_pair ( seed , node_id . get ( ) . as_slice ( ) ) ; // Generalise over fs key variants: let public_key = CspFsEncryptionPublicKey :: Groth20_Bls12_381 ( key_set . public_key ) ; let pop = CspFsEncryptionPop :: Groth20WithPop_Bls12_381 ( key_set . pop ) ; let key_set = CspFsEncryptionKeySet :: Groth20WithPop_Bls12_381 ( key_set ) ; Ok ( ( public_key , pop , key_set ) ) } other => Err ( ni_dkg_errors :: CspDkgCreateFsKeyError :: UnsupportedAlgorithmId ( other ) ) , } ; let ( public_key , pop , key_set ) = result ? ; // Update state: let key_id = forward_secure_key_id ( & public_key ) ; if let Err ( err ) = self . sks_write_lock ( ) . insert ( key_id , CspSecretKey :: FsEncryption ( key_set ) , Some ( NIDKG_FS_SCOPE ) , ) { match err { SecretKeyStoreError :: DuplicateKeyId ( _key_id ) => panic ! ( " " ) , } ; } ; // FIN: Ok ( ( public_key , pop ) ) }
Creates a key pair for encrypting threshold key shares in transmission
from dealers to receivers.
Creates a key pair for encrypting threshold key shares in transmission from dealers to receivers .
&mut self
algorithm_id
AlgorithmId
node_id
NodeId
&mut self
algorithm_id
AlgorithmId
node_id
NodeId