-
Notifications
You must be signed in to change notification settings - Fork 157
/
crypto-details.tex
126 lines (109 loc) · 7.81 KB
/
crypto-details.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
\section{Cryptographic Details}
\label{sec:crypto-details}
\subsection{Warning About Re-serialization}
It is a bad security practice to check signatures or hashes on re-serialized data,
the original bytes must be preserved.
\subsection{Hashing}
We present the (informal) properties of cryptographically safe hash functions:
\begin{description}
\item[Preimage resistance] It should be hard to find a message with a given hash value.
\item[Second preimage resistance] Given one message, it should be hard to find another message with the same hash value.
\item[Collision resistance] It should be hard to find two messages with the same hash value.
\end{description}
\noindent In practice, several cryptographic protocols use hash functions as random oracles.
However, the properties of our scheme do not depend on it.
The hashing algorithm we use for all verification keys and multi-signature scripts is BLAKE2b-224\footnote{Note that for the signature
and verification algorithms, as well as the proving and verification algorithms of VRFs, we use the hash function as defined in the IETF standard (see Section~\ref{sec:app-addresses} and Section~\ref{sec:app-vrf}).}.
Explicitly, this is the payment and stake credentials (Figure~\ref{fig:defs:addresses}),
the genesis keys and their delegates (Figure~\ref{fig:ts-types:pp-update}),
stake pool verification keys (Figure~\ref{fig:delegation-transitions}),
and VRF verification keys (Figure~\ref{fig:delegation-defs}).
The only property we require of this hash function is that of Second Preimage resistance. Given the hash of verification key or multi-signature script, it should be hard to find a different key or script with the same hash.
Everywhere else we use BLAKE2b-256. In this case we do require second preimage resistance and collision resistance. We use the output of these hash functions to produce signatures (see Figure~\ref{fig:rules:utxow-shelley}), meaning that if an adversary can find two messages with the same hash, it could break the intended EUF-CMA (Existentially UnForgeable against a Chosen Plaintext Attack) property of the underlying signature scheme.
In the CDDL specification in Appendix~\ref{sec:cddl},
$\mathsf{hash28}$ refers to BLAKE2b-224 and
and $\mathsf{hash32}$ refers to BLAKE2b-256.
BLAKE2 is specified in RFC 7693 \cite{rfcBLAKE2}.
\subsection{Addresses}
\label{sec:app-addresses}
The \fun{sign} and \fun{verify} functions from Figure~\ref{fig:crypto-defs-shelley}
use Ed25519. See \cite{rfcEdDSA}.
\subsection{KES}
The \fun{sign_{ev}} and \fun{verify_{ev}} functions from Figure~\ref{fig:kes-defs-shelley}
use the iterated sum construction from Section 3.1 of \cite{cryptoeprint:2001:034}.
We allow up to $2^7$ key evolutions, which is larger than the maximum number
of evolutions allow by the spec, \MaxKESEvo, which will be set to $90$.
See Figure~\ref{fig:rules:ocert}.
\subsection{VRF}
\label{sec:app-vrf}
The \fun{verifyVrf} function from Figure~\ref{fig:defs-vrf}
uses ECVRF-ED25519-SHA512-Elligator2 as described in the draft IETF specification
\cite{rfcVRFDraft}.
More generally, we expect the following properties from a Verifyable Random Function:
\begin{description}
\item[Full uniqueness] For any fixed public VRF key and for \textit{any} input seed, there is a unique VRF output that can be proved valid.
\item[Full collision resistance] It should be computationally infeasible to find two distinct VRF inputs that have the same VRF output, even if the adversary knows the private key.
\item[Pseudorandomness] Assuming the public-private key pair has been generated honestly, the VRF hash output on any adversarially-chosen VRF input looks indistinguishable from random for a computationally bounded adversary who does not know the private key.
\end{description}
\subsection{Abstract functions}
\label{sec:abstract-funcs-implementation}
\begin{itemize}
\item The transaction ID function $\fun{txid}$ from Figure~\ref{fig:defs:utxo-shelley} is implemented
as the BLAKE2b-256 hash of the CBOR serialization of the transaction body.
\textbf{Note} that we do \textbf{not} enforce canonical CBOR and that there are
multiple valid serializations for any given transaction body.
The transaction ID must be computed using the original bytes that were
submitted to the network.
\item The seed operation $x \seedOp y$ from Figure~\ref{fig:defs-vrf} is implemented
as the BLAKE2b-256 hash of the concatenation of $x$ and $y$.
\item The function \fun{slotToSeed} from Figure~\ref{fig:defs:blocks} is implemented
as the big-endian encoding of the slot number in 8 bytes.
\end{itemize}
\subsection{Multi-Signatures}
As presented in Figure~\ref{fig:types-msig}, Shelley realizes multi-signatures
in a native way, via a script-like DSL. One defines the conditions required to
validate a multi-signature, and the script takes care of verifying the
correctness of the request. It does so in a na\"ive way, i.e. checking every
signature individually. For instance, if the requirement is to have $n$ valid
signatures out of some set $\mathcal{V}$ of public keys, the na\"ive
script-based solution checks if: (i) the number of submitted signatures is
greater or equal to $n$, (ii) the distinct verification keys are part of the set
$\mathcal{V}$, and (iii) at least $n$ signatures are valid. However, there are
more efficient ways to achieve this using more advanced multi-signature schemes,
that allow for aggregating both the signatures and the verification procedure.
This results in less data to be stored on-chain, and a cheaper verification
procedure. Several schemes provide these properties~\cite{musigBoneh, musig,
musig2, pixel}, and we are currently investigating which would be the best fit
for the Cardano ecosystem. We formally introduce multi-signature schemes.
\sloppy
A multi-signature scheme~\cite{musigs} is defined as a tuple of algorithms
$\textsf{MS} = (\textsf{MS-Setup}, \textsf{MS-KG}, \textsf{MS-AVK},
\allowbreak\textsf{MS-Sign}, \textsf{MS-ASign}, \textsf{MS-Verify)}$ such that
$\Pi\leftarrow\textsf{MS-Setup}(1^k)$ generates public parameters---where $k$ is
the security parameter. Given the public parameters, one can generate a
verification-signing key pair calling,
$(\mathsf{vk,sk})\leftarrow\textsf{MS-KG}(\Pi)$. A multi-signature scheme
provides a signing and an aggregate functionality. Mainly
\begin{itemize}
\item $\sigma\leftarrow\textsf{MS-Sign}(\Pi, \mathsf{sk}, m)$, produces a
signature, $\sigma$, over a message $m$ using signing key $\mathsf{sk}$, and
\item $\tilde{\sigma}\leftarrow\textsf{MS-ASig}(\Pi, m, \mathcal{V, S)}$, where
given a message $m$, a set of signatures, $\mathcal{S}$, over the message $m$,
and the corresponding set of verification keys, $\mathcal{V}$, aggregates all
signatures into a single, aggregate signature $\tilde{\sigma}$.
\end{itemize}
To generate an aggregate verification key, the verifier calls the function
$\mathsf{avk}\leftarrow\textsf{MS-AVK}(\Pi, \mathcal{V})$, which given input a
set of verification keys, $\mathcal{V}$, returns an aggregate verification key
that can be used for the verification of the aggregate siganture:
$\textsf{MS-Verify}(\Pi, \mathsf{avk}, m,
\tilde{\sigma})\in\{\textsf{true},\textsf{false}\}$.
Note the distinction between multi-signature schemes (as described above) and
multi-signatures as defined in Figure~\ref{fig:types-msig}. In
Figure~\ref{fig:types-msig} we allow scripts to consider valid the
\type{RequireAllOf}, \type{RequireAnyOf} or \type{RequireMOfN} typed signatures.
In the definition above, given a set of public keys $\mathcal{V}$, a signature
is considered valid if \textit{all} key owners participate. However, such
multi-signature schemes together with a simple script-like DSL can achieve the
properties defined in Figure~\ref{fig:types-msig} while still providing the
benefits of a simple verification procedure, and a smaller signature size.