WO2013051139A1 - 有限体上の乗算方法、計算機、およびプログラム - Google Patents

有限体上の乗算方法、計算機、およびプログラム Download PDF

Info

Publication number
WO2013051139A1
WO2013051139A1 PCT/JP2011/073136 JP2011073136W WO2013051139A1 WO 2013051139 A1 WO2013051139 A1 WO 2013051139A1 JP 2011073136 W JP2011073136 W JP 2011073136W WO 2013051139 A1 WO2013051139 A1 WO 2013051139A1
Authority
WO
WIPO (PCT)
Prior art keywords
bit
finite field
bits
multiplication
result
Prior art date
Application number
PCT/JP2011/073136
Other languages
English (en)
French (fr)
Inventor
恒太 井手口
渡辺 大
Original Assignee
株式会社日立製作所
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 株式会社日立製作所 filed Critical 株式会社日立製作所
Priority to PCT/JP2011/073136 priority Critical patent/WO2013051139A1/ja
Publication of WO2013051139A1 publication Critical patent/WO2013051139A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/60Methods or arrangements for performing computations using a digital non-denominational number representation, i.e. number representation without radix; Computing devices using combinations of denominational and non-denominational quantity representations, e.g. using difunction pulse trains, STEELE computers, phase computers
    • G06F7/72Methods or arrangements for performing computations using a digital non-denominational number representation, i.e. number representation without radix; Computing devices using combinations of denominational and non-denominational quantity representations, e.g. using difunction pulse trains, STEELE computers, phase computers using residue arithmetic
    • G06F7/724Finite field arithmetic

