pub(crate) fn correct_key_proof_rho(n: &BigInt) -> Vec<BigInt> {
    // use sha256 because it is used already in other parts of the code
    const HASH_SIZE: usize = 256;
    // use a 256 bit salt (i.e., "nash" as input to sha256)
    let salt: String = format!(
        "{:0>64}",
        create_hash(&BigInt::from_bytes(b"nash")).to_hex()
    );

    let mut rho_vec: Vec<BigInt> = Vec::new();
    let iterations = NumberTests::bits(n) / HASH_SIZE;
    for i in 0..CORRECT_KEY_M {
        let mut counter: usize = 0;
        loop {
            let rho = create_hash(
                &BigInt::from_hex(
                    &(i2osp(&n.to_hex())
                        + &salt.clone()
                        + &i2osp(&i.to_string())
                        + &i2osp(&counter.to_string())),
                )
                .unwrap(),
            );
            if iterations < 1 {
                rho_vec.push(rho);
                break;
            }

            // extend rho by using a mask generation function (which is similar to a hash function but with variable-sized output)
            let mut rho_full = "".to_string();
            for i in 0..iterations {
                rho_full += &format!(
                    "{:0>64}",
                    create_hash(
                        &BigInt::from_hex(&(i2osp(&rho.to_hex()) + &i2osp(&i.to_string())))
                            .unwrap()
                    )
                    .to_hex()
                );
            }
            let rho_full_int = BigInt::from_hex(&rho_full).unwrap();
            // increase counter and retry until result is in Z_n
            if &rho_full_int < n {
                rho_vec.push(rho_full_int);
                break;
            }
            counter += 1;
        }
    }
    rho_vec
}
/// this is an implementation of the getRho() function from the paper "Efficient Noninteractive Certification of RSA Moduli and Beyond" by Goldberg et al. 2019 (Appendix C.4)
/// parameters alpha = 6370, m = 11, kappa = 139 seem reasonable for our use case.
/// the bigger alpha the more primes need to be checked during verification -> slower computation
/// the smaller alpha the more messages need to be transferred -> higher bandwidth
this is an implementation of the getRho() function from the paper "Efficient Noninteractive Certification of RSA Moduli and Beyond" by Goldberg et al. 2019 (Appendix C.4)
parameters alpha = 6370, m = 11, kappa = 139 seem reasonable for our use case.
the bigger alpha the more primes need to be checked during verification -> slower computation
the smaller alpha the more messages need to be transferred -> higher bandwidth
this is an implementation of the getRho () function from the paper " Efficient Noninteractive Certification of RSA Moduli and Beyond " by Goldberg et al . 2019 ( Appendix C . 4 ) parameters alpha = 6370 m = 11 kappa = 139 seem reasonable for our use case . the bigger alpha the more primes need to be checked during verification - > slower computation the smaller alpha the more messages need to be transferred - > higher bandwidth
pub(crate) fn correct_key_proof_rho(n: &BigInt) -> Vec<BigInt> {
    // use sha256 because it is used already in other parts of the code
    const HASH_SIZE: usize = 256;
    // use a 256 bit salt (i.e., "nash" as input to sha256)
    let salt: String = format!(
        "{:0>64}",
        create_hash(&BigInt::from_bytes(b"nash")).to_hex()
    );
    let mut rho_vec: Vec<BigInt> = Vec::new();
    let iterations = NumberTests::bits(n) / HASH_SIZE;
    for i in 0..CORRECT_KEY_M {
        let mut counter: usize = 0;
        loop {
            let rho = create_hash(
                &BigInt::from_hex(
                    &(i2osp(&n.to_hex())
                        + &salt.clone()
                        + &i2osp(&i.to_string())
                        + &i2osp(&counter.to_string())),
                )
                .unwrap(),
            );
            if iterations < 1 {
                rho_vec.push(rho);
                break;
            }
            // extend rho by using a mask generation function (which is similar to a hash function but with variable-sized output)
            let mut rho_full = "".to_string();
            for i in 0..iterations {
                rho_full += &format!(
                    "{:0>64}",
                    create_hash(
                        &BigInt::from_hex(&(i2osp(&rho.to_hex()) + &i2osp(&i.to_string())))
                            .unwrap()
                    )
                    .to_hex()
                );
            }
            let rho_full_int = BigInt::from_hex(&rho_full).unwrap();
            // increase counter and retry until result is in Z_n
            if &rho_full_int < n {
                rho_vec.push(rho_full_int);
                break;
            }
            counter += 1;
        }
    }
    rho_vec
}
pub ( crate ) fn correct_key_proof_rho ( n : & BigInt ) -> Vec < BigInt > { // use sha256 because it is used already in other parts of the code const HASH_SIZE : usize = 256 ; // use a 256 bit salt (i.e., "nash" as input to sha256) let salt : String = format ! ( " " create_hash ( BigInt from_bytes ( b" " ) ) to_hex ( ) ) ; let mut rho_vec : Vec < BigInt > = Vec :: new ( ) ; let iterations = NumberTests :: bits ( n ) / HASH_SIZE ; for i in 0 .. CORRECT_KEY_M { let mut counter : usize = 0 ; loop { let rho = create_hash ( & BigInt :: from_hex ( & ( i2osp ( & n . to_hex ( ) ) + & salt . clone ( ) + & i2osp ( & i . to_string ( ) ) + & i2osp ( & counter . to_string ( ) ) ) , ) . unwrap ( ) , ) ; if iterations < 1 { rho_vec . push ( rho ) ; break ; } // extend rho by using a mask generation function (which is similar to a hash function but with variable-sized output) let mut rho_full = " " . to_string ( ) ; for i in 0 .. iterations { rho_full += & format ! ( " " create_hash ( BigInt from_hex ( ( i2osp ( rho to_hex ( ) ) i2osp ( i to_string ( ) ) ) ) unwrap ( ) ) to_hex ( ) ) ; } let rho_full_int = BigInt :: from_hex ( & rho_full ) . unwrap ( ) ; // increase counter and retry until result is in Z_n if & rho_full_int < n { rho_vec . push ( rho_full_int ) ; break ; } counter += 1 ; } } rho_vec }
this is an implementation of the getRho() function from the paper "Efficient Noninteractive Certification of RSA Moduli and Beyond" by Goldberg et al.
this is an implementation of the getRho () function from the paper " Efficient Noninteractive Certification of RSA Moduli and Beyond " by Goldberg et al .
n
&BigInt