arkworks-rs / std

A standard library wrapper for use in the `arkworks` ecosystem
https://www.arkworks.rs
Apache License 2.0
37 stars 33 forks source link

Replace `UniformRand` by `CryptoRng + R` #36

Open vlopes11 opened 3 years ago

vlopes11 commented 3 years ago

Summary

UniformRand can be replaced by the providers in rand to reduce code complexity

Problem Definition

The base field types need to implement Standard: Distribution<T> as RNG requirement. Example:

https://github.com/arkworks-rs/algebra/blob/master/ec/src/models/short_weierstrass_jacobian.rs#L351-L363

This is superseded by CryptoRng that wraps cryptographic requirements without requiring concrete implementations in T.

Proposal


For Admin Use

Pratyush commented 3 years ago

To add a little bit of context, we're evaluating whether we can/should replace UniformRand by methods on traits (eg: Field::rand or Commitment::sample_randomness). The upside is that we can reduce our custom randomness infrastructure, which makes it so that users have one less interface to worry about.

The downside is that we can longer say something like T: UniformRand in trait bounds, and the rand infrastructure would require us to do something like Standard: Distribution<T>, which can be a bit more clunky. Fortunately, in most cases, T is a Field or a Curve or a Polynomial, so we can just move the rand function to those traits. (Indeed, in the UnivariatePolynomials we already have a custom rand function that takes as input the degree of the sampled polynomial.)