Definitions

  • the present invention relates to a method for performing multiplication on a finite field GF (2 ⁇ m).
  • Y ⁇ 2 ⁇ ((n-1-i) ⁇ m) ⁇ xi is calculated in advance for all possible values of xi, and the calculation results are stored in advance in table Ti. And when calculating Y ⁇ 2 ⁇ ((n-1) ⁇ m) ⁇ x0 + Y ⁇ 2 ⁇ ((n-2) ⁇ m) ⁇ x1 + ... Y ⁇ x (k-1)
  • the calculation can be executed at high speed.
  • Table Ti has a capacity of
  • represents the number of bits of the bit string Y.
  • the above calculation method uses a different reference table Ti for each xi.
  • the calculation method using one type of reference table T (n-1) is to obtain Y ⁇ xi by referring to Table T0, then perform 2 ⁇ m multiplication on a finite field and repeat these.
  • This calculation of 2 ⁇ m multiplication can be realized by combining a shift operation that shifts by m bits and an operation that feeds back a value obtained by referring to the table.
  • Non-Patent Document 1 it takes time to calculate the shift process that shifts by m bits, and the calculation speed is greatly reduced. Then, the speed of the shift process decreases particularly remarkably when the original bit length of the finite field is longer than the bit length of the register of the CPU. For this reason, the calculation method disclosed in Non-Patent Document 1 may not be able to achieve the calculation speed required for a device that requires a high-speed response.
  • An object of the present invention is to provide a technique for performing multiplication on a finite field at high speed and with a small amount of memory.
  • a multiplication method on a finite field is a multiplication method on a finite field for performing multiplication on a finite field by a processor, wherein the table management means includes The first element that is an element of a finite field and one of the multiplication targets, and the finite field of which 0 or 1 is set to m bits every n bits from the nth bit and 0 is set to the other bits The first step of holding (2 ⁇ m) first bit strings, which are the results of multiplication with (2 ⁇ m) elements, as a table, and the iterative operation means are used for the previous shift / table reference operation.
  • the result is subjected to doubling on the finite field, and the first selected from the table based on the result of the doubling and the second element that is an element of the finite field and the other multiplication target.
  • FIG. 3 It is a block diagram of the computer which performs the process of the multiplication on a finite field in this embodiment. It is a flowchart which shows the process which performs the multiplication on a finite field in this embodiment. It is a figure which shows the mode of conversion of the bit arrangement
  • FIG. 1 is a configuration diagram of a computer that performs multiplication processing on a finite field in this embodiment.
  • FIG. 2 is a flowchart showing processing for performing multiplication on a finite field in the present embodiment.
  • the multiplication process on the finite field of the present embodiment includes a process of generating a table, a process of replacing original bits of the finite field to be multiplied, and a process of bit shift and table reference.
  • the process of generating a table, the process of replacing original bits of a finite field to be multiplied, and the process of bit shift and table reference are performed as functions.
  • Multiplication on a finite field is realized by executing processing in the order of the table generation function, data shuffle function, and shift / table reference function.
  • step 101 is a table generation function process
  • step 102 is a data shuffle function process
  • steps 103 to 110 are a shift / table reference function process.
  • the table generation function creates a table that depends only on one value of multiplication. As long as this variable is not changed, there is no need to calculate the table again. In a usage mode in which one value is fixed and the other value is sequentially changed and the multiplication is repeated, the table generation function only needs to be processed once during the first multiplication. In this embodiment, the multiplication of a finite field is particularly efficient in such a situation that one element is fixed and the other element is changed in this way.
  • the finite field is GF (2 128 )
  • the element of the finite field is represented by 128 bits
  • the multiplication X ⁇ Y of the two elements X and Y of GF (2 128 ) is calculated.
  • a computer 200 includes a CPU (Central Processing Unit) 201 that is a 32-bit processor that executes software processing, and a memory 202 that is a storage device that stores software and data.
  • the CPU 201 includes a plurality of registers 203 and at least one carry flag 204.
  • the register 203 is 32 bits, and the carry flag 204 is 1 bit.
  • the memory 202 includes a table storage unit 205 that stores a table generated by a table generation method described later.
  • the computer 200 includes a table management unit 401 that creates and manages a table, a rearrangement unit 402 that rearranges a bit string of data, and an iterative operation unit that repeatedly performs doubling and table reference. Prepare.
  • the instruction set that can be executed by the CPU 201 includes exclusive OR instructions XOR A and B, AND instructions AND A and B, OR instructions OR A and B, and copy instructions COPY A and B. .
  • Exclusive OR instructions XOR A and B are instructions that perform exclusive OR for each bit of the values stored in the two registers A and B and overwrite the result with A.
  • Logical product instructions AND A and B are instructions that perform bitwise logical product on the values stored in the two registers A and B and overwrite the result on A.
  • OR instructions OR A and B are instructions that perform a bitwise OR operation on the values stored in the two registers A and B and overwrite the result with A.
  • Copy instructions COPY A and B are instructions for copying the value of B to A.
  • the instruction set that can be executed by the CPU 201 includes a logical product instruction ANDi A, IMM with an immediate value and an exclusive OR instruction XORi A, IMM with the immediate value.
  • AND instruction ANDi A, IMM with immediate value is an instruction that performs logical AND for each bit of A and IMM on one register A and one 32-bit immediate value IMM and overwrites the result with A. .
  • Exclusive OR instruction XORi A, IMM with immediate value performs bitwise exclusive OR of A and IMM for one register A and one 32-bit immediate value IMM, and the result is A It is an instruction to overwrite.
  • the instruction set that can be executed by the CPU 201 includes a 1-bit shift instruction ROL A and a 1-bit shift instruction ROLC A with carry.
  • 1-bit shift instruction ROL A is an instruction that shifts A by 1 bit to the left with respect to one register A and carry flag C, and stores the original most significant bit of A protruding from A in C .
  • 1-bit shift instruction with carry ROLC A shifts the bit stored in C to the least significant bit of A and shifts from A to 1 register A and carry flag C after shifting A to the left by 1 bit This is an instruction to store the original most significant bit of A in C.
  • the instruction set that can be executed by the CPU 201 includes SHR A, imm, SHL A, imm, and ROLi A, imm.
  • imm is an instruction to shift A to the right by imm bits for one register A and one immediate value imm.
  • imm is an instruction for shifting A to the left by one mm for one register A and one immediate value imm.
  • ROLi A, imm is an instruction that cyclically shifts A to the left by one mm for one register A and one immediate value imm.
  • the instruction set that can be executed by the CPU 201 includes an IF not carry instruction IFNC M.
  • the IF not carry instruction IFNC M is an instruction for setting a program counter in the memory address M only when the carry flag is 0 with respect to the carry flag and the memory address M.
  • the instruction set that can be executed by the CPU 201 includes memory load instructions LOAD A and M.
  • Memory load instructions LOAD A and M are instructions for copying 32-bit data stored in the memory address M to the register A.
  • the XOR, AND, OR, ANDi, XORi, ROL, ROLC, SHR, SHL, ROLi, and IFNC instructions can be executed in one cycle using the ALU of the CPU 201. Further, it is assumed that the LOAD instruction can be executed in one cycle using the memory access unit of the CPU 201.
  • Each bit of the b-bit variable W is described as W ⁇ 0 ⁇ , W ⁇ 1 ⁇ ,..., W ⁇ b-1 ⁇ sequentially from the left bit, and W ⁇ 0 ⁇ is the most significant bit.
  • a continuous j-i + 1 bit from W ⁇ i ⁇ to W ⁇ j ⁇ is described as W ⁇ ij ⁇ .
  • the elements of table T with m elements are T [0], It is described as T [1],..., T [m-1]. That is, the i-th element is described as T [i-1].
  • a ⁇ B represents a bitwise exclusive OR of a 32-bit bit string A and B.
  • B represents the bitwise OR of the 32-bit bit strings A and B.
  • a & B represents a bitwise AND of a 32-bit bit string A and B.
  • B represents a combination of two bit strings A and B.
  • a ⁇ n represents the left n-bit shift of the 32-bit variable A.
  • a >> n represents the right n-bit shift of the 32-bit variable A.
  • a ⁇ n represents the left n-bit cyclic shift of the 32-bit variable A.
  • n For two integers m and n, m / n and m% n represent the quotient and remainder when m is divided by n, respectively.
  • the table management unit 401 determines whether a table corresponding to the element Y of the finite field stored in the table storage unit 205 is stored (step 100). When a table corresponding to the original Y is stored, the table management unit 401 repeatedly passes the stored table to the calculation unit 403. If the table corresponding to the original Y is not stored, the table management unit 401 creates a table corresponding to Y, stores the table in the table storage unit 205 (step 101), and stores the table in the iterative calculation unit 403. Deliver.
  • step 101 the table management unit 401 uses the CPU 201 to execute a table generation function.
  • the table generation function is a function that generates a 256-byte table T by using the element Y of the finite field as an input, and stores the table T in the table storage unit 205.
  • the table generation method of the table generation function is as follows.
  • the element of the finite field is 128 bits, and the register length of the CPU is 32 bits. Therefore, one table T in which 128-bit values are stored is divided into four 32-bit tables T_0, T_1, T_2, and T_3 on the program.
  • the divided T_i is referred to as a small table.
  • Each small table is a table of 4 bits input and 32 bits output, that is, each small table is composed of 16 4-byte elements. Therefore, the data amount of each small table is 64 bytes, and the data amount of the table T is 256 bytes in total of the four small tables.
  • the i-th element of the small table is specified by index i-1. That is, the i-th element of T_0 is described as T_0 [i-1]. The same applies to other tables.
  • the i-th element of each small table is T_0 [i-1], 128 bits combined in the order of T_1 [i-1], T_2 [i-1], and T_3 [i-1] are the i-th element T [i-1] of the table T.
  • T_0 [i] T [i] ⁇ 0-31 ⁇
  • T_1 [i] T [i] ⁇ 32-63 ⁇
  • T_2 [i] T [i] ⁇ 64-95 ⁇
  • T_3 [i] T [i] ⁇ 96-127 ⁇ .
  • T [i] Y ⁇ g (i)
  • i is an integer from 0 to 15.
  • g is a mapping from a 4-bit value i to a 128-bit value, and is defined as follows.
  • g (i) ⁇ j ⁇ and i ⁇ j ⁇ are the j + 1th bit from the left of g (i) and i, respectively.
  • the significant value (0 or 1) of each bit of i is set in the 32 * j + 31 + 1st bit of g (i), and fixed to the other bits of g (i). 0 is set.
  • the method for multiplying G (i) and Y is not particularly limited.
  • the table T is stored in a series of areas on the memory with i as an offset, and can be referred to by i.
  • (A) of FIG. 5 is a figure explaining calculation of T [i].
  • step 101 Since the table for the element Y of the finite field created in step 101 is stored in the table storage unit 205, if a table corresponding to the element Y having the same value becomes necessary again, the CPU 201 proceeds to step 101.
  • step 102 it is only necessary to proceed directly to step 102. That is, when the multiplication of X and Y is performed on the elements X of a plurality of finite fields that are the other multiplication targets without changing the element Y of the finite field that is the multiplication target, the table generation function is first It is only necessary to execute the table generation function, and the execution of the table generation function can be omitted in the second and subsequent multiplications.
  • the second and subsequent multiplications are particularly fast.
  • the second and subsequent multiplications are faster than the first. Therefore, the effect of increasing the calculation speed according to the present embodiment will be verified by comparing the speeds of the second and subsequent multiplications in the present embodiment and the conventional method, as will be described later.
  • Step 102 is a step in which the rearrangement unit 402 acquires X and converts X to X ′ by a data shuffle function.
  • the data shuffle function is a function that takes a 128-bit value X as an input and outputs a 128-bit value X ′.
  • FIG. 3 is a diagram illustrating how the bit arrangement is converted from X to X ′. When X is divided into four parts having 32 bits and the bits at the same position in each part are collected, X ′ is obtained.
  • S0 (X0 & 0xff00ff00)
  • S1 ((X0 & 0x00ff00ff) ⁇ 8)
  • S2 ((X2 & 0xff00ff00) ⁇ 16)
  • S3 ((X2 & 0x00ff00f) ⁇ 24)
  • U0 (S0 & 0xffff0000)
  • U1 (S1 & 0xfff0000)
  • U2 (S0 ⁇ 16)
  • U3 (S1 ⁇ 16)
  • R0, R1, R2, and R3 which are the four registers 203 of the CPU 201, respectively.
  • S0, S1, S2, and S3 are calculated, and further, U0, U1, U2, and U3 are calculated. After the calculation, U0, U1, U2, and U3 are stored in the four registers 203.
  • the CPU 201 is provided with a sufficient number of registers 203 so that intermediate values and results need not be saved in the memory 202 in the course of this calculation. If so, the data shuffle calculation can be completed with 38 instructions by using an instruction executable by the CPU 201 of the computer 200. For example, if the number of registers 203 in the CPU 201 is 16, memory saving is not necessary.
  • Steps 103 to 110 are steps in which the iterative calculation unit 403 acquires Z, converts Z by the calculation described below, and outputs the converted Z.
  • the shift / table reference function is a function that inputs the 128-bit value X ′ obtained in step 102 and the table T in the table storage unit 205 and outputs a 128-bit value Z obtained based on the input.
  • Processing of the shift / table reference function consists of the following procedures.
  • FIG. 5B is a diagram illustrating a state of division from X ′ to x′i.
  • the iterative operation unit 403 first doubles Z on GF (2 128 ) (step 105).
  • (C) of FIG. 5 illustrates the state of doubling Z in step 105.
  • FIG. 5D illustrates the table reference state in step 106.
  • an exclusive OR of Z and t is obtained, and the result is newly set as Z (step 107).
  • FIG. 5 (e) illustrates the state of exclusive OR in step 107.
  • the iterative operation unit 403 increments i by 1 (step 108), and determines whether i has reached 32 (step 109). If i has not reached 32, the CPU 201 returns to step 105 and repeats the loop processing. If i has reached 32, the CPU 201 exits the loop and proceeds to step 110. Then, Z obtained when exiting the loop is output as the result of multiplication (step 110).
  • (Z1 >>31); Z1 (Z1 ⁇ 1)
  • (Z2 >>31); Z2 (Z2 ⁇ 1)
  • 0x0000008b is a feedback bit string obtained from the above definition polynomial. By feeding back this bit string, the result of doubling is expressed as an element of GF (2 128 ).
  • This pseudo-code for doubling can be implemented with 6 instructions as follows using the computer 200. However, it is assumed that Z0 is stored in the register R0, Z1 is stored in the register R1, Z2 is stored in the register R2, and Z3 is stored in the register R3.
  • the XOR instruction may be stored in a register not using 0x0000008b. However, in that case, one extra memory access instruction is required each time the shift / table reference function is executed once.
  • x′i is assumed to be 4 bits starting from the (28-k) th bit from the left of X′j. If there are as many registers as memory saving is not necessary, this pseudo code can be executed by the computer 200 with two ALU instructions and four memory access instructions. For example, if the number of registers is 16, it is not necessary to save the memory.
  • Step 104 the process regarding the variable i in Step 104, Step 108, and Step 109 is a process for realizing 32 loops. If the loop process is unrolled in the implementation, these processes become unnecessary, so that the program execution time can be reduced accordingly.
  • 214 + 374 588 ALU instructions and 128 memory access instructions are required to calculate X ⁇ Y by the computer 200 in a situation where a table for Y is already stored in the table storage unit 205. become.
  • the number of instructions in the data shuffle function is reduced from 214 ALU instructions to 186 ALU instructions.
  • the conventional multiplication method on a finite field consists of a conventional table generation function and a conventional shift / table reference function. First, a conventional table generation function is executed, and then a conventional shift / table reference function is executed.
  • the conventional table generation function creates a table that depends only on one variable of multiplication. Unless this variable is changed, it is not necessary to calculate the table again, so the calculation need only be performed once during the first multiplication.
  • the conventional shift / table reference function corresponds to a processing amount obtained by replacing the doubling in the shift / table reference function in this embodiment with 16 times.
  • FBTBL is a table composed of 16 16-bit or 32-bit elements.
  • the FBTBL is a table that takes the most significant 4 bits protruding by shift as an input and returns a feedback value obtained from the definition polynomial for the 4 bits.
  • This pseudo code can be executed with the ALU 16 instruction and one memory access instruction as follows using the computer 200, assuming that there are as many registers as there is no need to save memory. However, it is assumed that Z0 is stored in the register R0, Z1 is stored in the register R1, Z2 is stored in the register R2, and Z3 is stored in the register R3. Registers R4, R5, R6, and R7 are used to store intermediate values. START of CALC.
  • the computer 200 needs the 684 ALU instruction and the 159 memory access instruction to calculate X ⁇ Y. Become.
  • the number of instructions is reduced by about 20% according to this embodiment compared to the conventional method. Furthermore, in the present embodiment, since the FBTBL is not necessary, the amount of memory can be reduced by 32 bytes or 64 bytes.
  • the finite field has a size of 128 bits, and the table reference is performed every 4 bits.
  • the present invention is not limited to this combination.
  • the present invention can be applied by arbitrarily combining the size of the finite field and the number of bits of the reference table.
  • FIG. 4 is a functional block diagram of the computer 200 in this embodiment.
  • FIG. 1 is a configuration diagram focusing on the hardware configuration of the computer 200, but FIG. 4 is a functional block diagram focusing on the function of the computer 200.
  • the computer 200 includes a table management unit 401, a rearrangement unit 402, and an iterative calculation unit 403.
  • the basic functions of each part are as follows as an example, and further perform various functions as described above.
  • the table management unit 401 sets 0 or 1 to 4 bits every 32 bits from the 128-bit element Y to be multiplied and the 32nd bit out of 128 bits, and sets the other bits to 0.
  • a bit string that is a result of multiplication with 16 elements g (i) is held in a table.
  • the rearrangement unit 402 divides the other X to be multiplied into four first partial bit strings of 32 bits, and collects bits in the same position of each of the partial bit strings, thereby collecting the elements of the element X.
  • the order of the bits in the bit string is rearranged, and the rearranged bit string is defined as 32 second partial bit strings having 4 bits.
  • the iterative operation unit 403 performs doubling on a finite field, and performs an exclusive OR for each bit of the doubling result and a bit string selected from the table based on the second partial bit string. Repeat the calculation 32 times.
  • the technology applied to the present embodiment can be widely applied, for example, when an algorithm using multiplication of a finite field is implemented in a system using a low resource device such as an embedded CPU. In low-resource devices, high speed mounting and memory saving are often required, and this need can be met by applying the present invention.
  • algorithms using multiplication over a finite field include cryptographic algorithms such as authentication cryptographic schemes GCM and MULTI-S01, and various code algorithms.

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • Complex Calculations (AREA)

