Skip to content

Commit

Permalink
Remove add, sub, mul and div precompiles
Browse files Browse the repository at this point in the history
Because ethereum/EIPs#198 supersedes ethereum/EIPs#101 and the new version does not contain these.
  • Loading branch information
pirapira committed Jan 17, 2018
1 parent b436cae commit 3ff0df0
Showing 1 changed file with 2 additions and 66 deletions.
68 changes: 2 additions & 66 deletions Paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,7 @@ \section{Message Call} \label{ch:call}
\Xi_{\mathtt{SHA256}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 2 \\
\Xi_{\mathtt{RIP160}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 3 \\
\Xi_{\mathtt{ID}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 4 \\
\Xi_{\mathtt{ADD}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 5 \\
\Xi_{\mathtt{SUB}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 6 \\
\Xi_{\mathtt{MUL}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 7 \\
\Xi_{\mathtt{DIV}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 8 \\
\Xi_{\mathtt{EXPMOD}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 9 \\
\Xi_{\mathtt{EXPMOD}}(\boldsymbol{\sigma}_1, g, I) & \text{if} \quad r = 5 \\
\Xi(\boldsymbol{\sigma}_1, g, I) & \text{otherwise} \end{cases} \\
I_a & \equiv & r \\
I_o & \equiv & o \\
Expand Down Expand Up @@ -1395,67 +1391,7 @@ \section{Precompiled Contracts}\label{app:precompiled}
\mathbf{o} &=& I_\mathbf{d}
\end{eqnarray}

The fifth contract performs arbitrary-precision addition on non-negative integers.
The first word in the input specifies the number of bytes that the first non-negative integer $X$ occupies. The rest of the input is interpreted as $Y$.
Both $X$ and $Y$ are interpreted as a natural number encoded as byte sequences in the big-endian way.
The result is represented in the smallest possible number of bytes. The first byte in the output, if exists, is never zero.
The input and output formats are the same for $\Xi_{\mathtt{SUB}}$, $\Xi_{\mathtt{MUL}}$ and $\Xi_{\mathtt{DIV}}$ as well.

\begin{eqnarray}
\Xi_{\mathtt{ADD}} &\equiv& \Xi_{\mathtt{PRE}} \quad \text{except:}\\
\Xi_{\mathtt{ADD}}(\boldsymbol{\sigma}, g, I) &\equiv& (\varnothing, 0, A^0, ()) \quad \text{if} \quad |I_\mathbf{d}| - 32 < l_X \\
g_r &=& G_{addsubbase} + G_{arithword} \Big\lceil \dfrac{|I_\mathbf{d}|}{32} \Big\rceil \\
\mathbf{o} &=& \mathtt{\tiny BE}(X + Y) \\
X &=& I_\mathbf{d}[32..(31 + l_X)] \\
l_X &=& I_\mathbf{d}[0..31] \in \mathbb{P}_{256} \\
Y &=& I_\mathbf{d}[(32 + l_X)..(|I_\mathbf{d}| - 1)] \\
l_Y &=& |I_\mathbf{d}| - 32 - l_X
\end{eqnarray}

The sixth contract performs arbitrary-precision subtraction on non-negative integers. This is similar to the addition. The subtraction contract halts exceptionally if the result would be negative.

\begin{eqnarray}
\Xi_{\mathtt{SUB}} &\equiv& \Xi_{\mathtt{PRE}} \quad \text{except:}\\
\Xi_{\mathtt{SUB}}(\boldsymbol{\sigma}, g, I) &\equiv& (\varnothing, 0, A^0, ()) \quad \text{if} \quad |I_\mathbf{d}| - 32 < l_X \, \vee \, X < Y \\
g_r &=& G_{addsubbase} + G_{arithword} \Big\lceil \dfrac{|I_\mathbf{d}|}{32} \Big\rceil \\
\mathbf{o} &=& \mathtt{\tiny BE}(X - Y) \\
X &=& I_\mathbf{d}[32..(31 + l_X)] \\
l_X &=& I_\mathbf{d}[0..31] \in \mathbb{P}_{256} \\
Y &=& I_\mathbf{d}[(32 + l_X)..(|I_\mathbf{d}| - 1)] \\
l_Y &=& |I_\mathbf{d}| - 32 - l_X
\end{eqnarray}

The seventh contract performs arbitrary-precision multiplication on non-negative integers. The input format is the same as that of the addition contract.

\begin{eqnarray}
\Xi_{\mathtt{MUL}} &\equiv& \Xi_{\mathtt{PRE}} \quad \text{except:}\\
\Xi_{\mathtt{MUL}}(\boldsymbol{\sigma}, g, I) &\equiv& (\varnothing, 0, A^0, ()) \quad \text{if} \quad |I_\mathbf{d}| - 32 < l_X \\
g_r &=& G_{muldivbase} + G_{arithword} \Big\lceil \dfrac{|I_\mathbf{d}|}{32} \Big\rceil + l_X l_Y / G_{quaddivisor} \\
\mathbf{o} &=& \mathtt{\tiny BE}(X \times Y) \\
X &=& I_\mathbf{d}[32..(32 + I_\mathbf{d}[0..31] - 1)] \\
l_X &=& l_X \in \mathbb{P}_{256} \\
Y &=& I_\mathbf{d}[(32 + l_X)..(|I_\mathbf{d}| - 1)] \\
l_Y &=& |I_\mathbf{d}| - 32 - l_X
\end{eqnarray}

The eigth contract performs arbitrary-precision division on non-negative integers. The definition is similar to that of the multiplication contract.

\begin{eqnarray}
\Xi_{\mathtt{DIV}} &\equiv& \Xi_{\mathtt{PRE}} \quad \text{except:}\\
\Xi_{\mathtt{DIV}}(\boldsymbol{\sigma}, g, I) &\equiv& (\varnothing, 0, A^0, ()) \quad \text{if} \quad |I_\mathbf{d}| - 32 < l_X \\
g_r &=& G_{muldivbase} + G_{arithword} \Big\lceil \dfrac{|I_\mathbf{d}|}{32} \Big\rceil + l_X l_Y / G_{quaddivisor} \\
\mathbf{o} &=&
\begin{cases}
() & \text{if} \ Y = 0 \\
\mathtt{\tiny BE}\Big(\big\lfloor \dfrac X Y \big\rfloor\Big) & \text{otherwise}
\end{cases} \\
X &=& I_\mathbf{d}[32..(31 + l_X)] \\
l_X &=& I_\mathbf{d}[0..31] \in \mathbb{P}_{256} \\
Y &=& I_\mathbf{d}[(32 + l_X..(|I_\mathbf{d}| - 1)] \\
l_Y &=& |I_\mathbf{d}| - 32 - l_X
\end{eqnarray}

The ninth contract performs arbitrary-precision exponentiation under modulo. Here, $0 ^ 0$ is taken to be one.
The fifth contract performs arbitrary-precision exponentiation under modulo. Here, $0 ^ 0$ is taken to be one.
The first word in the input specifies the number of bytes that the first non-negative integer $B$ occupies.
The second word in the input specifies the number of bytes that the second non-negative integer $E$ occupies.
These two words are followed by $B$ and $E$; and the rest of the input is interpreted as the third non-negative integer $M$.
Expand Down

0 comments on commit 3ff0df0

Please sign in to comment.