pub fn new(entropy: usize) -> Self {
            // Less than 31
            // Since we fix both low bits of the base prime to 1, we need an extra nonce bit, since
            // the 2's place bit is artificially fixed.
            let nonce_bits_needed_in_base = nonce_bits_needed(32) + 1;
            let mut plan = Self {
                base_nonce_bits: nonce_bits_needed_in_base,
                // High bit is fixed to 1, so 31 bits for the nonce/random bits.
                base_random_bits: min(entropy, 31 - nonce_bits_needed_in_base),
                extensions: Vec::new(),
            };

            while plan.entropy() < entropy {
                // If the extension has this many bits it is guaranteed to be less than the current
                // base.
                let max_extension_bits = plan.min_value().significant_bits() as usize - 1;
                // Now, how many of those need to be nonce.
                // TODO We could get a tighter bound by using max values, and not bits.
                let max_nonce_bits_needed = nonce_bits_needed(max_extension_bits + plan.max_bits());
                assert!(max_nonce_bits_needed < max_extension_bits);
                let max_random_bits = max_extension_bits - max_nonce_bits_needed - 1;
                let random_bits = min(entropy - plan.entropy(), max_random_bits);
                // TODO we might be able to omit a nonce bit if we were to re-compute the nonce
                // width using `random_bits`.
                plan.extensions.push(PlannedExtension {
                    nonce_bits: max_nonce_bits_needed,
                    random_bits: random_bits,
                })
                // TODO these TODOs are worth looking at because we currently require 321 bits for
                // a 256b nonce, which is just bigger than a multiple of 32.
            }

            plan
        }
/// Given a target entropy, constructs a plan for how to make a prime number of that
/// bitwidth that can be certified using a recursive Pocklington test.
Given a target entropy, constructs a plan for how to make a prime number of that
bitwidth that can be certified using a recursive Pocklington test.
Given a target entropy constructs a plan for how to make a prime number of that bitwidth that can be certified using a recursive Pocklington test .
pub fn new(entropy: usize) -> Self {
            // Less than 31
            // Since we fix both low bits of the base prime to 1, we need an extra nonce bit, since
            // the 2's place bit is artificially fixed.
            let nonce_bits_needed_in_base = nonce_bits_needed(32) + 1;
            let mut plan = Self {
                base_nonce_bits: nonce_bits_needed_in_base,
                // High bit is fixed to 1, so 31 bits for the nonce/random bits.
                base_random_bits: min(entropy, 31 - nonce_bits_needed_in_base),
                extensions: Vec::new(),
            };
            while plan.entropy() < entropy {
                // If the extension has this many bits it is guaranteed to be less than the current
                // base.
                let max_extension_bits = plan.min_value().significant_bits() as usize - 1;
                // Now, how many of those need to be nonce.
                // TODO We could get a tighter bound by using max values, and not bits.
                let max_nonce_bits_needed = nonce_bits_needed(max_extension_bits + plan.max_bits());
                assert!(max_nonce_bits_needed < max_extension_bits);
                let max_random_bits = max_extension_bits - max_nonce_bits_needed - 1;
                let random_bits = min(entropy - plan.entropy(), max_random_bits);
                // TODO we might be able to omit a nonce bit if we were to re-compute the nonce
                // width using `random_bits`.
                plan.extensions.push(PlannedExtension {
                    nonce_bits: max_nonce_bits_needed,
                    random_bits: random_bits,
                })
                // TODO these TODOs are worth looking at because we currently require 321 bits for
                // a 256b nonce, which is just bigger than a multiple of 32.
            }
            plan
        }
pub fn new ( entropy : usize ) -> Self { // Less than 31 // Since we fix both low bits of the base prime to 1, we need an extra nonce bit, since // the 2's place bit is artificially fixed. let nonce_bits_needed_in_base = nonce_bits_needed ( 32 ) + 1 ; let mut plan = Self { base_nonce_bits : nonce_bits_needed_in_base , // High bit is fixed to 1, so 31 bits for the nonce/random bits. base_random_bits : min ( entropy , 31 - nonce_bits_needed_in_base ) , extensions : Vec :: new ( ) , } ; while plan . entropy ( ) < entropy { // If the extension has this many bits it is guaranteed to be less than the current // base. let max_extension_bits = plan . min_value ( ) . significant_bits ( ) as usize - 1 ; // Now, how many of those need to be nonce. // TODO We could get a tighter bound by using max values, and not bits. let max_nonce_bits_needed = nonce_bits_needed ( max_extension_bits + plan . max_bits ( ) ) ; assert ! ( max_nonce_bits_needed max_extension_bits ) ; let max_random_bits = max_extension_bits - max_nonce_bits_needed - 1 ; let random_bits = min ( entropy - plan . entropy ( ) , max_random_bits ) ; // TODO we might be able to omit a nonce bit if we were to re-compute the nonce // width using `random_bits`. plan . extensions . push ( PlannedExtension { nonce_bits : max_nonce_bits_needed , random_bits : random_bits , } ) // TODO these TODOs are worth looking at because we currently require 321 bits for // a 256b nonce, which is just bigger than a multiple of 32. } plan }
Given a target entropy, constructs a plan for how to make a prime number of that
bitwidth that can be certified using a recursive Pocklington test.
Given a target entropy constructs a plan for how to make a prime number of that bitwidth that can be certified using a recursive Pocklington test .
entropy
usize
entropy
usize