Abstract

 テーブル管理手段は、前記有限体の元であり一方の乗算対象である第1の元と、n番目のビットからnビット毎のm個のビットに0か1を設定し他のビットに0を設定した前記有限体の(2^m)個の元との乗算の結果である(2^m)個の第1のビット列をテーブルとして保持する。繰り返し演算手段は、前回のシフト・表参照演算の結果に前記有限体上での2倍算を行い、前記2倍算の結果と、前記有限体の元であり他方の乗算対象である第2の元に基づいて前記テーブルから選択した第1のビット列とのビット毎の排他的論理和を行うシフト・表参照演算を繰り返す。

Description

有限体上の乗算方法、計算機、およびプログラム
 本発明は、有限体GF(2^m)上の乗算を行う方法に関する。
 従来、有限体上の乗算を高速に行う方法として、事前に計算した表を参照する方法が用いられてきた。2つの値XとYの乗算を行う場合、XをX=x0||x1||...||x(n-1)とn個のmビットに分割し、Y・2^((n-1)・m)・x0+Y・2^((n-2)・m)・x1+...Y・x(n-1)を計算する。ただし、||はビット列の結合を表す。その計算に先立ってY・2^((n-1-i)・m)・xiをxiの可能な全ての値に対して事前に計算し、計算結果を表Tiに予め格納しておく。そして、Y・2^((n-1)・m)・x0+Y・2^((n-2)・m)・x1+...Y・x(k-1)を計算するときには、iについて0からn-1まで表Tiをxiで参照し、得られる値を足し合わせることで高速に計算を実行することができる。
 その場合、表Tiは|Y|×2^mビットの容量をもつ。ただし、ここで|Y|という記号はビット列Yのビット数を表すものとする。
 表Tiを参照する回数と表Tiの容量との間には、表Tiを参照する回数を多くすると表Tiの容量が大きくなり、表Tiを参照する回数を少なくすると表Tiの容量が大きくなる、という関係にある。
 上述の計算方法は、xi毎に異なる参照表Tiを用いる方法である。しかし、他の計算方法として、1種類の参照表T(n-1)のみを用いて実装する方法がある。
 1種類の参照表T(n-1)を用いる計算方法は、表T0の参照によってY・xiを得た後に、有限体上の2^m倍算を行い、これらを繰り返すというものである。この2^m倍算の計算は、mビットだけシフトするシフト演算と、表を参照して得た値をフィードバックする演算とを組み合わせることで実現できる。この計算方法ではY・xi(i=0,..,k-1)を求める際の参照表をT(n-1)の1種類にすることで、参照する表T(n-1)に必要なメモリ容量を減らしている(非特許文献1参照)。
