mimblewimble / rust-secp256k1-zkp

ZKP fork for rust-secp256k1, adds wrappers for range proofs, pedersen commitments, etc
Creative Commons Zero v1.0 Universal
56 stars 51 forks source link

Fuzz: implement Arbitrary trait for fuzzed types #74

Open unseddd opened 3 years ago

unseddd commented 3 years ago

Implementing the Arbitrary trait allows libFuzzer to work faster, and simplifies fuzz driver code.

Implementations are conditionally compiled, so non-fuzz builds aren't affected.

Commitment and RangeProof implement Arbitrary for use in main grin repo.

antiochp commented 3 years ago

https://docs.rs/arbitrary/0.4.7/arbitrary/trait.Arbitrary.html#impl-Arbitrary-for-(B%2C%20C%2C%20D%2C%20E%2C%20F%2C%20G%2C%20H%2C%20I%2C%20J%2C%20K%2C%20L%2C%20M%2C%20N%2C%20O%2C%20P%2C%20Q%2C%20R%2C%20S%2C%20T%2C%20U%2C%20V%2C%20W%2C%20X%2C%20Y%2C%20Z%2C%20A)

:sob:

I need to take a look at arbitrary a bit more, but :+1: on the idea.

unseddd commented 3 years ago

https://docs.rs/arbitrary/0.4.7/arbitrary/trait.Arbitrary.html#impl-Arbitrary-for-(B%2C%20C%2C%20D%2C%20E%2C%20F%2C%20G%2C%20H%2C%20I%2C%20J%2C%20K%2C%20L%2C%20M%2C%20N%2C%20O%2C%20P%2C%20Q%2C%20R%2C%20S%2C%20T%2C%20U%2C%20V%2C%20W%2C%20X%2C%20Y%2C%20Z%2C%20A)

:sob:

That is intense... :sweat_smile:

I'm new to the Arbitrary trait, too. Ran across it when refactoring fuzzer code. Apparently, structure-aware fuzzing is the way to go. Not sure why they do trait impls over so many generic types, maybe usability for derive macro? First time seeing something like that.