pub fn from_curve_and_small_prime_size<P: Field>(
        prime_bits_min: u16,
        prime_bits_max: u16,
    ) -> Result<(Parameters, u16), ParametersError> {
        let field_size_bits = P::size_in_bits() as u16;
        let security_level = field_size_bits / 2;
        let derived = (|| {
            for c in 0..security_level {
                let security_soundness_zk = ((2 * security_level - 2 - c) - 2) / 2;
                for i in prime_bits_min..=prime_bits_max {
                    if i <= 2 * security_level - 2 - c && (2 * security_level - 2 - c) % i >= i - c
                    {
                        return Some((i, security_soundness_zk));
                    }
                }
            }

            None
        })();
        let (prime_bits, security_soundness_zk) =
            derived.ok_or(ParametersError::InvalidParameters)?;

        let parameters = Parameters {
            security_level,
            security_zk: security_soundness_zk,
            security_soundness: security_soundness_zk,
            field_size_bits,
            hash_to_prime_bits: prime_bits,
        };

        parameters.is_valid()?;
        Ok((parameters, security_level))
    }
/// Derive parameters based on a curve and desired small prime bit size.
/// Based on section 4.5 of the paper.
Derive parameters based on a curve and desired small prime bit size.
Based on section 4.5 of the paper.
Derive parameters based on a curve and desired small prime bit size . Based on section 4 . 5 of the paper .
pub fn from_curve_and_small_prime_size<P: Field>(
        prime_bits_min: u16,
        prime_bits_max: u16,
    ) -> Result<(Parameters, u16), ParametersError> {
        let field_size_bits = P::size_in_bits() as u16;
        let security_level = field_size_bits / 2;
        let derived = (|| {
            for c in 0..security_level {
                let security_soundness_zk = ((2 * security_level - 2 - c) - 2) / 2;
                for i in prime_bits_min..=prime_bits_max {
                    if i <= 2 * security_level - 2 - c && (2 * security_level - 2 - c) % i >= i - c
                    {
                        return Some((i, security_soundness_zk));
                    }
                }
            }
            None
        })();
        let (prime_bits, security_soundness_zk) =
            derived.ok_or(ParametersError::InvalidParameters)?;
        let parameters = Parameters {
            security_level,
            security_zk: security_soundness_zk,
            security_soundness: security_soundness_zk,
            field_size_bits,
            hash_to_prime_bits: prime_bits,
        };
        parameters.is_valid()?;
        Ok((parameters, security_level))
    }
pub fn from_curve_and_small_prime_size < P : Field > ( prime_bits_min : u16 , prime_bits_max : u16 , ) -> Result < ( Parameters , u16 ) , ParametersError > { let field_size_bits = P :: size_in_bits ( ) as u16 ; let security_level = field_size_bits / 2 ; let derived = ( | | { for c in 0 .. security_level { let security_soundness_zk = ( ( 2 * security_level - 2 - c ) - 2 ) / 2 ; for i in prime_bits_min ..= prime_bits_max { if i <= 2 * security_level - 2 - c && ( 2 * security_level - 2 - c ) % i >= i - c { return Some ( ( i , security_soundness_zk ) ) ; } } } None } ) ( ) ; let ( prime_bits , security_soundness_zk ) = derived . ok_or ( ParametersError :: InvalidParameters ) ? ; let parameters = Parameters { security_level , security_zk : security_soundness_zk , security_soundness : security_soundness_zk , field_size_bits , hash_to_prime_bits : prime_bits , } ; parameters . is_valid ( ) ? ; Ok ( ( parameters , security_level ) ) }
Derive parameters based on a curve and desired small prime bit size.
Derive parameters based on a curve and desired small prime bit size .
prime_bits_min
u16
prime_bits_max
u16
prime_bits_min
u16
prime_bits_max
u16