Victor Shoup, On Fast andProvably Secure Message Authentication Based on Universal Hashing, Advances inCryptology - Proceedings of CRYPTO'96, 1996.
 しかし、非特許文献1に記載された計算方法では、mビットだけシフトするシフト処理の計算に時間がかかり、計算速度が大きく低下してしまう。そして、シフト処理の速度は、有限体の元のビット長がCPUのレジスタのビット長よりも長い場合に特に顕著に低下する。このため、非特許文献1の計算方法では、高速な応答が求められる機器で要求される計算速度を達成できない可能性がある。
 本発明の目的は、有限体上の乗算を高速かつ省メモリで行う技術を提供することである。
 上記目的を達成するために、本発明の一態様による有限体上の乗算方法は、プロセッサによって有限体上の乗算を行うための、有限体上の乗算方法であって、テーブル管理手段が、前記有限体の元であり一方の乗算対象である第1の元と、n番目のビットからnビット毎のm個のビットに0か1を設定し他のビットに0を設定した前記有限体の(2^m)個の元との乗算の結果である(2^m)個の第1のビット列をテーブルとして保持する第1のステップと、繰り返し演算手段が、前回のシフト・表参照演算の結果に前記有限体上での2倍算を行い、前記2倍算の結果と、前記有限体の元であり他方の乗算対象である第2の元に基づいて前記テーブルから選択した第1のビット列とのビット毎の排他的論理和を行うシフト・表参照演算を繰り返す第2のステップと、を有している。
本実施形態において有限体上の乗算の処理を行う計算機の構成図である。 本実施形態における有限体上の乗算を行う処理を示すフローチャートである。 XからX’へのビット配置の変換の様子を示す図である。 本実施形態における計算機200の機能ブロック図である。 図2の各ステップの説明図である。 テーブルTの例図である。
 本発明を実施するための形態について図面を参照して詳細に説明する。
 図1は、本実施形態において有限体上の乗算の処理を行う計算機の構成図である。図2は、本実施形態における有限体上の乗算を行う処理を示すフローチャートである。
 本実施形態の有限体上の乗算の処理には、テーブルを生成する処理と、乗算する有限体の元のビットを入れ替える処理と、ビットシフトおよび表参照の処理とが含まれる。ここでは、テーブルを生成する処理、乗算する有限体の元のビットを入れ替える処理、およびビットシフトおよび表参照の処理をそれぞれ関数として行うものとする。テーブル生成関数、データシャッフル関数、シフト・表参照関数の順に処理を実行することで、有限体上の乗算が実現される。図2におけるステップ101がテーブル生成関数の処理であり、ステップ102がデータシャッフル関数の処理であり、ステップ103~110がシフト・表参照関数の処理である。
 テーブル生成関数は、乗算の片方の値のみに依存したテーブルを作成するものである。この変数が変更されない限り、テーブルを再び計算する必要はない。片方の値を固定し、他方の値を順次変えて乗算を繰り返すような利用態様では、最初の乗算の際に一度だけテーブル生成関数の処理を行えばよい。本実施形態では、このように片方の元を固定し、他方の元を変えていくような状況における有限体の乗算が特に効率化される。
 本実施形態においては、一例として、有限体はGF(2128)であり、有限体の元は128ビットで表現され、有限体の定義多項式はf(x) = x128 + x7
+ x2 + x + 1であるものとする。そして、本実施形態ではGF(2128)の2つの元XとYの乗算X・Yの計算を行うものとする。
 図1を参照すると、計算機200は、ソフトウェアの処理を実行する32ビットのプロセッサであるCPU(Central Processing Unit)201と、ソフトウェアやデータを記憶する記憶装置であるメモリ202と、を備える。また、CPU201は、複数のレジスタ203と、少なくとも1つのキャリーフラグ204と、を備える。レジスタ203は32ビットであり、キャリーフラグ204は1ビットである。メモリ202は、後述するテーブル生成方法で生成されるテーブルを格納するテーブル格納部205を備える。
 図4を参照すると、計算機200は、テーブルを作成および管理するテーブル管理部401と、データのビット列を並び替える並び替え部402と、2倍算と表参照を繰り返し演算する繰り返し演算部と、を備える。
 CPU201が実行可能な命令セットには、排他的論理和命令XOR A,Bと、論理積命令AND A,Bと、論理和命令OR A,Bと、コピー命令COPY A,Bと、が含まれる。
 排他的論理和命令XOR A,Bは、2つのレジスタA、Bに格納された値に対して、ビット毎の排他的論理和を行い、その結果をAに上書きする命令である。
 論理積命令AND A,Bは、2つのレジスタA、Bに格納された値に対して、ビット毎の論理積を行い、その結果をAに上書きする命令である。
 論理和命令OR A,Bは、2つのレジスタA、Bに格納された値に対して、ビット毎の論理和を行い、その結果をAに上書きする命令である。
 コピー命令COPY A,Bは、Bの値をAにコピーする命令である。
 さらに、CPU201が実行可能な命令セットには、即値との論理積命令ANDi A,IMMと、即値との排他的論理和命令XORi A,IMMと、が含まれる。
 即値との論理積命令ANDi A,IMMは、1つのレジスタAと1つの32ビットの即値IMMに対して、AとIMMのビット毎の論理積を行い、その結果をAに上書きする命令である。
 即値との排他的論理和命令XORi A,IMMは、1つのレジスタAと1つの32ビットの即値IMMに対して、AとIMMとのビット毎の排他的論理和を行い、その結果をAに上書きする命令である。
 さらに、CPU201が実行可能な命令セットには、1ビットシフト命令ROL Aと、キャリー付き1ビットシフト命令ROLC Aと、が含まれる。
 1ビットシフト命令ROL Aは、1つのレジスタAとキャリーフラグCに対して、Aを1ビットだけ左にシフトし、Aからはみ出したAのもとの最上位ビットをCに格納する命令である。
 キャリー付き1ビットシフト命令ROLC Aは、1つのレジスタAとキャリーフラグCに対して、Aを1ビットだけ左にシフトした後にAの最下位ビットにCに格納されているビットを移しAからはみ出したAの元の最上位ビットをCに格納する命令である。
 さらに、CPU201が実行可能な命令セットには、SHR A,immと、SHL A,immと、ROLi A,immと、が含まれる。
 SHR A,immは、1つのレジスタAと1つの即値immに対して、Aをimmビットだけ右にシフトする命令である。
 SHL A,immは、1つのレジスタAと1つの即値immに対して、Aをimmだけ左にシフトする命令である。
 ROLi A,immは、1つのレジスタAと1つの即値immに対して、Aをimmだけ左に巡回シフトする命令である。
 さらに、CPU201が実行可能な命令セットには、IFノットキャリー命令IFNC Mが含まれる。
 IFノットキャリー命令IFNC Mは、キャリーフラグとメモリ番地Mに対して、キャリーフラグが0の場合のみメモリ番地Mにプログラムカウンタを設定する命令である。
 さらに、CPU201が実行可能な命令セットには、メモリロード命令LOAD A,Mが含まれる。
 メモリロード命令LOAD A,Mは、メモリ番地Mに格納されている32ビットデータをレジスタAにコピーする命令である。
 上述した命令のうち、XOR,AND,OR,ANDi,XORi,ROL,ROLC,SHR,SHL,ROLi,IFNC命令はCPU201のALUを用いて1サイクルで実行できるものとする。また、LOAD命令はCPU201のメモリアクセスユニットを用いて1サイクルで実行できるものとする。
 次に、本実施形態の説明に用いる記法について説明する。
 bビット変数Wの各ビットは、左のビットから順にW{0}、W{1}、…、W{b-1}と記述され、W{0}が最上位ビットである。また、W{i}からW{j}までの連続するj-i+1ビットをW{i-j}と記述する。m個の要素を持つテーブルTの要素は、1番目から順にT[0],
