GaloisInc / cryptol

Cryptol: The Language of Cryptography
https://galoisinc.github.io/cryptol/master/RefMan.html
BSD 3-Clause "New" or "Revised" License
1.14k stars 126 forks source link

add :smartcheck command #87

Open kiniry opened 10 years ago

kiniry commented 10 years ago

Introduce a new :smartcheck command that intelligently uses the context of value generation to produce smaller and more useful counter-examples more frequently. Discussed at some length with @TomMD.

Testing.Random.randomWord is being patched to produce proper uniform distributions as :check was never documented to generated biased values.

@brianhuffman @yav @acfoltzer @dmwit @dmzimmerman probably have opinions about this. ;)

LeventErkok commented 10 years ago

Here's something related.. I wanted to do this on Cryptol-1, but never got around to, but it should be easier now with the likes of sBranch and on-the-fly SMT interface available.

This is essentially the concolic testing idea (http://en.wikipedia.org/wiki/Concolic_testing)

Note that such systems hardly ever worth building for crypto-algorithms: Good crypto is always designed to be oblivious to data values for their branching, if there's any branching at all. So, it's not clear if this is really a good idea if all you want is crypto.

But if you're targeting Cryptol for other embedded work, then it could indeed be a nice addition to the tool-suite. (For instance, if you ran this algorithm on AES, you'll get zero good test vectors since AES has no choice points based on data+key. But if you run it on a fixed-point number implementation like CORDIC, it'll give you really nice test cases. Ask Adam Wick for the latter!)

atomb commented 3 years ago

PR #1028 provides an interesting start on a solution to this problem.