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 |
|---|---|---|---|---|---|---|---|---|---|---|
E : [K] -> [128] -> [128] | function | E | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
encrypt :
{n} (2^^39 - 256 >= n) =>
{ key : [K], iv : [IV], aad : [AAD], pt : [n] } -> { ct : [n], tag : [T] } | encrypt input = { ct = C, tag = T }
where (C,T) = enc_dec input.key input.iv input.aad input.pt | function | encrypt | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
">=",
"enc_dec"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
decrypt :
{n} (2^^39 - 256 >= n) =>
{ key : [K], iv : [IV], aad : [AAD], ct : [n], tag : [T] } ->
{ valid : Bool, pt : [n] } | decrypt input = if input.tag == T then { valid = True, pt = P }
else { valid = False, pt = 0 }
where (P,T) = enc_dec input.key input.iv input.aad input.ct
/**
The basic functionality between encryption and decryption.
In the case of decryption, the plain text is only valid if the ... | function | decrypt | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
"==",
">=",
"enc_dec"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
enc_dec :
{n} ((2^^39 - 256) >= n) => [K] -> [IV] -> [AAD] -> [n] -> ([n], [T]) | enc_dec K IV A P = (C,T)
where
H = E K 0
Y0 = ifWidth`{96} IV (\IV96 -> IV96 # 1)
(GHASH H [] IV)
Ys = [Y0] # [ y+1 | y <- Ys ]
Cs = [ p ^ E K y | p <- blockify P | y <- drop`{1} Ys ]
C = unblockify Cs
T = take (GHASH H A C ^ E K Y0)
/** Section 2.3, equation (2) */ | function | enc_dec | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
">=",
"GHASH",
"IV",
"blockify",
"take",
"unblockify"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
GHASH : {C,A} (64 >= width C, 64 >= width A) => [128] -> [A] -> [C] -> [128] | GHASH H A C = step (XS ! 0) (wa # wc)
where
wa = `A : [64]
wc = `C : [64]
XS = [0] # [ step X' B | X' <- XS | B <- blockify A # blockify C ]
step x b = mult (x ^ b) H
/** Section 2.5, multiplication in GF(2^^128)
This is simple polynomial multipliation and reduction in Cryptol.
Somewhat oddly, when thin... | function | GHASH | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
">=",
"blockify",
"mult",
"width"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
mult : [128] -> [128] -> [128] | mult X Y = reverse (pmod (pmult (reverse X) (reverse Y)) irred)
where irred = <| 1 + x + x^^2 + x^^7 + x^^128 |>
/** Create blocks as described in the spec, first paragraph of Section 2.3.
Basically we split into 128-bit chunk and pad the last one with 0. */ | function | mult | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
"pmod",
"pmult",
"reverse"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
blockify : {n} (fin n) => [n] -> [n /^ 128][128] | blockify msg = split (msg # 0)
/** Join back the blocks, dropping any additional padding. */ | function | blockify | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
"fin",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
unblockify : {n} (fin n) => [n /^ 128][128] -> [n] | unblockify ms = take (join ms) | function | unblockify | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
"fin",
"join",
"take"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
ifWidth : {w,n,a} (fin n, fin w) => [n] -> ([w] -> a) -> a -> a | ifWidth thing yep nope = if `w == (`n : [max (width w) (width n)])
then yep (take (thing # (zero : [inf])))
else nope | function | ifWidth | examples.param_modules.Common | examples/param_modules/Common/GCM.cry | [] | [
"==",
"fin",
"take",
"width",
"zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
w : # | type | w | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(fin w, w >= 1)
/** The number of iterations in the hash computation
(i.e. the number of words in K) */ | type constraint | fin | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
j : # | type | j | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(fin j, j >= 17) | type constraint | fin | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
block_size | = 16 * w | type | block_size | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
num_blocks L | = (L+1+2*w) /^ block_size | type | num_blocks | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"block_size"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
padded_size L | = num_blocks L * block_size
/** (4.1) (w==32), (4.2) (w==32), (4.8) (w==64) */ | type | padded_size | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"block_size",
"num_blocks"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
H0 : [8][w] | function | H0 | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
K : [j][w]
/* FIPS 180-4 defines lowercase and uppercase
(respective to the Greek alphabet) sigma functions for SHA-256 and SHA-512.
(4.4)-(4.7) SHA-224, SHA-256 (w==32)
(4.10)-(4.13) SHA-384, SHA-512, SHA-512/224, SHA-512/256 (w==64) */ | function | K | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
SIGMA_0 : [w] -> [w] | function | SIGMA_0 | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
SIGMA_1 : [w] -> [w] | function | SIGMA_1 | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
sigma_0 : [w] -> [w] | function | sigma_0 | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
sigma_1 : [w] -> [w] | function | sigma_1 | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
sha : {L} (2 * w >= width L) => [L] -> [8 * w] | sha M = join (SHA_2_Common' [ split x | x <- parse`{num_blocks L} (pad`{L} M) ]) | function | sha | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
">=",
"SHA_2_Common'",
"join",
"num_blocks",
"split",
"width"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Ch : [w] -> [w] -> [w] -> [w] | Ch x y z = (x && y) ^ (~x && z)
/** (4.1) (w==32), (4.3) (w==32), (4.9) (w==64) */ | function | Ch | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"&&"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Maj : [w] -> [w] -> [w] -> [w] | Maj x y z = (x && y) ^ (x && z) ^ (y && z)
/**
5.1 Padding the Message
5.1.1 SHA-1, SHA-224 and SHA-256 (w==32)
5.1.2 SHA-384, SHA-512, SHA-512/224 and SHA-512/256 (w==64)
The constraint ensure that the message size, `L`, fits within a
(2 * w)-bit word (consistent w/ Figure 1)
*/ | function | Maj | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"&&"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
pad : {L} (2 * w >= width L) => [L] -> [padded_size L] | pad M = M # 0b1 # zero # (`L : [2*w])
/**
5.2 Parsing the Message
5.2.1 SHA-1, SHA-224 and SHA-256 (w==32)
5.2.2 SHA-384, SHA-512, SHA-512/224 and SHA-512/256 (w==64)
*/ | function | pad | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
">=",
"width",
"zero"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
parse : {m} [m * block_size] -> [m][block_size] | parse = split
/**
SHA-256 and SHA-512 (and their respective derivatives) use a similar
message schedule that can be expressed in the same way relative to their
respective sigma functions.
6.2.2 SHA-256 Hash Computation (w==32, j=64)
6.4.2 SHA-512 Hash Computation (w==64, j=80)
*/ | function | parse | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
messageSchedule_Common : [16][w] -> [j][w] | messageSchedule_Common Mi = take W
where
W : [inf][_]
W = Mi # [ w1 + sigma_0 w2 + w3 + sigma_1 w4
| w1 <- W
| w2 <- drop`{1} W
| w3 <- drop`{9} W
| w4 <- drop`{14} W
]
/**
Amazon S2N's SHA-256 specification includes a compression routin... | function | messageSchedule_Common | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"sigma_0",
"sigma_1",
"take"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
compress_Common : [8][w] -> [j][w] -> [8][w] | compress_Common H W =
// XXX: This whole definitions looks like it might be simplifiable.
[ (as ! 0) + (H @ 0),
(bs ! 0) + (H @ 1),
(cs ! 0) + (H @ 2),
(ds ! 0) + (H @ 3),
(es ! 0) + (H @ 4),
(fs ! 0) + (H @ 5),
(gs ! 0) + (H @ 6),
(hs ! 0) + (H @ 7)
]
where
... | function | compress_Common | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"Ch",
"Maj",
"SIGMA_0",
"SIGMA_1",
"t1",
"t2"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
processBlock_Common : [8][w] -> [16][w] -> [8][w] | processBlock_Common H Mi = compress_Common H (messageSchedule_Common Mi) | function | processBlock_Common | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"compress_Common",
"messageSchedule_Common"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
SHA_2_Common' : {L} (fin L) => [L][16][w] -> [8][w] | SHA_2_Common' blocks = hash ! 0
where
hash = [H0] # [ processBlock_Common h b | h <- hash | b <- blocks] | function | SHA_2_Common' | examples.param_modules.Common | examples/param_modules/Common/SHA.cry | [] | [
"fin",
"processBlock_Common"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
AES128 | = SB::AES128
/**
* Key schedule parameter setting for AES-192
*/ | type | AES128 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
AES192 | = SB::AES192
/**
* Key schedule parameter setting for AES-256
*/ | type | AES192 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
AES256 | = SB::AES256
/**
* Element of an AES key schedule for use in a particular round
*/ | type | AES256 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
AESRoundKey | = SB::AESRoundKey
/**
* Expanded encryption key schedule for AES
*/ | type | AESRoundKey | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
AESEncryptKeySchedule k | = SB::AESEncryptKeySchedule k
/**
* Expanded decryption key schedule for AES
*/ | type | AESEncryptKeySchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
AESDecryptKeySchedule k | = SB::AESDecryptKeySchedule k
/**
* Encryption key expansion for AES-128.
* See FIPS 197, section 5.2.
*/ | type | AESDecryptKeySchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes128EncryptSchedule : [128] -> AESEncryptKeySchedule AES128 | aes128EncryptSchedule =
if aesniSupported
then \key -> aesniExpandEncrypt128 (split key)
else SB::aes128EncryptSchedule
/**
* Decryption key expansion for AES-128, for use in the "equivalent inverse cypher".
* See FIPS 197, sections 5.2 and 5.3.5.
*/ | function | aes128EncryptSchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES128",
"AESEncryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes128DecryptSchedule : [128] -> AESDecryptKeySchedule AES128 | aes128DecryptSchedule =
if aesniSupported
then \key -> aesniExpandDecrypt128 (split key)
else SB::aes128DecryptSchedule
/**
* Encryption and decryption key schedules for AES-128.
* If you will need both schedules, it is slightly more efficient
* to call this function than to compute the two schedules sepa... | function | aes128DecryptSchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES128",
"AESDecryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes128Schedules : [128] -> (AESEncryptKeySchedule AES128, AESDecryptKeySchedule AES128) | aes128Schedules =
if aesniSupported
then \key -> aesniExpandEncryptDecrypt128 (split key)
else SB::aes128Schedules
/**
* Encryption key expansion for AES-192.
* See FIPS 197, section 5.2.
*/ | function | aes128Schedules | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES128",
"AESDecryptKeySchedule",
"AESEncryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes192EncryptSchedule : [192] -> AESEncryptKeySchedule AES192 | aes192EncryptSchedule =
if aesniSupported
then \key -> aesniExpandEncrypt192 (split key)
else SB::aes192EncryptSchedule
/**
* Decryption key expansion for AES-192, for use in the "equivalent inverse cypher".
* See FIPS 197, sections 5.2 and 5.3.5.
*/ | function | aes192EncryptSchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES192",
"AESEncryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes192DecryptSchedule : [192] -> AESDecryptKeySchedule AES192 | aes192DecryptSchedule =
if aesniSupported
then \key -> aesniExpandDecrypt192 (split key)
else SB::aes192DecryptSchedule
/**
* Encryption and decryption key schedules for AES-192.
* If you will need both schedules, it is slightly more efficient
* to call this function than to compute the two schedules sepa... | function | aes192DecryptSchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES192",
"AESDecryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes192Schedules : [192] -> (AESEncryptKeySchedule AES192, AESDecryptKeySchedule AES192) | aes192Schedules =
if aesniSupported
then \key -> aesniExpandEncryptDecrypt192 (split key)
else SB::aes192Schedules
/**
* Encryption key expansion for AES-256.
* See FIPS 197, section 5.2
*/ | function | aes192Schedules | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES192",
"AESDecryptKeySchedule",
"AESEncryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes256EncryptSchedule : [256] -> AESEncryptKeySchedule AES256 | aes256EncryptSchedule =
if aesniSupported
then \key -> aesniExpandEncrypt256 (split key)
else SB::aes256EncryptSchedule
/**
* Decryption key expansion for AES-256, for use in the "equivalent inverse cypher".
* See FIPS 197, sections 5.2 and 5.3.5.
*/ | function | aes256EncryptSchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES256",
"AESEncryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes256DecryptSchedule : [256] -> AESDecryptKeySchedule AES256 | aes256DecryptSchedule =
if aesniSupported
then \key -> aesniExpandDecrypt256 (split key)
else SB::aes256DecryptSchedule
/**
* Encryption and decryption key schedules for AES-256.
* If you will need both schedules, it is slightly more efficient
* to call this function than to compute the two schedules sepa... | function | aes256DecryptSchedule | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES256",
"AESDecryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aes256Schedules : [256] -> (AESEncryptKeySchedule AES256, AESDecryptKeySchedule AES256) | aes256Schedules =
if aesniSupported
then \key -> aesniExpandEncryptDecrypt256 (split key)
else SB::aes256Schedules
/**
* AES block encryption algorithm.
* See FIPS 197, section 5.1.
*/ | function | aes256Schedules | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AES256",
"AESDecryptKeySchedule",
"AESEncryptKeySchedule",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aesEncryptBlock : {k} (fin k) => AESEncryptKeySchedule k -> [128] -> [128] | aesEncryptBlock =
if aesniSupported
then \schedule plaintext -> join (aesniEncryptBlock schedule (split plaintext))
else SB::aesEncryptBlock
/**
* AES block decryption algorithm, via the "equivalent inverse cypher".
* See FIPS 197, section 5.3.5.
*/ | function | aesEncryptBlock | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AESEncryptKeySchedule",
"fin",
"join",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
aesDecryptBlock : {k} (fin k) => AESDecryptKeySchedule k -> [128] -> [128] | aesDecryptBlock =
if aesniSupported
then \schedule ciphertext -> join (aesniDecryptBlock schedule (split ciphertext))
else SB::aesDecryptBlock | function | aesDecryptBlock | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [
"AESDecryptKeySchedule",
"fin",
"join",
"split"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sha224 | = SB::sha224
/**
* The SHA-256 secure hash algorithm. See FIPS 180-4, section 6.2.2.
*/ | function | sha224 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sha256 | = SB::sha256
/**
* The SHA-384 secure hash algorithm. See FIPS 180-4, section 6.5.
*/ | function | sha256 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sha384 | = SB::sha384
/**
* The SHA-512 secure hash algorithm. See FIPS 180-4, section 6.4.
*/ | function | sha384 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
sha512 | = SB::sha512 | function | sha512 | examples.SuiteB_FFI | examples/SuiteB_FFI/SuiteB_FFI.cry | [
"SuiteB"
] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Array : * -> * -> * | primitive type | Array | lib | lib/Array.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayConstant : {a, b} b -> (Array a b) | primitive | arrayConstant | lib | lib/Array.cry | [] | [
"Array"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayLookup : {a, b} (Array a b) -> a -> b | primitive | arrayLookup | lib | lib/Array.cry | [] | [
"Array"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayUpdate : {a, b} (Array a b) -> a -> b -> (Array a b) | primitive | arrayUpdate | lib | lib/Array.cry | [] | [
"Array"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayEq : {n, a} (Array [n] a) -> (Array [n] a) -> Bool
/**
* Copy elements from the source array to the destination array.
*
* 'arrayCopy dest_arr dest_idx src_arr src_idx len' copies the
* elements from 'src_arr' at indices '[src_idx ..< (src_idx + len)]' into
* 'dest_arr' at indices '[dest_idx ..< (dest_idx + ... | primitive | arrayEq | lib | lib/Array.cry | [] | [
"Array",
"Bool"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayCopy : {n, a} (fin n) => (Array [n] a) -> [n] -> (Array [n] a) -> [n] -> [n] -> (Array [n] a)
/**
* Set elements of the given array.
*
* 'arraySet' arr idx val len' sets the elements of 'arr' at indices
* '[idx ..< (idx + len)]' to 'val'.
*
* The result is undefined if 'idx + len' wraps around.
*/ | primitive | arrayCopy | lib | lib/Array.cry | [] | [
"Array",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arraySet : {n, a} (fin n) => (Array [n] a) -> [n] -> a -> [n] -> (Array [n] a)
/**
* Check whether the lhs array and rhs array are equal at a range of
* indices.
*
* 'arrayRangeEqual sym lhs_arr lhs_idx rhs_arr rhs_idx len' checks whether
* the elements of 'lhs_arr' at indices '[lhs_idx ..< (lhs_idx + len)]' and
... | primitive | arraySet | lib | lib/Array.cry | [] | [
"Array",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayRangeEqual : {n, a} (fin n) => (Array [n] a) -> [n] -> (Array [n] a) -> [n] -> [n] -> Bool | primitive | arrayRangeEqual | lib | lib/Array.cry | [] | [
"Array",
"Bool",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
arrayRangeLookup : {a, b, n} (Integral a, fin n, LiteralLessThan n a) => (Array a b) -> a -> [n]b | arrayRangeLookup arr idx = res
where
res @ i = arrayLookup arr (idx + i) | function | arrayRangeLookup | lib | lib/Array.cry | [] | [
"Array",
"Integral",
"LiteralLessThan",
"arrayLookup",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
arrayRangeUpdate : {a, b, n} (Integral a, fin n, LiteralLessThan n a) => (Array a b) -> a -> [n]b -> (Array a b) | arrayRangeUpdate arr idx vals = arrs ! 0
where
arrs = [arr] # [ arrayUpdate acc (idx + i) val | acc <- arrs | i <- [0 ..< n] | val <- vals ] | function | arrayRangeUpdate | lib | lib/Array.cry | [] | [
"Array",
"Integral",
"LiteralLessThan",
"arrayUpdate",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Bit : *
/** The type of unbounded integers. */ | primitive type | Bit | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Integer : *
/**
* 'Z n' is the type of integers, modulo 'n'.
*
* The values of 'Z n' may be thought of as equivalence
* classes of integers according to the equivalence
* 'x ~ y' iff 'n' divides 'x - y'. 'Z n' naturally
* forms a ring, but does not support integral division
* or indexing.
*
* However, you ma... | primitive type | Integer | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
n : #} (fin n, n >= 1) => Z n : *
/**
* 'Rational' is the type of rational numbers.
* Rational numbers form a Field (and thus a Ring).
*
* The 'ratio' operation may be used to directly create
* rational values from as a ratio of integers, or
* the 'fromInteger' method and the field operations
* can be used.
*/ | primitive type | n | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Rational : * | primitive type | Rational | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Bool | = Bit | type | Bool | lib | lib/Cryptol.cry | [] | [
"Bit"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Word n | = [n] | type | Word | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
Char | = [8] | type | Char | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
String n | = [n]Char
// Numeric operators and constraints ----------------------------------------------
/** A numeric type representing infinity. */ | type | String | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
inf : #
/** Assert that two numeric types are equal. */ | primitive type | inf | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(==) : # -> # -> Prop
/** Assert that two numeric types are different. */ | primitive type | == | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(!=) : # -> # -> Prop
/** Assert that the first numeric type is larger than, or equal to the second.*/ | primitive type | != | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(>=) : # -> # -> Prop
/** Assert that a numeric type is a proper natural number (not 'inf'). */ | primitive type | >= | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fin : # -> Prop
/** Assert that a numeric type is a prime number. */ | primitive type | fin | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
prime : # -> Prop
/** Add numeric types. */ | primitive type | prime | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(+) : # -> # -> #
/** Multiply numeric types. */ | primitive type | + | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(*) : # -> # -> #
/** Subtract numeric types. */ | primitive type | * | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
m : #, n : # }
(fin n, m >= n) =>
m - n : #
/** Divide numeric types, rounding down. */ | primitive type | m | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
m : #, n : # }
(fin m, n >= 1) =>
m / n : #
/** Remainder of numeric type division. */ | primitive type | m | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
m : #, n : # }
(fin m, n >= 1) =>
m % n : #
/** Exponentiate numeric types. */ | primitive type | m | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
(^^) : # -> # -> #
/** The number of bits required to represent the value of a numeric type. */ | primitive type | ^^ | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
width : # -> #
/**
* The ceiling of the base-2 logarithm of a numeric type.
* We define 'lg2 n = width (n - 1)' for nonzero n, and 'lg2 0 = 0'.
*/ | primitive type | width | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
lg2 n | = width (max n 1 - 1)
/** The smaller of two numeric types. */ | type | lg2 | lib | lib/Cryptol.cry | [] | [
"max",
"width"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | |
min : # -> # -> #
/** The larger of two numeric types. */ | primitive type | min | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
max : # -> # -> #
/** Divide numeric types, rounding up. */ | primitive type | max | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
m : #, n : # }
(fin n, n >= 1) =>
m /^ n : #
/** How much we need to add to make a proper multiple of the second argument. */ | primitive type | m | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
m : #, n : # }
(fin n, n >= 1) =>
m %^ n : #
/** The length of an enumeration. */ | primitive type | m | lib | lib/Cryptol.cry | [] | [
">=",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
start : #, next : #, last : # }
(fin start, fin next, fin last, start != next) =>
lengthFromThenTo start next last : #
/**
* Assert that the first numeric type is less than or equal to the second.
*/ | primitive type | start | lib | lib/Cryptol.cry | [] | [
"!=",
"fin",
"last"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
i <= j = (j >= i)
/**
* Assert that the first numeric type is greater than the second.
*/ | type constraint | i | lib | lib/Cryptol.cry | [] | [
"<=",
">="
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
i > j = i >= j + 1
/**
* Assert that the first numeric type is less than the second.
*/ | type constraint | i | lib | lib/Cryptol.cry | [] | [
">="
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
i < j = j >= i + 1
// The Literal class ----------------------------------------------------
/** 'Literal n a' asserts that type 'a' contains the number 'n'. */ | type constraint | i | lib | lib/Cryptol.cry | [] | [
">="
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
Literal : # -> * -> Prop
/**
* 'LiteralLessThan n a' asserts that the type 'a' contains all the
* natural numbers strictly below 'n'. Note that we may have 'n = inf',
* in which case the type 'a' must be unbounded.
*/ | primitive type | Literal | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
LiteralLessThan : # -> * -> Prop
/**
* The value corresponding to a numeric type.
*/ | primitive type | LiteralLessThan | lib | lib/Cryptol.cry | [] | [] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
number : {val, rep} Literal val rep => rep
/**
* An alternative name for 'number', present for backward compatibility.
*/ | primitive | number | lib | lib/Cryptol.cry | [] | [
"Literal"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromTo : {first, last, a}
(fin last, last >= first, Literal last a) =>
[1 + (last - first)]a
/**
* A possibly infinite sequence counting up from 'first' up to (but not including) 'bound'.
*
* '[ x ..< y ]' is syntactic sugar for 'fromToLessThan`{first=x,bound=y}'.
*
* Note that if 'first' = 'bound' then the s... | primitive | fromTo | lib | lib/Cryptol.cry | [] | [
">=",
"Literal",
"fin",
"first",
"last"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromToLessThan :
{first, bound, a} (fin first, bound >= first, LiteralLessThan bound a) =>
[bound - first]a
/**
* A finite sequence counting up from 'first' to 'last' by 'stride'.
* Note that 'last' will only be an element of the enumeration if
* 'stride' divides 'last - first' evenly.
*
* '[x .. y by n]' is ... | primitive | fromToLessThan | lib | lib/Cryptol.cry | [] | [
">=",
"LiteralLessThan",
"fin"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromToBy : {first, last, stride, a}
(fin last, fin stride, stride >= 1, last >= first, Literal last a) =>
[1 + (last - first)/stride]a
/**
* A finite sequence counting from 'first' up to (but not including) 'bound'
* by 'stride'. Note that if 'first = bound' then the sequence will
* be empty. If 'bound = inf'... | primitive | fromToBy | lib | lib/Cryptol.cry | [] | [
">=",
"Literal",
"fin",
"first",
"last"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromToByLessThan : {first, bound, stride, a}
(fin first, fin stride, stride >= 1, bound >= first, LiteralLessThan bound a) =>
[(bound - first)/^stride]a
/**
* A finite sequence counting from 'first' down to 'last' by 'stride'.
* Note that 'last' will only be an element of the enumeration if
* 'stride' divides '... | primitive | fromToByLessThan | lib | lib/Cryptol.cry | [] | [
">=",
"LiteralLessThan",
"fin",
"first"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb | ||
fromToDownBy : {first, last, stride, a}
(fin first, fin stride, stride >= 1, first >= last, Literal first a) =>
[1 + (first - last)/stride]a
/**
* A finite sequence counting from 'first' down to (but not including)
* 'bound' by 'stride'.
*
* '[x ..> y down by n]' is syntactic sugar for
* 'fromToDownByGreaterT... | primitive | fromToDownBy | lib | lib/Cryptol.cry | [] | [
">=",
"Literal",
"fin",
"first",
"last"
] | https://github.com/GaloisInc/cryptol | a50cac6eb2c30a79503814f423f375f9476aaceb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.