mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-09-11 22:17:18 +03:00
Miscellaneous edits to the book.
This commit is contained in:
parent
891b7fe914
commit
1eaabf87aa
@ -411,15 +411,15 @@ Write a function
|
||||
gf28Inverse : GF28 -> GF28
|
||||
\end{code}
|
||||
to compute the multiplicative inverse of a given element by raising it
|
||||
to the power $254$. Note that {\tt gf28Inverse} must map $0$ to
|
||||
$0$. Do you have to do anything special to make sure this happens?
|
||||
to the power \texttt{254}. Note that {\tt gf28Inverse} must map \texttt{0} to
|
||||
\texttt{0}. Do you have to do anything special to make sure this happens?
|
||||
\end{Exercise}
|
||||
\begin{Answer}\ansref{ex:gfmi:01}
|
||||
\begin{code}
|
||||
gf28Inverse x = gf28Pow (x, 254)
|
||||
\end{code}
|
||||
We do not have to do anything special about $0$, since our {\tt
|
||||
gf28Inverse} function yields $0$ in that case:
|
||||
We do not have to do anything special about \texttt{0}, since our
|
||||
\texttt{gf28Inverse} function yields \texttt{0} in that case:
|
||||
\begin{Verbatim}
|
||||
Cryptol> gf28Inverse 0
|
||||
0x00
|
||||
@ -429,10 +429,10 @@ We do not have to do anything special about $0$, since our {\tt
|
||||
\begin{Exercise}\label{ex:gfmi:1}
|
||||
Write and prove a property {\tt gf28InverseCorrect}, ensuring that
|
||||
{\tt gf28Inverse x} does indeed return the multiplicative inverse of
|
||||
{\tt x}. Do you have to do anything special when {\tt x} is $0$?
|
||||
{\tt x}. Do you have to do anything special when {\tt x} is \texttt{0}?
|
||||
\end{Exercise}
|
||||
\begin{Answer}\ansref{ex:gfmi:1}
|
||||
Since $0$ does not have a multiplicative inverse, we have to write a
|
||||
Since \texttt{0} does not have a multiplicative inverse, we have to write a
|
||||
conditional property:
|
||||
\begin{code}
|
||||
property gf28InverseCorrect x =
|
||||
@ -726,7 +726,7 @@ We have:
|
||||
Q.E.D.
|
||||
AES> :check DPDist : [10]GF28 -> [10]GF28 -> [10]GF28 -> Bit
|
||||
Using random testing.
|
||||
passed 1000 tests.
|
||||
Passed 1000 tests.
|
||||
\end{Verbatim}
|
||||
\todo[inline]{Revisit after \ticket{207} is addressed.}
|
||||
% \verb+[Coverage: 0.00%. (1000/17668470647783843295832975007429185158274838968756189 ...58121606201292619776)]+
|
||||
|
@ -40,7 +40,7 @@ interchangeable scramblers, and a fixed reflector.
|
||||
Enigma essentially implements a polyalphabetic substitution cipher
|
||||
(\autoref{section:subst})\indPolyAlphSubst, consisting of a number
|
||||
of rotating units that jumble up the alphabet. The first component is
|
||||
the so called plugboard ({\em steckerbrett} in
|
||||
the so called plugboard (\textit{Steckerbrett} in
|
||||
German)\indEnigmaPlugboard. In the original Enigma, the plugboard
|
||||
provided a means of interchanging 6 pairs of letters. For instance,
|
||||
the plugboard could be set-up so that pressing the {\tt B} key would
|
||||
@ -116,7 +116,7 @@ locations:\footnote{The function {\tt elem} was defined in \exerciseref{ex:recfu
|
||||
\begin{code}
|
||||
mkRotor : {n} (fin n) => (Permutation, String n) -> Rotor
|
||||
mkRotor (perm, notchLocations) = [ (p, elem (p, notchLocations))
|
||||
| p <- perm
|
||||
| p <- perm
|
||||
]
|
||||
\end{code}
|
||||
\todo[inline]{A diagram here would be really useful, especially one
|
||||
@ -568,10 +568,10 @@ well (compare this code to {\tt joinRotors}, defined in
|
||||
\begin{code}
|
||||
backSignal : {n} (fin n) => ([n]Rotor, Char) -> Char
|
||||
backSignal (rotors, inputChar) = cs ! 0
|
||||
where
|
||||
where
|
||||
cs = [inputChar] # [ substBwd ([ p | (p, _) <- r ], c)
|
||||
| r <- reverse rotors
|
||||
| c <- cs
|
||||
| r <- reverse rotors
|
||||
| c <- cs
|
||||
]
|
||||
\end{code}
|
||||
Note that we explicitly reverse the rotors in the definition of {\tt
|
||||
|
@ -80,7 +80,7 @@ numbers corresponding to the letters.
|
||||
\begin{Exercise}\label{ex:helloWorld2}
|
||||
Try the above exercise, after first issuing the following command:
|
||||
\begin{Verbatim}
|
||||
Cryptol> :set ascii=on
|
||||
Cryptol> :set ascii=on
|
||||
\end{Verbatim}
|
||||
Why do you think this is not the default behavior?\indSettingASCII
|
||||
\end{Exercise}
|
||||
@ -166,9 +166,9 @@ considered good practice.\indSignature
|
||||
|
||||
\paragraph*{Polymorphism}
|
||||
Cryptol functions can be polymorphic, which means they can operate on
|
||||
many different types. Beware that the type which Cryptol infers might
|
||||
many different types. Beware that the type that Cryptol infers might
|
||||
be too polymorphic, so it is good practice to write your signatures,
|
||||
or at least check what Cryptol inferred is what you had in
|
||||
or at least check that what Cryptol inferred is what you had in
|
||||
mind.\indPolymorphism\indSignature
|
||||
|
||||
\paragraph*{Module system}
|
||||
|
@ -63,9 +63,9 @@ considered good practice.\indSignature
|
||||
|
||||
\paragraph*{Polymorphism}
|
||||
Cryptol functions can be polymorphic, which means they can operate on
|
||||
many different types. Be aware that the type which Cryptol infers might
|
||||
many different types. Be aware that the type that Cryptol infers might
|
||||
be too polymorphic, so it is good practice to write your signatures,
|
||||
or at least check what Cryptol inferred is what you had in
|
||||
or at least check that what Cryptol inferred is what you had in
|
||||
mind.\indPolymorphism\indSignature
|
||||
|
||||
\paragraph*{Module system}
|
||||
@ -100,7 +100,7 @@ You can feed \LaTeX~files to Cryptol (i.e., files with extension
|
||||
\texttt{.tex}). Cryptol will look for \verb|\begin{code}| and
|
||||
\verb|\end{code}| marks to extract Cryptol code. Everything else
|
||||
will be comments as far as Cryptol is concerned. In fact, the book
|
||||
you are reading is a Literate Cryptol program.\indLiterateProgramming
|
||||
you are reading is a literate Cryptol program.\indLiterateProgramming
|
||||
|
||||
\todo[inline]{Discuss Cryptol support for literate Markdown. Use ticks to
|
||||
delimit code blocks in Markdown layout. Talk with Trevor.}
|
||||
@ -203,8 +203,8 @@ We want to write: ``You set your favorite editor by :set
|
||||
editor=/path/to/editor.''}
|
||||
|
||||
\paragraph*{Running shell commands}
|
||||
You can run Unix shell commands from within Cryptol like this: {\tt :!
|
||||
cat test.cry}.\indCmdShell
|
||||
You can run Unix shell commands from within Cryptol like this:
|
||||
\texttt{:!~cat test.cry}.\indCmdShell
|
||||
|
||||
\paragraph*{Changing working directory}
|
||||
You can change the current working directory of Cryptol like this:
|
||||
@ -240,8 +240,8 @@ The \texttt{:sat} command uses an external SAT solver to attempt to
|
||||
find a satisfying assignment to a property. See~\autoref{sec:sat} for
|
||||
more detailed information.
|
||||
|
||||
\paragraph*{Type specialization}
|
||||
Discuss \texttt{:debug\_specialize}. \todo[inline]{Dylan?}
|
||||
% \paragraph*{Type specialization}
|
||||
% Discuss \texttt{:debug\_specialize}. \todo[inline]{Dylan?}
|
||||
|
||||
%=====================================================================
|
||||
%\section{Using Cryptol: The Big Picture}
|
||||
|
Loading…
Reference in New Issue
Block a user