Cryptol stream equation/synonym/class/module
Download learning reference materials: https://cryptol.net/documentation.html
Flow equation
-
For the shift feedback register in the figure below, the description code is as follows:
as = [0x3F, 0xE2, 0x65, 0xCA] # new where new = [ a ^ b ^ c | a <- as | b <- drop`{ 1} as | c <- drop`{ 3} as ]
Synonym
-
Similar to the definition of typedef in C language, but more powerful and can be parameterized;
type Word8 = [8] type CheckedWord = (Word8, Bit) type Point a = { x : [a], y : [a]}
Class//Class in Cpp is not a concept
-
Used to describe the behavior shared by multiple types, such as == to compare any single type and return a Boolean value;
Cryptol> :t (==) (==) : { a} (Eq a) => a -> a -> Bit
Program structure with module
-
Similar to the concept of Verilog's module, a file can only have one module, and the module and the file name are the same;
-
The first line of non-commented code in the file should be:
module utilities where
-
If you want to use other modules, you can use the following definitions, and the corresponding files will be searched in the current directory:
import utilities
-
Private variables, similar to Cpp, prevent the data of your own module from being accessed;
private internalDouble x = x + x exportedDouble = x * 2
It's hard to understand by just looking at the description document, the next step is to look at it in conjunction with the code!