From b8b4d34728d2a37a81f5ec93cc02b40b870b58d6 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Wed, 21 Jun 2017 16:26:57 +0200 Subject: [PATCH] Make sure that divisions and modulo operations are not subject to mod 2^{256} --- Paper.tex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Paper.tex b/Paper.tex index ff955d82..3127b7d9 100644 --- a/Paper.tex +++ b/Paper.tex @@ -1583,18 +1583,20 @@ \subsection{Instruction Set} \midrule 0x04 & {\small DIV} & 2 & 1 & Integer division operation. \\ &&&& $\boldsymbol{\mu}'_\mathbf{s}[0] \equiv \begin{cases}0 & \text{if} \quad \boldsymbol{\mu}_\mathbf{s}[1] = 0\\ \lfloor\boldsymbol{\mu}_\mathbf{s}[0] \div \boldsymbol{\mu}_\mathbf{s}[1]\rfloor & \text{otherwise}\end{cases}$ \\ +&&&& where division is not subject to modulo $2^{256}$. \\ \midrule 0x05 & {\small SDIV} & 2 & 1 & Signed integer division operation (truncated). \\ &&&& $\boldsymbol{\mu}'_\mathbf{s}[0] \equiv \begin{cases}0 & \text{if} \quad \boldsymbol{\mu}_\mathbf{s}[1] = 0\\ -2^{255} & \text{if} \quad \boldsymbol{\mu}_\mathbf{s}[0] = -2^{255} \wedge \quad \boldsymbol{\mu}_\mathbf{s}[1] = -1\\ \mathbf{sgn} (\boldsymbol{\mu}_\mathbf{s}[0] \div \boldsymbol{\mu}_\mathbf{s}[1]) \lfloor |\boldsymbol{\mu}_\mathbf{s}[0] \div \boldsymbol{\mu}_\mathbf{s}[1]| \rfloor & \text{otherwise}\end{cases}$ \\ -&&&& Where all values are treated as two's complement signed 256-bit integers. \\ +&&&& Where all values are treated as two's complement signed 256-bit integers and division is not subject to modulo $2^{256}.$ \\ &&&& Note the overflow semantic when $-2^{255}$ is negated.\\ \midrule 0x06 & {\small MOD} & 2 & 1 & Modulo remainder operation. \\ &&&& $\boldsymbol{\mu}'_\mathbf{s}[0] \equiv \begin{cases}0 & \text{if} \quad \boldsymbol{\mu}_\mathbf{s}[1] = 0\\ \boldsymbol{\mu}_\mathbf{s}[0] \bmod \boldsymbol{\mu}_\mathbf{s}[1] & \text{otherwise}\end{cases}$ \\ +&&&& where $\mod$ is not subject to modulo $2^{256}$. \\ \midrule 0x07 & {\small SMOD} & 2 & 1 & Signed modulo remainder operation. \\ &&&& $\boldsymbol{\mu}'_\mathbf{s}[0] \equiv \begin{cases}0 & \text{if} \quad \boldsymbol{\mu}_\mathbf{s}[1] = 0\\ \mathbf{sgn} (\boldsymbol{\mu}_\mathbf{s}[0]) |\boldsymbol{\mu}_\mathbf{s}[0]| \bmod |\boldsymbol{\mu}_\mathbf{s}[1]| & \text{otherwise}\end{cases}$ \\ -&&&& Where all values are treated as two's complement signed 256-bit integers. \\ +&&&& Where all values are treated as two's complement signed 256-bit integers and $\mod$ is not subject to modulo $2^{256}$. \\ \midrule 0x08 & {\small ADDMOD} & 3 & 1 & Modulo addition operation. \\ &&&& $\boldsymbol{\mu}'_\mathbf{s}[0] \equiv \begin{cases}0 & \text{if} \quad \boldsymbol{\mu}_\mathbf{s}[2] = 0\\ (\boldsymbol{\mu}_\mathbf{s}[0] + \boldsymbol{\mu}_\mathbf{s}[1]) \mod \boldsymbol{\mu}_\mathbf{s}[2] & \text{otherwise}\end{cases}$ \\