statement
stringlengths
1
746
proof
stringlengths
0
19.5k
type
stringclasses
7 values
symbolic_name
stringlengths
1
36
library
stringclasses
13 values
filename
stringclasses
70 values
imports
listlengths
0
23
deps
listlengths
0
14
docstring
stringclasses
1 value
source_url
stringclasses
1 value
commit
stringclasses
1 value
groupBy : {each, parts, a} (fin each) => [parts * each]a -> [parts][each]a
groupBy = split`{parts=parts} /** * Left shift. The first argument is the sequence to shift, the second is the * number of positions to shift by. */
function
groupBy
lib
lib/Cryptol.cry
[]
[ "fin" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
(@@) : {n, k, ix, a} (Integral ix) => [n]a -> [k]ix -> [k]a
function
@@
lib
lib/Cryptol.cry
[]
[ "Integral" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
(!!) : {n, k, ix, a} (fin n, Integral ix) => [n]a -> [k]ix -> [k]a
function
!!
lib
lib/Cryptol.cry
[]
[ "Integral", "fin" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
updates : {n, k, ix, a} (Integral ix, fin k) => [n]a -> [k]ix -> [k]a -> [n]a
updates xs0 idxs vals = foldl upd xs0 (zip idxs vals) where upd xs (i,b) = update xs i b /** * Perform a series of updates to a sequence. The first argument is * the initial sequence to update. The second argument is a sequence * of indices, and the third argument is a sequence of values. * This function a...
function
updates
lib
lib/Cryptol.cry
[]
[ "Integral", "fin", "foldl", "update", "xs", "zip" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
updatesEnd : {n, k, ix, a} (fin n, Integral ix, fin k) => [n]a -> [k]ix -> [k]a -> [n]a
updatesEnd xs0 idxs vals = foldl upd xs0 (zip idxs vals) where upd xs (i,b) = updateEnd xs i b /** * Produce a sequence using a generating function. * Satisfies 'generate f @ i == f i' for all 'i' between '0' and 'n-1'. * * Declarations of the form 'x @ i = e' are syntactic sugar for * 'x = generate (\i -> ...
function
updatesEnd
lib
lib/Cryptol.cry
[]
[ "Integral", "fin", "foldl", "updateEnd", "xs", "zip" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
generate : {n, a, ix} (Integral ix, LiteralLessThan n ix) => (ix -> a) -> [n]a
generate f = [ f i | i <- [0 .. <n] ] /** * Sort a sequence of elements. Equivalent to 'sortBy (<=)'. */
function
generate
lib
lib/Cryptol.cry
[]
[ "Integral", "LiteralLessThan" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
sort : {a, n} (Cmp a, fin n) => [n]a -> [n]a
sort = sortBy (<=) /** * Sort a sequence according to the given less-than-or-equal relation. * The sorting is stable, so it preserves the relative position of any * pair of elements that are equivalent according to the order relation. */
function
sort
lib
lib/Cryptol.cry
[]
[ "<=", "Cmp", "fin", "sortBy" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
sortBy : {a, n} (fin n) => (a -> a -> Bit) -> [n]a -> [n]a
sortBy le ((xs : [n/2]a) # (ys : [n/^2]a)) = take zs.0 where xs' = if `(n/2) == (1 : Integer) then xs else sortBy le xs ys' = if `(n/^2) == (1 : Integer) then ys else sortBy le ys zs = [ if i == `(n/2) then (ys'@j, i , j+1) | j == `(n/^2) then (xs'@i, i+1, j ) | ...
function
sortBy
lib
lib/Cryptol.cry
[]
[ "==", "Bit", "Integer", "fin", "take", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
rnf : {a} Eq a => a -> a
rnf x = deepseq x x /** * Raise a run-time error with the given message. * This function can be called at any type. */
function
rnf
lib
lib/Cryptol.cry
[]
[ "Eq", "deepseq" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
undefined : {a} a
undefined = error "undefined" /** * Assert that the given condition holds, and raise an error * with the given message if it does not. If the condition * holds, return the third argument unchanged. */
function
undefined
lib
lib/Cryptol.cry
[]
[ "error" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
assert : {a, n} (fin n) => Bit -> String n -> a -> a
assert pred msg x = if pred then x else error msg /** * Generates random values from a seed. When called with a function, currently * generates a function that always returns zero. */
function
assert
lib
lib/Cryptol.cry
[]
[ "Bit", "String", "error", "fin" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
traceVal : {n, a} (fin n) => String n -> a -> a
traceVal msg x = trace msg x x /* Functions previously in Cryptol::Extras */ /** * Conjunction of all bits in a sequence. */
function
traceVal
lib
lib/Cryptol.cry
[]
[ "String", "fin", "trace" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
and : {n} (fin n) => [n]Bit -> Bit
and xs = ~zero == xs /** * Disjunction of all bits in a sequence. */
function
and
lib
lib/Cryptol.cry
[]
[ "==", "Bit", "fin", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
or : {n} (fin n) => [n]Bit -> Bit
or xs = zero != xs /** * Conjunction after applying a predicate to all elements. */
function
or
lib
lib/Cryptol.cry
[]
[ "!=", "Bit", "fin", "xs", "zero" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
all : {n, a} (fin n) => (a -> Bit) -> [n]a -> Bit
all f xs = foldl' (/\) True (map f xs) /** * Disjunction after applying a predicate to all elements. */
function
all
lib
lib/Cryptol.cry
[]
[ "/\\", "Bit", "True", "fin", "foldl'", "map", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
any : {n, a} (fin n) => (a -> Bit) -> [n]a -> Bit
any f xs = foldl' (\/) False (map f xs) /** * Map a function over a sequence. */
function
any
lib
lib/Cryptol.cry
[]
[ "Bit", "False", "\\/", "fin", "foldl'", "map", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
map : {n, a, b} (a -> b) -> [n]a -> [n]b
map f xs = [f x | x <- xs] /** * Functional left fold. * * foldl (+) 0 [1,2,3] = ((0 + 1) + 2) + 3 */
function
map
lib
lib/Cryptol.cry
[]
[ "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
foldr : {n, a, b} (fin n) => (a -> b -> b) -> b -> [n]a -> b
foldr f acc xs = foldl g acc (reverse xs) where g b a = f a b /** * Functional right fold, with strict evaluation of the accumulator value. * The accumulator is reduced to weak head normal form at each step. * * foldr' (-) 0 [1,2,3] = 0 - (1 - (2 - 3)) */
function
foldr
lib
lib/Cryptol.cry
[]
[ "fin", "foldl", "reverse", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
foldr' : {n, a, b} (fin n, Eq b) => (a -> b -> b) -> b -> [n]a -> b
foldr' f acc xs = foldl' g acc (reverse xs) where g b a = f a b /** * Compute the sum of the values in the sequence. */
function
foldr'
lib
lib/Cryptol.cry
[]
[ "Eq", "fin", "foldl'", "reverse", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
sum : {n, a} (fin n, Eq a, Ring a) => [n]a -> a
sum xs = foldl' (+) (fromInteger 0) xs /** * Compute the product of the values in the sequence. */
function
sum
lib
lib/Cryptol.cry
[]
[ "Eq", "Ring", "fin", "foldl'", "fromInteger", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
product : {n, a} (fin n, Eq a, Ring a) => [n]a -> a
product xs = foldl' (*) (fromInteger 1) xs /** * Scan left is like a foldl that also emits the intermediate values. */
function
product
lib
lib/Cryptol.cry
[]
[ "Eq", "Ring", "fin", "foldl'", "fromInteger", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
scanr : {n, a, b} (fin n) => (a -> b -> b) -> b -> [n]a -> [1+n]b
scanr f acc xs = reverse (scanl (\a b -> f b a) acc (reverse xs)) /** * Repeat a value. */
function
scanr
lib
lib/Cryptol.cry
[]
[ "fin", "reverse", "scanl", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
repeat : {n, a} a -> [n]a
repeat x = [ x | _ <- zero : [n] ] /** * 'elem x xs' returns true if x is equal to a value in xs. */
function
repeat
lib
lib/Cryptol.cry
[]
[ "zero" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
elem : {n, a} (fin n, Eq a) => a -> [n]a -> Bit
elem a xs = any (\x -> x == a) xs /** * Create a list of tuples from two lists. */
function
elem
lib
lib/Cryptol.cry
[]
[ "==", "Bit", "Eq", "any", "fin", "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
zip : {n, a, b} [n]a -> [n]b -> [n](a, b)
zip xs ys = [(x,y) | x <- xs | y <- ys] /** * Create a list by applying the function to each pair of elements in the input. */
function
zip
lib
lib/Cryptol.cry
[]
[ "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
zipWith : {n, a, b, c} (a -> b -> c) -> [n]a -> [n]b -> [n]c
zipWith f xs ys = [f x y | x <- xs | y <- ys] /** * Transform a function into uncurried form. */
function
zipWith
lib
lib/Cryptol.cry
[]
[ "xs" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
uncurry : {a, b, c} (a -> b -> c) -> (a, b) -> c
uncurry f = \(a, b) -> f a b /** * Transform a function into curried form. */
function
uncurry
lib
lib/Cryptol.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
curry : {a, b, c} ((a, b) -> c) -> a -> b -> c
curry f = \a b -> f (a, b) /** * Map a function iteratively over a seed value, producing an infinite * list of successive function applications. */
function
curry
lib
lib/Cryptol.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
iterate : {a} (a -> a) -> a -> [inf]a
iterate f z = scanl (\x _ -> f x) z (zero:[inf]())
function
iterate
lib
lib/Cryptol.cry
[]
[ "scanl" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
f === g = \ x -> f x == g x /** * Compare the outputs of two functions for inequality. */
f !== g = \x -> f x != g x // The Cmp class --------------------------------------------------- /** Value types that support equality and ordering comparisons. */
function
f
lib
lib/Cryptol.cry
[]
[ "!=", "!==", "==", "===" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
x >$ y = y <$ x /** * 2's complement signed less-than-or-equal. */
x <=$ y = ~(y <$ x) /** * 2's complement signed greater-than-or-equal. */ x >=$ y = ~(x <$ y) // The Option and Result types ------------------------------------ /** * The 'Option a' type represents an optional value. Every 'Option a' value is * either 'Some' and contains a value of type 'a', or 'None' and does ...
function
x
lib
lib/Cryptol.cry
[]
[ "/\\", "<$", "<=$", ">$", ">=$", "False", "True", "\\/" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
enum Option a = None | Some a deriving (Eq, Cmp, SignedCmp) /** * Values of the 'Result t e' type can either be 'Ok', representing success and * containing a value of type 't', or 'Err', representing error and containing * an error value of type 'e'. Functions can return 'Result' whenever errors are * expected and...
enum Result t e = Ok t | Err e deriving (Eq, Cmp, SignedCmp) // Bit specific operations ---------------------------------------- /** * The constant True. Corresponds to the bit value 1. */
function
enum
lib
lib/Cryptol.cry
[]
[ "SignedCmp" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
a ==> b
= if a then b else True // Bitvector specific operations ---------------------------------- /** * 2's complement signed division. Division rounds toward 0. * Division by 0 is undefined. * * * Satisfies 'x == x %$ y + (x /$ y) * y' for 'y != 0'. */
function
a
lib
lib/Cryptol.cry
[]
[ "==>", "True" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
xs @@ is = [ xs @ i | i <- is ] /** * Reverse index operator. The first argument is a finite sequence. The second * argument is the zero-based index of the element to select, starting from the * end of the sequence. */
xs !! is = [ xs ! i | i <- is ] /** * Update the given sequence with new value at the given index position. * The first argument is a sequence. The second argument is the zero-based * index of the element to update, starting from the front of the sequence. * The third argument is the new element. The return value...
function
xs
lib
lib/Cryptol.cry
[]
[ "!!" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ValidFloat : # -> # -> Prop /** IEEE-754 floating point numbers. */
primitive type
ValidFloat
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
exponent : #, precision : #} ValidFloat exponent precision => Float exponent precision : * /** An abbreviation for common 16-bit floating point numbers. */
primitive type
exponent
lib
lib/Float.cry
[]
[ "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
Float16
= Float 5 11 /** An abbreviation for common 32-bit floating point numbers. */
type
Float16
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
Float32
= Float 8 24 /** An abbreviation for common 64-bit floating point numbers. */
type
Float32
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
Float64
= Float 11 53 /** An abbreviation for common 128-bit floating point numbers. */
type
Float64
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
Float128
= Float 15 113 /** An abbreviation for common 256-bit floating point numbers. */
type
Float128
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
Float256
= Float 19 237 /* ---------------------------------------------------------------------- * Rounding modes (this should be an enumeration type, when we add these) *---------------------------------------------------------------------- */ /** * A 'RoundingMode' is used to specify the precise behavior of some * fl...
type
Float256
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
RoundingMode
= [3] /** Round toward nearest, ties go to even. */
type
RoundingMode
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpNaN : {e,p} ValidFloat e p => Float e p /** Positive infinity. */
primitive
fpNaN
lib
lib/Float.cry
[]
[ "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpPosInf : {e,p} ValidFloat e p => Float e p /** Negative infinity. */
primitive
fpPosInf
lib
lib/Float.cry
[]
[ "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpFromBits : {e,p} ValidFloat e p => [e + p] -> Float e p /** Export a floating point number in IEEE interchange format with layout: (sign : [1]) # (biased_exponent : [e]) # (significand : [p-1]) NaN is represented as: * positive: sign == 0 * quiet with no info: significand == 0b1 # 0 */
primitive
fpFromBits
lib
lib/Float.cry
[]
[ "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpToBits : {e,p} ValidFloat e p => Float e p -> [e + p] /* ---------------------------------------------------------------------- * Predicates * ---------------------------------------------------------------------- */ // Operations in `Cmp` use IEEE reasoning. /** Check if two floating point numbers are repr...
primitive
fpToBits
lib
lib/Float.cry
[]
[ "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
(=.=) : {e,p} ValidFloat e p => Float e p -> Float e p -> Bool
primitive
=.=
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsNaN : {e,p} ValidFloat e p => Float e p -> Bool /** Test if this value is positive or negative infinity. */
primitive
fpIsNaN
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsInf : {e,p} ValidFloat e p => Float e p -> Bool /** Test if this value is positive or negative zero. */
primitive
fpIsInf
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsZero : {e,p} ValidFloat e p => Float e p -> Bool /** Test if this value is negative. */
primitive
fpIsZero
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsNeg : {e,p} ValidFloat e p => Float e p -> Bool /** Test if this value is normal (not NaN, not infinite, not zero, and not subnormal). */
primitive
fpIsNeg
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsNormal : {e,p} ValidFloat e p => Float e p -> Bool /** * Test if this value is subnormal. Subnormal values are nonzero * values with magnitudes smaller than can be represented with the * normal implicit leading bit convention. */
primitive
fpIsNormal
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsSubnormal : {e,p} ValidFloat e p => Float e p -> Bool /* Returns true for numbers that are not an infinity or NaN. */
primitive
fpIsSubnormal
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpAdd : {e,p} ValidFloat e p => RoundingMode -> Float e p -> Float e p -> Float e p /** Subtract floating point numbers using the given rounding mode. */
primitive
fpAdd
lib
lib/Float.cry
[]
[ "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpSub : {e,p} ValidFloat e p => RoundingMode -> Float e p -> Float e p -> Float e p /** Multiply floating point numbers using the given rounding mode. */
primitive
fpSub
lib
lib/Float.cry
[]
[ "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpMul : {e,p} ValidFloat e p => RoundingMode -> Float e p -> Float e p -> Float e p /** Divide floating point numbers using the given rounding mode. */
primitive
fpMul
lib
lib/Float.cry
[]
[ "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpDiv : {e,p} ValidFloat e p => RoundingMode -> Float e p -> Float e p -> Float e p /** * Fused-multiply-add. 'fpFMA r x y z' computes the value '(x*y)+z', * rounding the result according to mode 'r' only after performing both * operations. */
primitive
fpDiv
lib
lib/Float.cry
[]
[ "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpFMA : {e,p} ValidFloat e p => RoundingMode -> Float e p -> Float e p -> Float e p -> Float e p /** * Absolute value of a floating-point value. */
primitive
fpFMA
lib
lib/Float.cry
[]
[ "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpAbs : {e,p} ValidFloat e p => Float e p -> Float e p /** * Square root of a floating-point value. The square root of * a negative value yiels NaN, except that the sqaure root of * '-0.0' is '-0.0'. */
primitive
fpAbs
lib
lib/Float.cry
[]
[ "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpSqrt : {e,p} ValidFloat e p => RoundingMode -> Float e p -> Float e p /* ------------------------------------------------------------ * * Rationals * * ------------------------------------------------------------ */ /** Convert a floating point number to a ra...
primitive
fpSqrt
lib
lib/Float.cry
[]
[ "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpToRational : {e,p} ValidFloat e p => Float e p -> Rational /** Convert a rational to a floating point number, using the given rounding mode, if the number cannot be represented exactly. */
primitive
fpToRational
lib
lib/Float.cry
[]
[ "Rational", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpFromRational : {e,p} ValidFloat e p => RoundingMode -> Rational -> Float e p
primitive
fpFromRational
lib
lib/Float.cry
[]
[ "Rational", "RoundingMode", "ValidFloat" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundNearestEven, rne : RoundingMode
function
roundNearestEven
lib
lib/Float.cry
[]
[ "RoundingMode", "rne" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundNearestAway, rna : RoundingMode
function
roundNearestAway
lib
lib/Float.cry
[]
[ "RoundingMode", "rna" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundPositive, rtp : RoundingMode
function
roundPositive
lib
lib/Float.cry
[]
[ "RoundingMode", "rtp" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundNegative, rtn : RoundingMode
function
roundNegative
lib
lib/Float.cry
[]
[ "RoundingMode", "rtn" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundZero, rtz : RoundingMode
function
roundZero
lib
lib/Float.cry
[]
[ "RoundingMode", "rtz" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpNegInf : {e,p} ValidFloat e p => Float e p
fpNegInf = - fpPosInf /** Positive zero. */
function
fpNegInf
lib
lib/Float.cry
[]
[ "ValidFloat", "fpPosInf" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpPosZero : {e,p} ValidFloat e p => Float e p
fpPosZero = zero /** Negative zero. */
function
fpPosZero
lib
lib/Float.cry
[]
[ "ValidFloat", "zero" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpNegZero : {e,p} ValidFloat e p => Float e p
fpNegZero = - fpPosZero // Binary representations /** A floating point number using the exact bit pattern, in IEEE interchange format with layout: (sign : [1]) # (biased_exponent : [e]) # (significand : [p-1]) */
function
fpNegZero
lib
lib/Float.cry
[]
[ "ValidFloat", "fpPosZero" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
fpIsFinite : {e,p} ValidFloat e p => Float e p -> Bool
fpIsFinite f = ~ (fpIsNaN f \/ fpIsInf f ) /* ---------------------------------------------------------------------- * Arithmetic * ---------------------------------------------------------------------- */ /** Add floating point numbers using the given rounding mode. */
function
fpIsFinite
lib
lib/Float.cry
[]
[ "Bool", "ValidFloat", "\\/", "fpIsInf", "fpIsNaN" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundNearestEven
= 0
function
roundNearestEven
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
rne
= roundNearestEven /** Round toward nearest, ties away from zero. */
function
rne
lib
lib/Float.cry
[]
[ "roundNearestEven" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundNearestAway
= 1
function
roundNearestAway
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
rna
= roundNearestAway /** Round toward positive infinity. */
function
rna
lib
lib/Float.cry
[]
[ "roundNearestAway" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundPositive
= 2
function
roundPositive
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
rtp
= roundPositive /** Round toward negative infinity. */
function
rtp
lib
lib/Float.cry
[]
[ "roundPositive" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundNegative
= 3
function
roundNegative
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
rtn
= roundNegative /** Round toward zero. */
function
rtn
lib
lib/Float.cry
[]
[ "roundNegative" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
roundZero
= 4
function
roundZero
lib
lib/Float.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
rtz
= roundZero /* ---------------------------------------------------------------------- * Constants * ---------------------------------------------------------------------- */ /** Not a number. */
function
rtz
lib
lib/Float.cry
[]
[ "roundZero" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
AffinePoint p
= { x : Z p , y : Z p } /** * The type of points of an elliptic curve in (homogeneous) * projective coordinates. The coefficients are taken from the * prime field 'Z p' with 'p > 3'. These points should be understood as * representatives of equivalence classes of points, where two representatives * 'S' and...
type
AffinePoint
lib
lib/PrimeEC.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ProjectivePoint p
= { x : Z p , y : Z p , z : Z p } /** * 'ec_is_point_affine b S' checks that the supposed affine elliptic curve * point 'S' in fact lies on the curve defined by the curve parameter 'b'. Here, * and throughout this module, we assume the curve parameter 'a' is equal to * '-3'. Precisely, this function chec...
type
ProjectivePoint
lib
lib/PrimeEC.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_double : {p} (prime p, p > 3) => ProjectivePoint p -> ProjectivePoint p /** * Given two projective points 'S' and 'T' where neither is the identity, * compute 'S+T'. If the points are not known to be distinct from the point * at infinity, use 'ec_add' instead. */
primitive
ec_double
lib
lib/PrimeEC.cry
[]
[ "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_add_nonzero : {p} (prime p, p > 3) => ProjectivePoint p -> ProjectivePoint p -> ProjectivePoint p /** * Given a projective point 'S', compute its negation, '-S' */
primitive
ec_add_nonzero
lib
lib/PrimeEC.cry
[]
[ "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_mult : {p} (prime p, p > 3) => Z p -> ProjectivePoint p -> ProjectivePoint p /** * Given a scalar value 'j' and a projective point 'S', and another scalar * value 'k' and point 'T', compute the "twin" scalar multiplication 'jS + kT'. */
primitive
ec_mult
lib
lib/PrimeEC.cry
[]
[ "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_twin_mult : {p} (prime p, p > 3) => Z p -> ProjectivePoint p -> Z p -> ProjectivePoint p -> ProjectivePoint p
primitive
ec_twin_mult
lib
lib/PrimeEC.cry
[]
[ "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_is_point_affine : {p} (prime p, p > 3) => Z p -> AffinePoint p -> Bit
ec_is_point_affine b S = S.y^^2 == S.x^^3 - (3*S.x) + b /** * 'ec_is_nonsingular' checks that the given curve parameter 'b' gives rise to * a non-singular elliptic curve, appropriate for use in ECC. * * Precisely, this checks that '4*a^^3 + 27*b^^2 != 0 mod p'. Here, and * throughout this module, we assume 'a =...
function
ec_is_point_affine
lib
lib/PrimeEC.cry
[]
[ "==", "AffinePoint", "Bit", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_is_nonsingular : {p} (prime p, p > 3) => Z p -> Bit
ec_is_nonsingular b = (fromInteger 4) * a^^3 + (fromInteger 27) * b^^2 != 0 where a = -3 : Z p /** * Returns true if the given point is the identity "point at infinity." * This is true whenever the 'z' coordinate is 0, but one of the 'x' or * 'y' coordinates is nonzero. */
function
ec_is_nonsingular
lib
lib/PrimeEC.cry
[]
[ "!=", "Bit", "fromInteger", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_is_identity : {p} (prime p, p > 3) => ProjectivePoint p -> Bit
ec_is_identity S = S.z == 0 /\ ~(S.x == 0 /\ S.y == 0) /** * Test two projective points for equality, up to the equivalence relation * on projective points. */
function
ec_is_identity
lib
lib/PrimeEC.cry
[]
[ "/\\", "==", "Bit", "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_equal : {p} (prime p, p > 3) => ProjectivePoint p -> ProjectivePoint p -> Bit
ec_equal S T = (S.z == 0 /\ T.z == 0) \/ (S.z != 0 /\ T.z != 0 /\ ec_affinify S == ec_affinify T) /** * Compute a projective representative for the given affine point. */
function
ec_equal
lib
lib/PrimeEC.cry
[]
[ "!=", "/\\", "==", "Bit", "ProjectivePoint", "\\/", "ec_affinify", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_projectify : {p} (prime p, p > 3) => AffinePoint p -> ProjectivePoint p
ec_projectify R = { x = R.x, y = R.y, z = 1 } /** * Compute the affine point corresponding to the given projective point. * This results in an error if the 'z' component of the given point is 0, * in which case there is no corresponding affine point. */
function
ec_projectify
lib
lib/PrimeEC.cry
[]
[ "AffinePoint", "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_affinify : {p} (prime p, p > 3) => ProjectivePoint p -> AffinePoint p
ec_affinify S = if S.z == 0 then error "Cannot affinify the point at infinity" else R where R = {x = lambda^^2 * S.x, y = lambda^^3 * S.y } lambda = recip S.z /** * Coerce an integer modulo 'p' to a bitvector. This will reduce the value * modulo '2^^a' if necessary. */
function
ec_affinify
lib
lib/PrimeEC.cry
[]
[ "==", "AffinePoint", "ProjectivePoint", "error", "prime", "recip" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ZtoBV : {p, a} (fin p, p >= 1, fin a) => Z p -> [a]
ZtoBV x = fromInteger (fromZ x) /** * Coerce a bitvector value to an integer modulo 'p'. This will * reduce the value modulo 'p' if necessary. */
function
ZtoBV
lib
lib/PrimeEC.cry
[]
[ ">=", "fin", "fromInteger", "fromZ" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
BVtoZ : {p, a} (fin p, p >= 1, fin a) => [a] -> Z p
BVtoZ x = fromInteger (toInteger x) /** * Given a projective point 'S', compute '2S = S+S'. */
function
BVtoZ
lib
lib/PrimeEC.cry
[]
[ ">=", "fin", "fromInteger", "toInteger" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_negate : {p} (prime p, p > 3) => ProjectivePoint p -> ProjectivePoint p
ec_negate S = { x = S.x, y = -S.y, z = S.z } /** * Given two projective points 'S' and 'T' compute 'S+T'. */
function
ec_negate
lib
lib/PrimeEC.cry
[]
[ "ProjectivePoint", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_add : {p} (prime p, p > 3) => ProjectivePoint p -> ProjectivePoint p -> ProjectivePoint p
ec_add S T = if S.z == 0 then T | T.z == 0 then S else R where R = ec_add_nonzero S T /** * Given two projective points 'S' and 'T' compute 'S-T'. */
function
ec_add
lib
lib/PrimeEC.cry
[]
[ "==", "ProjectivePoint", "ec_add_nonzero", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
ec_sub : {p} (prime p, p > 3) => ProjectivePoint p -> ProjectivePoint p -> ProjectivePoint p
ec_sub S T = ec_add S U where U = { x = T.x, y = -T.y, z = T.z } /** * Given a scalar value 'k' and a projective point 'S', compute the * scalar multiplication 'kS'. */
function
ec_sub
lib
lib/PrimeEC.cry
[]
[ "ProjectivePoint", "ec_add", "prime" ]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
AES128
= 4 /** * Key schedule parameter setting for AES-192 */
type
AES128
lib
lib/SuiteB.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb
AES192
= 6 /** * Key schedule parameter setting for AES-256 */
type
AES192
lib
lib/SuiteB.cry
[]
[]
https://github.com/GaloisInc/cryptol
a50cac6eb2c30a79503814f423f375f9476aaceb