T[1], …, T[m-1]と記述される。つまり、i番目の要素がT[i-1]と記述される。
 X・Yは、GF(2128)の元XとYのGF(2128)上の乗算を表す。A^Bは、32ビットのビット列AとBのビット毎排他的論理和を表す。A|Bは、32ビットのビット列AとBのビット毎論理和を表す。A&Bは、32ビットのビット列AとBのビット毎論理積を表す。A||Bは、二つのビット列AとBの結合を表す。A<<nは、32ビット変数Aの左nビットシフトを表す。A>>nは、32ビット変数Aの右nビットシフトを表す。A<<<nは、32ビット変数Aの左nビット巡回シフトを表す。
 2つの整数mとnに対して、m/nとm%nは、それぞれmをnで割った商と余りを表す。
 本実施形態においては、有限体の元Xを4つの32ビットに分割し、それぞれがR0、R1、R2、R3の4つのレジスタ203に格納されるものとする。つまり、R0=X{0-31}、R1=X{32-63}、R2=X{64-95}、R3=X{96-127}である。
 図2を参照して、本実施形態における有限体上での元XとYの乗算の処理について説明する。ここでの有限体上の乗算の利用態様として、元Yは比較的固定されており、元Xが比較的変動するものであるとする。
 テーブル管理部401は、テーブル格納部205に記憶された有限体の元Yに対応するテーブルが格納されているか否か判定する(ステップ100)。元Yに対応するテーブルが格納されている場合、テーブル管理部401は格納されたテーブルを繰り返し演算部403に受け渡す。元Yに対応するテーブルが格納されていない場合、テーブル管理部401は、Yに対応するテーブルを作成して、テーブルをテーブル格納部205に格納し(ステップ101)、テーブルを繰り返し演算部403に受け渡す。
 ステップ101では、テーブル管理部401はCPU201を用いてテーブル生成関数を実行する。
 テーブル生成関数は、有限体の元Yを入力として、256バイトのテーブルTを生成し、テーブルTをテーブル格納部205に格納する関数である。テーブル生成関数のテーブルの生成方法は次の通りである。
 本実施形態においては、有限体の元が128ビットであり、CPUのレジスタ長が32ビットである。そのため、128ビット値が格納される1つのテーブルTを、プログラム上では、テーブルT_0、T_1、T_2、T_3という32ビットの4枚のテーブルに分割して持つことになる。分割されたT_iを以下では小テーブルと呼ぶことにする。
 小テーブルはそれぞれ4ビット入力32ビット出力のテーブルであり、つまり、それぞれの小テーブルは16個の4バイトの要素からなる。従って、各小テーブルはデータ量が64バイトであり、テーブルTのデータ量は4つの小テーブルの合計で256バイトとなる。
 小テーブルのi番目の要素は、インデックスi-1で指定される。つまり、T_0のi番目の要素はT_0[i-1]と記述される。他のテーブルに関しても同様である。各小テーブルのi番目の要素をT_0[i-1],
T_1[i-1], T_2[i-1], T_3[i-1]の順で結合した128ビットがテーブルTのi番目の要素T[i-1]である。つまりT_0[i] = T[i]{0-31}、T_1[i] = T[i]{32-63}、T_2[i]
= T[i]{64-95}、T_3[i] = T[i]{96-127}である。
 ここで、T[i]は以下のように定義される。
T[i] =
Y・g(i)
 ただし、ここで、iは0から15の整数である。iを4ビットで表した場合、gは4ビットの値iから128ビットの値への写像であり、以下のように定義される。
g(i){32*j+31} = i{j} j=0,1,2,3
g(i){j} = 0, j:それ以外
 ただし、ここでg(i){j}およびi{j}は、それぞれg(i)およびiの左からj+1番目のビットである。
 g(i)の32*j+31+1番目のビットには、iの各ビットの有意な値(0または1)がそれぞれ設定され、g(i)のそれ以外のビットには固定的に0が設定されている。このようなg(i)とYとの乗算結果をテーブルTに保持し、そのTの出力を用いることにより、有限体上の乗算を2倍算によって実行することが可能になる。G(i)とYの乗算を行う方法は特に限定されない。また、テーブルTは、メモリ上の一連の領域にiをオフセットとして格納され、iによって参照することができる。図5の(a)は、T[i]の計算を説明する図である。テーブルTの一例として、Y= 0x111bef395a787fa57ce604911142c307とした場合のテーブルが図6に記載してある。
 なお、ステップ101で作成された有限体の元Yに対するテーブルはテーブル格納部205に格納されるため、同じ値の元Yに対応するテーブルが再び必要になった場合、CPU201は、ステップ101に進まず、直接ステップ102に進めばよい。つまり、一方の乗算対象である有限体の元Yを変更せずに、他方の乗算対象である複数の有限体の元Xに対して、XとYの乗算を行う場合、テーブル生成関数は最初の乗算の際にのみ実行すればよく、二度目以降の乗算の際には、テーブル生成関数の実行は省略できる。
 本実施形態において、二度目以降の乗算は特に高速になる。ただし、従来の方法でも二度目以降の乗算は一度目よりも高速になる。従って、本実施形態による計算速度の高速化の効果は、後述において、本実施形態と従来方法とで二度目以降の乗算の速度を比較して検証することにする。
 次にステップ102で行うデータシャッフル関数について説明する。ステップ102は、並び替え部402がXを取得し、データシャッフル関数でXをX´に変換するステップである。
 データシャッフル関数は、128ビットの値Xを入力としてとり、128ビットの値X’を出力する関数である。図3は、XからX’へのビット配置の変換の様子を示す図である。Xをビット数が32である4個の部分に区切り、各部分のそれぞれの同一位置にあるビットを集めると、X’になる。
 X’は、Xのビットの配置を図3のように入れ替えたものであり、X’、Xのjビット目をそれぞれX'{j-1}、X{j-1}とすると、
X'{j} = X{(j%4)*32+j/4} (1)
と表わされる。
 データシャッフル関数を、計算機200で計算する場合は、例えば以下のように計算できる。ただし、Xは4つの32ビット変数X0,
X1, X2, X3に分割され、X=X0||X1||X2||X3であるものとする。まず、X0, X1, X2, X3から4つの32ビットの中間変数S0, S1, S2, S3を計算する。
S0 =
(X0&0xff00ff00)|((X1&0xff00ff00)>>8),
S1 =
((X0&0x00ff00ff)<<8)|(X1&0x00ff00ff),
S2 =
((X2&0xff00ff00)<<<16)|((X3&0xff00ff00)<<<8),
S3 =
((X2&0x00ff00ff)<<<24)|((X3&0x00ff00ff)<<<16).
 さらに、S0, S1, S2, S3から4つの32ビットの中間変数U0, U1, U2, U3を計算する。
U0 =
(S0&0xffff0000)|(S2&0x0000ffff),
U1 =
(S1&0xffff0000)|(S3&0x0000ffff),
U2 =
(S0<<16)|(S2>>16),
U3 =
(S1<<16)|(S3>>16).
 計算前にはX0, X1, X2, X3が、CPU201の備える4つのレジスタ203であるR0, R1, R2, R3にそれぞれ保持されている。CPU201の実行可能な命令を用いて、S0, S1, S2, S3を計算し、さらに、U0, U1, U2, U3を計算する。計算後には、4つのレジスタ203にはU0, U1, U2, U3が格納されている。
 ここでは、この計算の過程で中間値や結果をメモリ202に退避する必要がないだけの十分な数のレジスタ203をCPU201が備えているものとする。そうであれば、計算機200のCPU201が実行可能な命令を用いることにより、38命令でデータシャフルの計算を終えることができる。たとえば、CPU201のレジスタ203の数が16であれば、メモリ退避は不要である。
 次に、CPU201は、各U0, U1, U2, U3に対して以下の計算を行う。
V = (Ui ^ (Ui>>4))&0x00f000f0;
Ui = Ui ^ V ^ (V<<4);
V = (Ui ^
(Ui>>1))&0x22222222; Ui = Ui ^ V ^ (V<<1);
V = (Ui ^
(Ui>>2))&0x0c0c0c0c; Ui = Ui ^ V ^ (V<<2);
V = (Ui ^ (Ui>>1))&0x22222222;
Ui = Ui ^ V ^ (V<<1);
V = (Ui ^
(Ui>>14))&0x0000cccc; Ui = Ui ^ V ^ (V<<14);
V = (Ui ^
(Ui>>8))&0x0000ff00; Ui = Ui ^ V ^ (V<<8);
 以上の計算で得られるUi(i=0,1,2,3)を結合すると、X'が得られる。つまり、X'=U0||U1||U2||U3である。このX'は前記式(1)を満たすものになっている。先ほどと同様にメモリ退避が必要ないだけ数のレジスタ203をCPU201が備えていれば、この計算は、計算機200が実行可能な命令を用いて、176命令で実行できる。たとえば、レジスタ数が16であれば、メモリ退避は不要である。
 従って、データシャッフル関数は、計算機200を用いることで、38+176=214命令で実行できる。
 なお、上述した最終行の2つの式V=(Ui^(Ui>>8))&0x0000ff00;
Ui=Ui^V^(V<<8);の計算は行わなくても、Uiは、後述するx'jを結合した形となる。具体的には、Ui =
x'(8*i)||x'(8*i+1)||x'(8*i+4)||x'(8*i+5)||x'(8*i+2)||x'(8*i+3)||x'(8*i+6)||x'(8*i+7)となる。よって、後述する表参照の処理の際、Uiからx'jを取り出すときに、この形に合うように取り出せば、このUiによって乗算が実行できる。この場合、データシャッフル関数の実行にかかる命令数は214命令から186命令に減る。
 次に、ステップ103~110で実行するシフト・表参照関数について説明する。ステップ103~110は、繰り返し演算部403がZを取得し、以下に説明する演算でZを変換し、変換されたZを出力するステップである。
 シフト・表参照関数は、ステップ102で求められた128ビット値X’とテーブル格納部205にあるテーブルTとを入力とし、それらに基づいて得られる128ビット値Zを出力する関数である。ZはZ=X・Yであり、乗算の計算結果である。
 シフト・表参照関数の処理は以下の手順からなる。
 繰り返し演算部403は、取得したX’を左から4ビット毎に32個に分割する(ステップ103)。つまり、X’=x’0||x’1||…||x’31であり、x'iは4ビット変数とする。図5の(b)は、X’からx’iへの分割の様子を示す図である。
 続いて、繰り返し演算部403は、初期値としてZ=0およびi=0を設定し(ステップ104)、次のループ処理に進む。
 ループ処理において、繰り返し演算部403は、まずZをGF(2128)上で2倍する(ステップ105)。図5の(c)は、ステップ105のZの2倍算の様子を図示したものである。続いて、x’iによってテーブルTを参照し、テーブルTから得られる参照結果をtとおく(t=T[x’i])(ステップ106)。図5の(d)はステップ106のテーブル参照の様子を図示したものである。更に、Zとtとの排他的論理和を求め、その結果を新たにZとする(ステップ107)。図5の(e)はステップ107の排他的論理和の様子を図示したものである。
 ここで、繰り返し演算部403は、はiを1だけインクリメントし(ステップ108)、iが32に達しているか否か判定する(ステップ109)。iが32に達していなければ、CPU201はステップ105に戻ってループ処理を繰り返す。iが32に達していれば、CPU201はループを抜けてステップ110に進む。そして、ループから抜けたときのZを乗算の結果として出力する(ステップ110)。
 以上説明した処理から分かるとおり、ステップ105から109のループ処理のループ回数は32回である。ただし、i=0のときには、Z=0であり、2倍算しても2・Z=0である。そのため、ステップ105とステップ107は行う必要がない。従って、ループにおいてi=0のときにはステップ105とステップ107を省略してもよい。
 128ビット変数Zが4つの32ビット変数Z0,Z1,Z2,Z3に分割され、Z = Z0||Z1||Z2||Z3と表わされる場合、ステップ105におけるGF(2128)上での2倍算は疑似コードであらわすと、
tmp = Z0>>31;
Z0 =
(Z0<<1)|(Z1>>31);
Z1 =
(Z1<<1)|(Z2>>31);
Z2 =
(Z2<<1)|(Z3>>31);
if(tmp==1)
 then
Z3 = (Z3<<1) ^ 0x0000008b;
 else
Z3 = (Z3<<1);
と記述できる。ただし、0x0000008bは、上記の定義多項式から求まるフィードバックのビット列である。このビット列をフィードバックすることにより、2倍算の結果がGF(2128)の元として表現される。
 この2倍算の疑似コードは、計算機200を用いると以下のように6命令で実装できる。ただし、Z0はレジスタR0に格納され、Z1はレジスタR1に格納され、Z2はレジスタR2に格納され、Z3はレジスタR3に格納されているとする。
START of CALC.
ROL R3
ROLC R2
ROLC R1
ROLC R0
IFNC .L0
XORi R3, 0x0000008b
.L0:
END of CALC.
 本実施形態では2倍算を行えばよいので、キャリー付き1ビットシフト演算命令ROLC Aを用いて効率良く処理を実行できる。これに対して従来のように、例えば16倍算であれば、4ビットのシフトが必要なので、あふれる桁の値をキャリーではなく別のレジスタに格納し、その後にレジスタ同士の値を加算するという処理が必要になる。すなわち本発明はXからX’に並び替え、2倍算と4ビットずつの表参照を繰り返し演算することで、従来と同じループ数で計算できる。その結果、従来より高速で計算することが可能である。
 なお、CPU201の命令において、XORiがXORに比べて実行時間が遅い場合、0x0000008bを利用していないレジスタに格納してXOR命令を用いてもよい。ただし、その場合、シフト・表参照関数を1回実行する毎に、1回のメモリアクセス命令が余分に必要となる。
 ステップ106における、x’iによるテーブルTの参照は、tがt=t0||t1||t2||t3と4つの32ビット変数t0, t1, t2, t3に分割されているとして、疑似コードで表わすと、
