Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make explicit the RNG's security needed for CRH parameter generation #19

Open
weikengchen opened this issue Aug 9, 2020 · 1 comment

Comments

@weikengchen
Copy link
Member

In generating the group elements for Pedersen hashes, we want these elements to have some sort of independence. This can be done by (1) using truly random bits (but not verifiable) or (2) using a cryptographic hash function, treated as a random oracle.

This, indeed, places a requirement on the security of RNG that is qualified to set up Pedersen hashes.

Currently, the CRH interface does not explicitly ask for this security. In fact, any RNG suffices.

    pub fn generator_powers<R: Rng>(num_powers: usize, rng: &mut R) -> Vec<G> {
        let mut cur_gen_powers = Vec::with_capacity(num_powers);
        let mut base = G::rand(rng);
        for _ in 0..num_powers {
            cur_gen_powers.push(base);
            base.double_in_place();
        }
        cur_gen_powers
    }

This would be problematic if the developers did not instantiate CRH with a secure RNG, but, for example, uses a weak RNG.

Such as in dpc's test:

#[test]
fn integration_test() {
    let mut rng = XorShiftRng::seed_from_u64(23472342u64);
    ...
}

Proposed solution:

It is necessary for cryptographic parameters whose setup is somehow based on random oracle to say so explicitly.

It seems that Rust has provided a trait that extends Rng, called CryptoRng. Note that this is only a marker, and it needs to be used together with Rng.
https://docs.rs/rand/0.5.0/rand/trait.CryptoRng.html

We likely should change a number of setup functions to explicitly ask for this level. Also, some prove, index may also require this level of security.

@Pratyush Pratyush transferred this issue from arkworks-rs/snark Nov 20, 2020
@weikengchen
Copy link
Member Author

We probably would leave this issue for the future.

It requires too many changes upstream, while the necessity is small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants