pub fn random(rng: &mut ChaCha20Rng, size: usize) -> Self {
        let mut nodes_by_node_id: BTreeMap<NodeId, MockNode> = (0..size)
            .map(|_| MockNode::random(rng))
            .map(|node| (node.node_id, node))
            .collect();

        let forward_secure_keys: BTreeMap<NodeId, CspFsEncryptionPublicKey> = nodes_by_node_id
            .iter_mut()
            .map(|(node_id, node)| {
                println!("Creating fs keys for {}", node_id);
                let (id, (pubkey, pop)) = (
                    *node_id,
                    node.csp
                        .create_forward_secure_key_pair(
                            AlgorithmId::NiDkg_Groth20_Bls12_381,
                            *node_id,
                        )
                        .unwrap_or_else(|_| {
                            panic!(
                                "Failed to create forward secure encryption key for NodeId {}",
                                node_id
                            )
                        }),
                );
                let node_pks = NodePublicKeys {
                    version: 0,
                    dkg_dealing_encryption_pk: Some(
                        crate::keygen::utils::dkg_dealing_encryption_pk_to_proto(
                            pubkey.to_owned(),
                            pop,
                        ),
                    ),
                    ..Default::default()
                };
                node.csp.reset_public_key_data(node_pks);
                (id, pubkey)
            })
            .collect();

        MockNetwork {
            nodes_by_node_id,
            forward_secure_keys,
        }
    }
/// Create N nodes.  No particular roles are attached.
Create N nodes.  No particular roles are attached.
Create N nodes . No particular roles are attached .
pub fn random(rng: &mut ChaCha20Rng, size: usize) -> Self {
        let mut nodes_by_node_id: BTreeMap<NodeId, MockNode> = (0..size)
            .map(|_| MockNode::random(rng))
            .map(|node| (node.node_id, node))
            .collect();
        let forward_secure_keys: BTreeMap<NodeId, CspFsEncryptionPublicKey> = nodes_by_node_id
            .iter_mut()
            .map(|(node_id, node)| {
                println!("Creating fs keys for {}", node_id);
                let (id, (pubkey, pop)) = (
                    *node_id,
                    node.csp
                        .create_forward_secure_key_pair(
                            AlgorithmId::NiDkg_Groth20_Bls12_381,
                            *node_id,
                        )
                        .unwrap_or_else(|_| {
                            panic!(
                                "Failed to create forward secure encryption key for NodeId {}",
                                node_id
                            )
                        }),
                );
                let node_pks = NodePublicKeys {
                    version: 0,
                    dkg_dealing_encryption_pk: Some(
                        crate::keygen::utils::dkg_dealing_encryption_pk_to_proto(
                            pubkey.to_owned(),
                            pop,
                        ),
                    ),
                    ..Default::default()
                };
                node.csp.reset_public_key_data(node_pks);
                (id, pubkey)
            })
            .collect();
        MockNetwork {
            nodes_by_node_id,
            forward_secure_keys,
        }
    }
pub fn random ( rng : & mut ChaCha20Rng , size : usize ) -> Self { let mut nodes_by_node_id : BTreeMap < NodeId , MockNode > = ( 0 .. size ) . map ( | _ | MockNode :: random ( rng ) ) . map ( | node | ( node . node_id , node ) ) . collect ( ) ; let forward_secure_keys : BTreeMap < NodeId , CspFsEncryptionPublicKey > = nodes_by_node_id . iter_mut ( ) . map ( | ( node_id , node ) | { println ! ( " " node_id ) ; let ( id , ( pubkey , pop ) ) = ( * node_id , node . csp . create_forward_secure_key_pair ( AlgorithmId :: NiDkg_Groth20_Bls12_381 , * node_id , ) . unwrap_or_else ( | _ | { panic ! ( " " node_id ) } ) , ) ; let node_pks = NodePublicKeys { version : 0 , dkg_dealing_encryption_pk : Some ( crate :: keygen :: utils :: dkg_dealing_encryption_pk_to_proto ( pubkey . to_owned ( ) , pop , ) , ) , .. Default :: default ( ) } ; node . csp . reset_public_key_data ( node_pks ) ; ( id , pubkey ) } ) . collect ( ) ; MockNetwork { nodes_by_node_id , forward_secure_keys , } }
Create N nodes.
Create N nodes .
rng
&mut ChaCha20Rng
size
usize
rng
&mut ChaCha20Rng
size
usize