x'i =
(X'j>>k)&0x0000000f;
t0 = T_0[x'i];
t1 = T_1[x'i];
t2 = T_2[x'i];
t3 = T_3[x'i];
と記述できる。ただし、x'iはX'jの左から(28-k)ビット目から始まる4ビットであるとする。メモリ退避が必要ないだけの数のレジスタがあるとすれば、この疑似コードは、計算機200を用いて2回のALU命令と4回のメモリアクセス命令とで実行できる。例えば、レジスタ数が16であれば、メモリ退避は不要である。
 ステップ107における、Zとtの排他的論理和は、
Z0 = Z0^t0;
Z1 = Z1^t1;
Z2 = Z2^t2;
Z3 = Z3^t3;
と疑似コードで記述できる。メモリ退避が必要ないだけの数のレジスタがあるとすれば、この疑似コードは、計算機200を用いて4回のALU命令で実行できる。例えば、レジスタ数が16であればメモリ退避は不要である。
 なお、ステップ104とステップ108とステップ109での変数iに関する処理は32回のループを実現するための処理である。実装において、ループ処理をアンロールすれば、これらの処理が不要となるので、プログラム実行時間としてはそれだけ削減することができる。
 以下、本実施形態による有限体上の乗算における高速化の効果について検証する。
 本実施形態では、シフト・表参照関数において、2倍算が31回、テーブルTの参照が32回、Zとtの排他的論理和が31回だけ繰り返される。従って、シフト・表参照関数は、6×31+2×32+4×31=374ALU命令と、4×32=128メモリアクセス命令とで実行できる。
 従って、本実施形態によると、Yに対するテーブルがテーブル格納部205にすでに格納されている状況において、計算機200によってX・Yを計算するのに、214+374=588ALU命令と128メモリアクセス命令が必要ということになる。
 なお、前述したように、データシャッフル関数で最後の2つの式の処理を省略した場合、データシャッフル関数の命令数は、214ALU命令から186ALU命令に削減される。この場合、本実施形態による有限体上の乗算は、186+374=560ALU命令と128メモリアクセス命令とで実行できるものとなる。
 本実施形態との比較のために、従来の方法での有限体上の乗算について検討する。
 従来の有限体上の乗算の計算方法は、従来のテーブル生成関数と、従来のシフト・表参照関数とからなる。まず、従来のテーブル生成関数が実行され、次に、従来のシフト・表参照関数が実行される。
 本実施形態と同様に、従来のテーブル生成関数は乗算の片方の変数のみに依存したテーブルを作成するものである。この変数が変更されない限り、テーブルを再び計算する必要はないので、計算は最初の乗算の際に一度だけ行えばよい。
 従来のシフト・表参照関数は、処理量としては、本実施形態におけるシフト・表参照関数における2倍算を16倍算に置き換えたものに相当する。
 GF(2^128)上での16倍算は疑似コードであらわすと、
tmp = Z0>>28;
Z0 =
(Z0<<4)|(Z1>>28);
Z1 =
(Z1<<4)|(Z2>>28);
Z2 = (Z2<<4)|(Z3>>28);
Z3 = (Z3<<4) ^ FBTBL[tmp];
と記述できる。ただし、FBTBLは16ビットまたは32ビットの要素16個からなるテーブルである。このFBTBLは、シフトによりはみ出す最上位4ビットを入力としてとり、その4ビットに対して定義多項式から得られるフィードバックの値を返すテーブルである。
 この疑似コードは、メモリ退避が必要ないだけの数のレジスタがあるとすれば、計算機200を用いて、以下のようにALU16命令とメモリアクセス1命令とで実行できる。ただし、Z0はレジスタR0に格納され、Z1はレジスタR1に格納され、Z2はレジスタR2に格納され、Z3はレジスタR3に格納されているとする。レジスタR4,R5,R6,R7は中間値を格納するために用いられている。
START of CALC.
COPY R4, R0
COPY R5, R1
COPY R6, R2
COPY R7, R3
SHL R0, 4
SHR R4, 28
SHL R1, 4
SHR R5, 28
SHL R2, 4
SHR R6, 28
SHL R3, 4
SHR R7, 28
OR R0, R5
OR R1, R6
OR R2, R7
LOAD R4, FBTBL[R4]
XOR R3, R4
END of CALC.
 以上より、従来のシフト・表参照関数では、16倍算が31回、テーブルTでの参照が32回、Zとtの排他的論理和が31回だけ繰り返される。従って、シフト・表参照関数は16×31+2×32+4×31=684ALU命令と1×31+4×32=159メモリアクセス命令とで実行できるということになる。
 従って、従来の方法を用いて、Yに対するテーブルがテーブル格納部205にすでに格納されている状況において、計算機200でX・Yを計算するには、684ALU命令と159メモリアクセス命令が必要ということになる。
 これら本実施形態と従来の方法とを比べると、本実施形態によれば従来の方法よりも命令数を約20%削減されると言える。さらに本実施形態では、FBTBLが必要ないため、その分のメモリ量32バイトまたは64バイトも削減できる。
 なお、本実施形態による高速化の効果をモデルによって検証するために、CPU201の備える命令とその実行時間について仮定を行ったが、これ以外のモデルのCPUを用いた場合にも本発明を適用することはできる。
 また、本実施形態では、有限体は128ビットの大きさであり、表参照は4ビット毎に行うものとした例を示した。しかし、本発明がこの組み合わせに限定されることは無い。例えば、有限体が256ビットの大きさであり、表参照を8ビット毎に行うものとすることも可能である。更には、これら以外に、有限体の大きさと参照表のビット数を任意に組み合わせて本発明を適用することが可能である。
 また、本実施形態における計算機200は、ソフトウェアプログラムを実行することにより実現される機能ブロックによって、上述したような各機能を実現するものである。図4は、本実施形態における計算機200の機能ブロック図である。図1は計算機200のハードウェア構成に着目した構成図であったが、図4は計算機200の機能に着目した機能ブロック図である。
 図4を参照すると、計算機200は、テーブル管理部401、並べ替え部402、および繰り返し演算部403を有している。各部の基本的な機能は一例として以下の通りであり、更に上述したような様々な機能を果たす。
 テーブル管理部401は、一方の乗算対象である128ビットの元Yと、128ビットのうち32番目のビットから32ビット毎の4ビットに0か1を設定し、その他のビットを0に設定した16個の元g(i)との乗算の結果であるビット列をテーブルに保持する。
 並べ替え部402は、もう一方の乗算対象である元Xを、32ビットの4個の第1の部分ビット列に区切り、それら部分ビット列のそれぞれの同一位置にあるビットを集めることにより、元Xのビット列のビットの順番を並び替え、並び替えたビット列を、ビット数が4である32個の第2の部分ビット列とする。
 繰り返し演算部403は、有限体上での2倍算を行い、その2倍算の結果と、第2の部分ビット列に基づいてテーブルから選択したビット列とのビット毎の排他的論理和を行うという演算を32回繰り返す。
 また、本実施形態に適用した技術は、例えば、組み込み向けCPU等のような低リソース機器を用いたシステムに、有限体の乗算を用いたアルゴリズムを実装する場合などに広く適用できる。低リソース機器においては、実装の高速性と省メモリ性が要求される場合が多く、本発明を適用することでこのニーズに応えることが可能になる。有限体上の乗算を用いたアルゴリズムの例としては、例えば、認証暗号方式GCM、MULTI-S01等の暗号アルゴリズム、および、各種符号アルゴリズム等が挙げられる。
200…計算機、201…CPU、202…メモリ、203…レジスタ、204…キャリーフラグ、205…テーブル格納部、401…テーブル管理部、402…並べ替え部、403…演算部
 

Claims (6)

  1.  プロセッサによって有限体上の乗算を行うための、有限体上の乗算方法であって、
     テーブル管理手段が、前記有限体の元であり一方の乗算対象である第1の元と、n番目のビットからnビット毎のm個のビットに0か1を設定し他のビットに0を設定した前記有限体の(2^m)個の元との乗算の結果である(2^m)個の第1のビット列をテーブルとして保持する第1のステップと、
     繰り返し演算手段が、前回のシフト・表参照演算の結果に前記有限体上での2倍算を行い、前記2倍算の結果と、前記有限体の元であり他方の乗算対象である第2の元に基づいて前記テーブルから選択した第1のビット列とのビット毎の排他的論理和を行うシフト・表演算を繰り返す第2のステップと、
    を有する有限体上の乗算方法。
  2.  前記第1のステップにおいて、前記テーブル管理手段が、前記(2^m)個の第1のビット列を、前記m個のビットで表現されるビット数がm個の値に対応づけて、前記テーブルとして保持し、
     前記第2のステップが開始される前に、並べ替え手段が、前記第2の元のビット列を、ビット数がnであるm個の第1の部分ビット列に区切り、前記第1の部分ビット列のそれぞれの同一位置にあるビットを集めることにより、前記ビット列のビットの順番を並び替え、並び替えた前記ビット列を、ビット数がmであるn個の第2の部分ビット列とする第3のステップを更に有し、
     前記第2のステップにおいて、前記繰り返し演算手段が、前記2倍算の結果と、前記各第2の部分ビット列で表現される値による前記テーブルの参照で得られる第1のビット列とのビット毎の排他的論理和を行う、
    請求項1に記載の有限体上の乗算方法。
  3.  前記第1のステップは、
     前記第1の元と、n番目のビットからnビット毎に0か1の値を設定し他のビットに0を設定した前記有限体の(2^m)個の元との乗算を行う第4のステップと、
     前記乗算の結果である(2^m)個の第1のビット列をテーブルとして記録する第5のステップと、を含む、請求項1に記載の有限体上の乗算方法。
  4.  前記プロセッサは、キャリー付き1ビットシフト演算命令を実行することができ、
     前記繰り返し演算手段が、前記キャリー付き1ビットシフト演算命令を用いて、前記第2のステップにおける前記2倍算を行う、
    請求項1に記載の有限体上の乗算方法。
  5.  プロセッサによって有限体上の乗算を行う計算機であって、
     前記有限体の元であり一方の乗算対象である第1の元と、n番目のビットからnビット毎のm個のビットに0か1を設定し他のビットに0を設定した前記有限体の(2^m)個の元との乗算の結果である(2^m)個の第1のビット列をテーブルとして保持するテーブル管理部と、
     前回のシフト・表参照演算の結果に前記有限体上での2倍算を行い、前記2倍算の結果と、前記有限体の元であり他方の乗算対象である第2の元に基づいて前記テーブルから選択した第1のビット列とのビット毎の排他的論理和を行うシフト・表演算演算を繰り返す繰り返し演算部と、を有する計算機。
  6.  有限体上の乗算をコンピュータに行わせるためのプログラムであって、
     前記有限体の元であり一方の乗算対象である第1の元と、n番目のビットからnビット毎のm個のビットに0か1を設定し他のビットに0を設定した前記有限体の(2^m)個の元との乗算の結果である(2^m)個の第1のビット列をテーブルとして保持する手順と、
     前回のシフト・表参照演算の結果に前記有限体上での2倍算を行い、前記2倍算の結果と、前記有限体の元であり他方の乗算対象である第2の元に基づいて前記テーブルから選択した第1のビット列とのビット毎の排他的論理和を行うシフト・表参照演算を繰り返す手順と、をコンピュータに実行させるためのプログラム。
     
     
     
     
     
     
     
     
     
     
     
     
     
PCT/JP2011/073136 2011-10-06 2011-10-06 有限体上の乗算方法、計算機、およびプログラム WO2013051139A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2011/073136 WO2013051139A1 (ja) 2011-10-06 2011-10-06 有限体上の乗算方法、計算機、およびプログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2011/073136 WO2013051139A1 (ja) 2011-10-06 2011-10-06 有限体上の乗算方法、計算機、およびプログラム

Publications (1)

Publication Number Publication Date
WO2013051139A1 true WO2013051139A1 (ja) 2013-04-11

Family

ID=48043330

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2011/073136 WO2013051139A1 (ja) 2011-10-06 2011-10-06 有限体上の乗算方法、計算機、およびプログラム

Country Status (1)

Country Link
WO (1) WO2013051139A1 (ja)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003529233A (ja) * 1999-08-27 2003-09-30 モトローラ・インコーポレイテッド データを符号化及び復号化する方法及び装置
JP2004135172A (ja) * 2002-10-11 2004-04-30 Motorola Inc ガロア体掛け算器の制御方法

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003529233A (ja) * 1999-08-27 2003-09-30 モトローラ・インコーポレイテッド データを符号化及び復号化する方法及び装置
JP2004135172A (ja) * 2002-10-11 2004-04-30 Motorola Inc ガロア体掛け算器の制御方法

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
M. ANWARUL HASAN: "Look-up table-based large finite field multiplication in memory constrained cryptosystems", IEEE TRANSACTIONS ON COMPUTERS, vol. 49, no. 7, July 2000 (2000-07-01), pages 749 - 758, XP002317228 *
YOICHI HADAMA ET AL.: "An Improved Method for the Table Lookup Multiplication Algorithm over GF(2m)", IPSJ SIG NOTES, vol. 2006, no. 81, 21 July 2006 (2006-07-21), pages 95 - 102 *

Similar Documents

Publication Publication Date Title
Bernstein et al. NEON crypto
Hutter et al. Fast multi-precision multiplication for public-key cryptography on embedded microprocessors
Hutter et al. NaCl on 8-bit AVR microcontrollers
Abdulrahman et al. Faster kyber and dilithium on the cortex-m4
Balasch et al. Compact implementation and performance evaluation of hash functions in attiny devices
Oliveira et al. How to (pre-) compute a ladder: Improving the performance of X25519 and X448
JP4662744B2 (ja) モンゴメリ乗算におけるsimd命令の使用
Liu et al. New speed records for Montgomery modular multiplication on 8-bit AVR microcontrollers
Bos et al. Fly, you fool! Faster Frodo for the ARM Cortex-M4
Bernstein et al. Really fast syndrome-based hashing
Gouvêa et al. Implementing gcm on armv8
JP2005122141A5 (ja)
JP2002229445A (ja) べき乗剰余演算器
Seo et al. Optimized SIKE Round 2 on 64-bit ARM
JP3726966B2 (ja) 乗算器及び暗号回路
Orhanou et al. SNOW 3G stream cipher operation and complexity study
Seo et al. Compact LEA and HIGHT implementations on 8-bit AVR and 16-bit MSP processors
Chen et al. Faster multiplication for long binary polynomials
CN116318660B (zh) 一种消息扩展与压缩方法及相关装置
CN110034918B (zh) 一种sm4加速方法和装置
Oliveira et al. Software implementation of Koblitz curves over quadratic fields
WO2013051139A1 (ja) 有限体上の乗算方法、計算機、およびプログラム
Eisenbarth et al. Evaluation of sha-3 candidates for 8-bit embedded processors
JP2002358010A (ja) べき乗剰余演算器
Liu et al. Multiprecision multiplication on armv8

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11873764

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11873764

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP