Skip to content

Commit 3088963

Browse files
apoelstraroconnor-blockstream
authored andcommitted
(to squash) address all of russell's nits, except lagrange ones
1 parent ac5873b commit 3088963

1 file changed

Lines changed: 65 additions & 25 deletions

File tree

mathematical-companion/main.tex

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,16 @@ \subsection{Polynomial Rings}
8181
also a fact that a polynomial has a multiplicative inverse, i.e.~it is a
8282
\textbf{unit}, if and only if it is nonzero constant.
8383

84-
If a polynomial $r$ can be written as the product of two polynomials as $r=pq$,
85-
where neither $p$ nor $q$ are units (degree 0) we say that $r$ is
86-
\textbf{irreducible}.
84+
If whenever a polynomial $r$ is written as the product of two polynomials $r=pq$,
85+
either $p$ or $q$ is a unit (i.e.~degree 0), then we say $r$ is \textbf{irreducible}.
8786

8887
\subsection{Quotient Fields}
8988

9089
Just like we can consider the integers modulo some integer $n$, thus obtaining
9190
$n$ equivalence classes which inherit (roughly) the original ring structure of
9291
the integers, we can consider a polynomial ring modulo some polynomial $p$. In
9392
this case, we will get $m^n$ equivalence classes, where $m$ is the number of
94-
elements in the underlying field and $n$ is the degree of the polynomial. For
95-
our purposes $m$ is always 2, so we get $2^n$ elements.
93+
elements in the underlying field and $n$ is the degree of the polynomial.
9694

9795
We call the set of equivalence classes a \textbf{quotient ring}, and its addition
9896
and multiplication are defined in the obvious way.
@@ -106,12 +104,26 @@ \subsection{Quotient Fields}
106104
our polynomial ring only by irreducible polynomials. It is a fact that the
107105
resulting quotient ring will then be a field, and we term it a \textbf{quotient
108106
field}. It is a fact that $x^5 + x^3 + 1$ is irreducible in $\ftwo$, so that
109-
$\ftwo/(x^5 + x^3 + 1)$ is a quotient field with 32 elements.
107+
$\ftwo/(x^5 + x^3 + 1)$ is a quotient field with 32 elements. The original
108+
field, $\ftwo$, we refer to as the \textbf{base field}.
110109

111110
In this field the object $x$ is a field element with a distinct identity and
112111
algebraic properties, so we rename it $\alpha$ to preserve the symbol $x$ to
113112
be an indeterminate used for writing polynomials.
114113

114+
For any element $\delta$ in the quotient field, we can talk about its
115+
\textbf{minimal polynomial} over the base field. This is a monic polynomial
116+
(one whose highest-degree coefficient is 1) over the base field, of minimal
117+
degree, such that $\delta$ is a root when the polynomial is considered over
118+
the extension field. It is a fact of field theory that for any element
119+
$\delta$, a unique such minimal polynomial exists. We sometimes refer to the
120+
\textbf{degree} of $\delta$ as being the degree of its minimal polynomial.
121+
122+
Whenever we walk about minimal polynomials or degrees of field elementns, it
123+
is understood that we are considering the elements relative to some base field,
124+
but it will always be clear from context what this base field is, so that we
125+
can use these terms unambiguously.
126+
115127
It is a fact that, for this specific polynomial, that $\alpha$ is a
116128
\textbf{generator} of the quotient field, meaning that the field in its entirety
117129
is equal to
@@ -150,8 +162,15 @@ \subsection{Lagrange Interpolation and Shamir's Secret Sharing\label{sec:sss}}
150162
standard theorem of algebra that $p$'s value on all points of $\mathbb{F}$ is
151163
implied by its values on any $n+1$ distinct points.
152164

153-
As discovered by Edward Waring in 1779, and later by Joseph-Louis Lagrange
154-
in 1795\footnote{citation: Wikipedia}, it is actually possible to compute
165+
As discovered by Edward Waring in
166+
1779\footnote{Waring, Edward (1779). ``Problems concerning interpolations''.
167+
\emph{Philosophical Transactions of the Royal Society}. 69: 59–67.
168+
doi:10.1098/rstl.1779.0008.},
169+
and later by Joseph-Louis Lagrange in 1795\footnote{Lagrange, Joseph-Louis (1795).
170+
``Leçon Cinquième. Sur l'usage des courbes dans la solution des problèmes''.
171+
\emph{Leçons Elémentaires sur les Mathématiques}}\footnote{Both citations taken
172+
from Wikipedia's ``Lagrange Interpolation'' page, March 2023.},
173+
it is actually possible to compute
155174
the value of a polynomial at a field element $x$ explicitly in terms of
156175
its values at $n$ given distinct points $x_i$.
157176

@@ -242,8 +261,8 @@ \subsection{Lagrange Interpolation and Shamir's Secret Sharing\label{sec:sss}}
242261
\section{Volvelles and Tables}
243262

244263
The basic tools of hand computation are lookup tables for operations in $\fttwo$.
245-
Because there are only 32 elements, even completely unstructured operations can
246-
be implemented by a reasonably-sized 1024-element table.
264+
With only 32 elements, we can represent binary operations using reasonably-sized
265+
1024-element tables.
247266

248267
The four basic operations are provided in the booklet as ``Principal Tables''
249268
and also implemented as \textbf{volvelles}, which are simple computers constructed
@@ -273,7 +292,7 @@ \subsection{The Bech32 Alphabet}
273292
\item Representing elements as a power of $\alpha$ makes multiplication
274293
very easy, since multiplication is just addition mod 31 in the exponent.
275294

276-
This is how our multiplication wheel can be implemented as a slide rule.
295+
This is how our multiplication wheel can be implemented as a circular slide rule.
277296
\item Representing alphabetically makes it easy for humans to scan and sort.
278297
\item Representing in binary is how the elements are typically stored in
279298
computers, can be used to convert data from other encodings. Addition is
@@ -795,8 +814,9 @@ \section{BCH Codes}
795814
highlights the fact that BCH codes are designed to handle only \emph{substitution}
796815
or \emph{erasure} errors, not insertions or deletions.) Other small values of
797816
$m$ have similar issues; bech32 was originally defined to have $m=1$ but later
798-
needed to be modified to bech32m for this reason. bech32m uses a large random
799-
$m$ instead.
817+
needed to be modified to bech32m for this reason. bech32m uses a large $m$
818+
instead\footnote{For more details, see
819+
\url{https://gist.github.com/sipa/14c248c288c3880a3b191f978a34508e}}.
800820

801821
On the other hand, $m=0$ makes a BCH code a \textbf{linear code}, and brings
802822
with it a ton of algebraic properties which are needed for analysis, so this
@@ -893,7 +913,7 @@ \subsection{The Checksum Worksheet}
893913
which works out to \vc{RRQDN} (the process is to take the high 3 bits of each
894914
8-bit ASCII character, followed by 0, followed by the low 5 bits of each character).
895915
Prefix a 1, or \vc{P} in bech32. The resulting initial polynomial is \vc{PRRQDN}, or
896-
\[ x^5 + \binrep{3}x^4 + \binrep{3}x^3 + 0x^2 + \binrep{13}x + \binrep{19} \]
916+
\[ x^5 + \vc{R}x^4 + \vc{R}x^3 + \vc{D}x + \vc{N} \]
897917
Multiply this by $x^{13}$ and reduce it mod $G(x)$. The result will be
898918
\vc{33XW87RRYLJG}. This string is initially filled in in the checksum
899919
worksheet.
@@ -1096,7 +1116,7 @@ \section{Quickchecks}
10961116
We will call this new root $\zeta$. By construction, $\zeta$ satisfies
10971117
the equation $\zeta^2 = \zeta + 1$.
10981118

1099-
We can write any element of $\ftttwo$ as $a\zeta + b$, where $a$ and $b$ are
1119+
We can write any element of $\ftttwo$ as $a + b\zeta$, where $a$ and $b$ are
11001120
in $\fttwo$. Multiplication and addition happen in the obvious way, with
11011121
every $\zeta^2$ factor simply replaced by $\zeta + 1$.
11021122

@@ -1109,7 +1129,15 @@ \section{Quickchecks}
11091129
alternate code (and 1023 as the length of bech32). This is not a coincidence.
11101130

11111131
Consider the element $\beta = \vc{G}\zeta$, which has order $93$. In fact, our
1112-
generator $G$ has roots which are all powers of $\beta$! We can write it as
1132+
generator $G$ has roots which are all powers of $\beta$!\footnote{This is no
1133+
accident --- to construct $G$, we started with 8 consecutive powers of $\beta$,
1134+
took the minimal polynomials of these, and took the least common multiple of
1135+
these. The exact choice of $\beta$ and its powers came down to an exhaustive
1136+
search of which values led us to a code with our desired properties: distance
1137+
9, checksum length 13, maximal length, and three repeated coefficients in the
1138+
generator polynomial, which cause the entries in the checksum table to have
1139+
repeated digits, which we believe make transcribing easier for human eyes.}
1140+
We can write it as
11131141
\begin{align*}
11141142
G(x) = \prod_{i\in\{17, 20, 46, 49, 52, 77, 78, 79, 80, 81, 82, 83, 84\}} (x - \beta^i).
11151143
\end{align*}
@@ -1185,6 +1213,13 @@ \section{Quickchecks}
11851213
scheme is to encourage the user to frequently engage with their secret data, so
11861214
that they gain and maintain familiarity with the checksum verification process.
11871215

1216+
Even more important that consistency, by making each quickcheck use a quadratic
1217+
generator polynomial, we get two checksum digits, providing 10 bits of protection
1218+
against random errors. This means that if even a single quickcheck passes, the
1219+
user has 99.9\% assurance (1023/1024) that their data is intact. If we'd used a
1220+
linear generator polynomial, we would get only 5 bits, so a passing check would
1221+
give the user only 97\% (31/32) assurance.
1222+
11881223
Each quickcheck is merely a modular reduction of the user's data; it differs
11891224
from the Checksum Worksheet only in that we are reducing modulo a quadratic
11901225
rather than modulo the full degree-13 generator. This allows us to rearrange
@@ -1195,7 +1230,7 @@ \section{Quickchecks}
11951230

11961231
(All of the considerations in this section apply also to our alternate length-1023
11971232
code, which is used for 400+-bit seeds. It uses the order-1023 element
1198-
$\gamma=\vc{X}\zeta+\vc{E}$ to generate its roots, in place of $\beta$. But since
1233+
$\gamma=\vc{E} + \vc{X}\zeta$ to generate its roots, in place of $\beta$. But since
11991234
we do not expect anybody to manipulate such large seeds by hand, we will not
12001235
bother do the equivalent calculations. The motivated user will be able to construct
12011236
everything merely from knowledge of the generator polynomial and of $\gamma$.)
@@ -1257,13 +1292,17 @@ \section{Error Correction}
12571292

12581293
\section{Conclusion and Acknowledgements}
12591294

1260-
We thank the authors of SLIP39 for noticing the remarkable compatibility between
1261-
SSSS and BCH codes (or any linear code), which enable user-computed SSSS. Even if
1262-
SSSS were otherwise tractable to do by hand, without hand-verifiable checksums it
1295+
We thank the Russell O'Connor for noticing the remarkable compatibility between
1296+
SSSS and BCH codes (or any linear code), which enable user-computed SSSS\footnote{
1297+
See \url{https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-August/018070.html}}.
1298+
Even if SSSS were otherwise tractable to do by hand, without hand-verifiable checksums it
12631299
would be hopeless for users to notice or recover from arithmetic and transcription
12641300
mistakes, and this whole project would be unworkable.
12651301

1266-
We thank Dr. Curr for then noticing that by using a code over $\fttwo$
1302+
We thank the authors of SLIP39, whose scheme exploits this compatibility, and
1303+
which inspired us to attempt a hand-computable version of it.
1304+
1305+
We thank Dr.~Curr for then noticing that by using a code over $\fttwo$
12671306
rather than $\mathbb{F}_{1024}$, it is possible to do these computations by hand,
12681307
and for putting together the initial prototype of this project which included
12691308
the PostScript fundamentals to do computations with BCH codes, to draw 32-by-32
@@ -1272,10 +1311,11 @@ \section{Conclusion and Acknowledgements}
12721311
We thank Micaela Paez for the amazing artwork that adorns the illustrated version
12731312
of the volvelles.
12741313

1275-
We thank Peter Todd for his borderline-trolling mailing list post, in which he
1276-
suggested replacing the checksum with a single-character one obtained by summing
1277-
all the share data. Without this we would not have discovered the ``quickcheck''
1278-
method of verifying the checksum.
1314+
We thank Peter Todd for his mailing list post in which he suggested replacing the
1315+
checksum with a single-character one obtained by summing all the share data\footnote{
1316+
\url{https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-February/021498.html}}.
1317+
Without this we would not have discovered the ``quickcheck'' method of verifying
1318+
the checksum.
12791319

12801320
From that point onward it was a real trip to bring everything together, optimizing
12811321
the layout of the volvelles and worksheets for user experience, reducing the

0 commit comments

Comments
 (0)