What is Cryptol?

Cryptol is a domain-specific language for specifying cryptographic algorithms. A Cryptol implementation of an algorithm resembles its mathematical specification more closely than an implementation in a general purpose language.

Here is a comparison of a portion of the SHA-1 hash function specification and its representation in Cryptol:

Cryptol SHA-1 implementation

f : ([8], [32], [32], [32]) -> [32] f (t, x, y, z) = if (0 <= t) && (t <= 19) then (x && y) ^ (~x && z) | (20 <= t) && (t <= 39) then x ^ y ^ z | (40 <= t) && (t <= 59) then (x && y) ^ (x && z) ^ (y && z) | (60 <= t) && (t <= 79) then x ^ y ^ z else error "f: t out of range"

The Cryptol implementation unambiguously captures both the English description and the mathematical specification below:

SHA-1 specification

From page 10 of NIST 180-4.