pub(super) fn new(
        subnet_size: usize,
        dkg_tag: NiDkgTag,
        registry_version: RegistryVersion,
        num_of_dealers: usize,
    ) -> Self {
        assert!(subnet_size > 0, "subnet must not be empty");
        let rng = &mut thread_rng();

        let receivers = Self::random_node_ids(subnet_size);
        let threshold = dkg_tag.threshold_for_subnet_of_size(subnet_size);
        let dealers = {
            assert!(
                num_of_dealers >= threshold,
                "dealers must be at least the threshold"
            );
            // Exclude receivers from being dealers because initial DKG is done by NNS for
            // another (remote) subnet, which means the dealers and receivers are disjoint.
            Self::random_node_ids_excluding(&receivers, num_of_dealers)
        };

        let config_data = NiDkgConfigData {
            dkg_id: NiDkgId {
                start_block_height: Height::new(random()),
                dealer_subnet: SubnetId::from(PrincipalId::new_subnet_test_id(random())),
                dkg_tag,
                // The first DKG is always done by NNS for another (remote) subnet
                target_subnet: NiDkgTargetSubnet::Remote(NiDkgTargetId::new(random())),
            },
            max_corrupt_dealers: Self::number_of_nodes_from_usize(rng.gen_range(0, dealers.len())),
            dealers,
            max_corrupt_receivers: {
                Self::number_of_nodes_from_usize(get_faults_tolerated(subnet_size))
            },
            receivers,
            threshold: Self::number_of_nodes_from_usize(threshold),
            registry_version,
            resharing_transcript: None,
        };
        Self(NiDkgConfig::new(config_data).expect("invariant violated"))
    }
/// Creates a random NI-DKG config for `dkg_tag` satisfying all
/// invariants.
Creates a random NI-DKG config for `dkg_tag` satisfying all
invariants.
Creates a random NI - DKG config for ` dkg_tag ` satisfying all invariants .
pub(super) fn new(
        subnet_size: usize,
        dkg_tag: NiDkgTag,
        registry_version: RegistryVersion,
        num_of_dealers: usize,
    ) -> Self {
        assert!(subnet_size > 0, "subnet must not be empty");
        let rng = &mut thread_rng();
        let receivers = Self::random_node_ids(subnet_size);
        let threshold = dkg_tag.threshold_for_subnet_of_size(subnet_size);
        let dealers = {
            assert!(
                num_of_dealers >= threshold,
                "dealers must be at least the threshold"
            );
            // Exclude receivers from being dealers because initial DKG is done by NNS for
            // another (remote) subnet, which means the dealers and receivers are disjoint.
            Self::random_node_ids_excluding(&receivers, num_of_dealers)
        };
        let config_data = NiDkgConfigData {
            dkg_id: NiDkgId {
                start_block_height: Height::new(random()),
                dealer_subnet: SubnetId::from(PrincipalId::new_subnet_test_id(random())),
                dkg_tag,
                // The first DKG is always done by NNS for another (remote) subnet
                target_subnet: NiDkgTargetSubnet::Remote(NiDkgTargetId::new(random())),
            },
            max_corrupt_dealers: Self::number_of_nodes_from_usize(rng.gen_range(0, dealers.len())),
            dealers,
            max_corrupt_receivers: {
                Self::number_of_nodes_from_usize(get_faults_tolerated(subnet_size))
            },
            receivers,
            threshold: Self::number_of_nodes_from_usize(threshold),
            registry_version,
            resharing_transcript: None,
        };
        Self(NiDkgConfig::new(config_data).expect("invariant violated"))
    }
pub ( super ) fn new ( subnet_size : usize , dkg_tag : NiDkgTag , registry_version : RegistryVersion , num_of_dealers : usize , ) -> Self { assert ! ( subnet_size 0 " " ) ; let rng = & mut thread_rng ( ) ; let receivers = Self :: random_node_ids ( subnet_size ) ; let threshold = dkg_tag . threshold_for_subnet_of_size ( subnet_size ) ; let dealers = { assert ! ( num_of_dealers threshold " " ) ; // Exclude receivers from being dealers because initial DKG is done by NNS for // another (remote) subnet, which means the dealers and receivers are disjoint. Self :: random_node_ids_excluding ( & receivers , num_of_dealers ) } ; let config_data = NiDkgConfigData { dkg_id : NiDkgId { start_block_height : Height :: new ( random ( ) ) , dealer_subnet : SubnetId :: from ( PrincipalId :: new_subnet_test_id ( random ( ) ) ) , dkg_tag , // The first DKG is always done by NNS for another (remote) subnet target_subnet : NiDkgTargetSubnet :: Remote ( NiDkgTargetId :: new ( random ( ) ) ) , } , max_corrupt_dealers : Self :: number_of_nodes_from_usize ( rng . gen_range ( 0 , dealers . len ( ) ) ) , dealers , max_corrupt_receivers : { Self :: number_of_nodes_from_usize ( get_faults_tolerated ( subnet_size ) ) } , receivers , threshold : Self :: number_of_nodes_from_usize ( threshold ) , registry_version , resharing_transcript : None , } ; Self ( NiDkgConfig :: new ( config_data ) . expect ( " " ) ) }
Creates a random NI-DKG config for `dkg_tag` satisfying all
invariants.
Creates a random NI - DKG config for ` dkg_tag ` satisfying all invariants .
subnet_size
usize
dkg_tag
NiDkgTag
registry_version
RegistryVersion
num_of_dealers
usize
subnet_size
usize
dkg_tag
NiDkgTag
registry_version
RegistryVersion
num_of_dealers
usize