JP2017058501A - Hash function calculation device and method - Google Patents

Hash function calculation device and method Download PDF

Info

Publication number
JP2017058501A
JP2017058501A JP2015182843A JP2015182843A JP2017058501A JP 2017058501 A JP2017058501 A JP 2017058501A JP 2015182843 A JP2015182843 A JP 2015182843A JP 2015182843 A JP2015182843 A JP 2015182843A JP 2017058501 A JP2017058501 A JP 2017058501A
Authority
JP
Japan
Prior art keywords
bit
calculation result
register
acc
value
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
JP2015182843A
Other languages
Japanese (ja)
Inventor
孝 青木
Takashi Aoki
孝 青木
昭彦 宮崎
Akihiko Miyazaki
昭彦 宮崎
孝裕 羽田野
Takahiro Hatano
孝裕 羽田野
望 戸川
Nozomi Togawa
望 戸川
健太 島崎
Kenta SHIMAZAKI
健太 島崎
俊隆 津田
Toshitaka Tsuda
俊隆 津田
容震 朴
Yong-Jin Park
容震 朴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Waseda University
Nippon Telegraph and Telephone Corp
Original Assignee
Waseda University
Nippon Telegraph and Telephone Corp
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 Waseda University, Nippon Telegraph and Telephone Corp filed Critical Waseda University
Priority to JP2015182843A priority Critical patent/JP2017058501A/en
Publication of JP2017058501A publication Critical patent/JP2017058501A/en
Pending legal-status Critical Current

Links

Images

Abstract

PROBLEM TO BE SOLVED: To provide a hash function calculation device with which it is possible to reduce a circuit scale while maintaining sufficient uniformity.SOLUTION: A linear feedback shift register 11 generates N bit random number data R on the basis of previously designated M series each time a bit value B is held by an input register 13. An exclusive OR circuit 12 calculates the bitwise exclusive OR of the random number data and a calculation result ACC, and outputs N bit calculation result Q. An ACC register 15 holds the calculation result Q from the exclusive OR circuit 12 as a new calculation result ACC only when the bit value B held by the input register 13 is 1, and outputs a calculation result ACC obtained by acquiring up to the last bit as a hash value OUT.SELECTED DRAWING: Figure 1

Description

本発明は、ハッシュ関数計算技術に関し、特に入力された引数を乱数データでマスク処理した後にリダクション処理することにより、ハッシュ関数の値であるハッシュ値を計算するハッシュ関数計算技術に関する。   The present invention relates to a hash function calculation technique, and more particularly to a hash function calculation technique for calculating a hash value which is a value of a hash function by performing a reduction process after masking an input argument with random number data.

ハッシュ関数計算処理をデジタル回路で実装する場合、計算結果の一様性に加えて、計算処理の軽量性が求められる。なお、本発明では、デジタル回路での実装を考慮して、引数の変域およびハッシュ値の値域、さらにはこれらのビット桁数が一定であるハッシュ関数を前提とする。
従来より、このような実装条件におけるハッシュ関数計算手法として、線形合同法(LCGs:Linear Congruential Generators)が広く用いられている(非特許文献1など参照)。この線形合同法は、疑似乱数列(以下は乱数列と表記)を生成するアルゴリズムの1つであり、その一般形は次の漸化式(1)で表される。

Figure 2017058501
When the hash function calculation process is implemented with a digital circuit, in addition to the uniformity of the calculation result, the lightness of the calculation process is required. In the present invention, in consideration of implementation in a digital circuit, a domain of arguments, a range of hash values, and a hash function in which the number of bit digits is constant are assumed.
Conventionally, linear congruential generators (LCGs) have been widely used as a hash function calculation method under such mounting conditions (see Non-Patent Document 1, etc.). This linear congruence method is one of algorithms for generating a pseudo-random number sequence (hereinafter referred to as a random number sequence), and its general form is represented by the following recurrence formula (1).
Figure 2017058501

この式(1)において、X0が乱数シードに相当し、A、B、Mは定数で、M>A、M>B、A>0、B≧0である。生成される乱数列は周期性を持ち、周期は最大でMであり、BとMが互いに素であること、A−1がMの持つ全ての素因数で割りきれること、Mが4の倍数である場合はA−1も4の倍数であることが、それぞれ満たされたときに最大周期Mを持つ。 In this equation (1), X 0 corresponds to a random number seed, A, B, and M are constants, and M> A, M> B, A> 0, and B ≧ 0. The generated random number sequence has periodicity, the period is M at maximum, B and M are relatively prime, A-1 can be divided by all the prime factors of M, and M is a multiple of 4. In some cases, A-1 also has a maximum period M when each is satisfied to be a multiple of 4.

したがって、線形合同法は、ほとんど記憶領域を必要とせず、実用的な擬似乱数アルゴリズムでは極めて簡素であり、低機能なプロセッサ上でも極めて高速に実装できる。また、乗算と除算が必要に見えるが、定数による乗算なのでシフトと加減算の組合せにでき、除算そのものが必要なのではなく剰余が得られれば良いので合同算術による式変形が可能、などの理由から効率的な式に変形できる。このため、他のハッシュ関数計算手法に比較して、デジタル回路化が容易であるとされている。   Therefore, the linear congruence method requires almost no storage area, is very simple with a practical pseudo-random number algorithm, and can be implemented very fast even on a low-function processor. In addition, multiplication and division seem to be necessary, but since it is multiplication by constants, it can be combined with shift and addition and subtraction, division is not necessary, it is only necessary to obtain a remainder, so it is possible to modify the expression by congruent arithmetic, etc. Can be transformed into a typical expression. For this reason, it is said that digital circuitization is easy compared with other hash function calculation methods.

「線形合同法」、Wikipedia、https://ja.wikipedia.org/wiki/%E7%B7%9A%E5%BD%A2%E5%90%88%E5%90%8C%E6%B3%95`` Linear joint method '', Wikipedia, https://en.wikipedia.org/wiki/%E7%B7%9A%E5%BD%A2%E5%90%88%E5%90%8C%E6%B3%95 「線形帰還シフトレジスタ」、Wikipedia、https://ja.wikipedia.org/wiki/%E7%B7%9A%E5%BD%A2%E5%B8%B0%E9%82%84%E3%82%B7%E3%83%95%E3%83%88%E3%83%AC%E3%82%B8%E3%82%B9%E3%82%BF`` Linear feedback shift register '', Wikipedia, https://en.wikipedia.org/wiki/%E7%B7%9A%E5%BD%A2%E5%B8%B0%E9%82%84%E3%82% B7% E3% 83% 95% E3% 83% 88% E3% 83% AC% E3% 82% B8% E3% 82% B9% E3% 82% BF

しかしながら、このような線形合同法を用いた従来技術では、漸化式を効率的な式に変形可能ではあるが、加減算や剰余を計算するための回路が必要となるため、ある程度の回路規模が必要となり、計算処理のさらなる軽量化に対応できないという問題点があった。   However, in the conventional technique using such a linear congruential method, the recurrence formula can be transformed into an efficient formula, but a circuit for calculating addition / subtraction and remainder is required, so that a certain circuit scale is required. There is a problem that it is necessary and cannot cope with further weight reduction of calculation processing.

計算処理の軽量性という観点からすれば、ハッシュ関数計算処理として、予め一様性のある乱数表を用意しておき、入力された引数でこの乱数表の乱数パタンをマスク処理する手法が考えられる。   From the viewpoint of lightness of calculation processing, a method of preparing a random number table with uniformity in advance as a hash function calculation processing and masking the random number pattern of this random number table with an input argument can be considered. .

図3は、ハッシュ関数計算処理の構成例である。ここでは、16ビットの引数を入力として、4ビットのハッシュ値を計算する例が示されており、乱数表として、16ビットの乱数パタンが1ビットずつずらして並べられた16ビット×4ビットの乱数表が用いられている。   FIG. 3 is a configuration example of the hash function calculation process. Here, an example in which a 16-bit argument is input and a 4-bit hash value is calculated is shown. As a random number table, a 16-bit × 4-bit 16-bit random number pattern is arranged by shifting one bit at a time. A random number table is used.

この構成例では、まず、乱数表のうちから、入力された引数のうちビット値が「1」である行と対応する行の乱数データ(4ビット分)をそれぞれ読み取ることにより、引数で乱数パタンをマスク処理する。この後、得られた各乱数データを、ビット桁ごとに排他的論理和(EXOR:EXclusive OR)を演算することにより、4ビットのハッシュ値が求められる。   In this configuration example, first, random number patterns (4 bits) corresponding to the row having the bit value “1” in the input argument are read from the random number table, respectively. Is masked. Thereafter, a 4-bit hash value is obtained by calculating exclusive OR (EXOR) for each bit digit of the obtained random number data.

しかしこのような簡素な構成例であっても、一様性のある乱数表を準備しておく必要があり、このような乱数表の記憶もしくは生成のための回路構成や処理が必要となる。また、より大きな引数の変域やハッシュ値の値域を持つハッシュ関数を実現するためには、必要となる記憶資源が大幅に増加するため、回路規模が増大し、装置の小型化・集積化・低コスト化の妨げとなるという問題点があった。   However, even with such a simple configuration example, it is necessary to prepare a uniform random number table, and a circuit configuration and processing for storing or generating such a random number table are required. Also, in order to realize a hash function with a larger range of arguments and a range of hash values, the required storage resources will increase significantly, increasing the circuit scale and reducing the size and integration of the device. There was a problem that the cost was hindered.

本発明はこのような課題を解決するためのものであり、十分な一様性を確保しつつ、回路規模を削減できるハッシュ関数計算技術を提供することを目的としている。   An object of the present invention is to solve such a problem, and an object of the present invention is to provide a hash function calculation technique capable of reducing the circuit scale while ensuring sufficient uniformity.

このような目的を達成するために、本発明にかかるハッシュ関数計算装置は、入力されたM(Mは2以上の整数)ビットの引数から、N(NはMより小さい整数)ビットのハッシュ値を計算して出力するハッシュ関数計算装置であって、前記引数を先頭ビットから最終ビットまで1ビットずつ取得し、ビット値として順次保持する入力レジスタと、予め指定されたM系列に基づいて、前記入力レジスタで前記ビット値を保持するごとにNビットの乱数データを発生させる線形帰還シフトレジスタと、前記入力レジスタで保持した前記ビット値までの計算過程で得られたNビットの計算結果を保持するACCレジスタと、前記乱数データと前記計算結果とについてビットごとに排他的論理和を演算してNビットの演算結果を出力する排他的論理和回路とを備え、前記ACCレジスタは、前記入力レジスタのビット値が1の場合にのみ、前記排他的論理和回路からの演算結果を新たな計算結果として保持し、前記最終ビットまで取得して得られた前記計算結果を前記ハッシュ値として出力するようにしたものである。   In order to achieve such an object, the hash function calculation device according to the present invention uses a hash value of N (N is an integer smaller than M) bits from an input M (M is an integer of 2 or more) bits argument. Is a hash function calculation device that calculates and outputs the argument, and obtains the argument bit by bit from the first bit to the last bit, and sequentially holds it as a bit value, and based on a previously designated M sequence, A linear feedback shift register that generates N-bit random number data each time the bit value is held in the input register, and an N-bit calculation result obtained in the calculation process up to the bit value held in the input register Exclusive logic that calculates an exclusive OR for each bit of the ACC register, the random number data, and the calculation result and outputs an N-bit calculation result And the ACC register holds the operation result from the exclusive OR circuit as a new calculation result only when the bit value of the input register is 1, and obtains up to the last bit. The calculated result is output as the hash value.

また、本発明にかかる上記ハッシュ関数計算装置の一構成例は、前記入力レジスタのビット値が1の場合には前記排他的論理和回路からの演算結果を選択するとともに、当該ビット値が0の場合には前記ACCレジスタからの計算結果を選択するセレクタをさらに備え、前記ACCレジスタは、前記入力レジスタでビット値を保持するごとに前記セレクタで選択された選択出力を新たな計算結果として保持するようにしたものである。   In addition, when the bit value of the input register is 1, the configuration example of the hash function calculation apparatus according to the present invention selects an operation result from the exclusive OR circuit and the bit value is 0. In some cases, the apparatus further includes a selector for selecting a calculation result from the ACC register, and the ACC register holds a selection output selected by the selector as a new calculation result every time the bit value is held in the input register. It is what I did.

また、本発明にかかるハッシュ関数計算方法は、入力されたM(Mは2以上の整数)ビットの引数から、N(NはMより小さい整数)ビットのハッシュ値を計算して出力するハッシュ関数計算装置で用いられるハッシュ関数計算方法であって、入力レジスタが、前記引数を先頭ビットから最終ビットまで1ビットずつ取得し、ビット値として順次保持するステップと、線形帰還シフトレジスタが、予め指定されたM系列に基づいて、前記入力レジスタで前記ビット値を保持するごとにNビットの乱数データを発生させるステップと、
ACCレジスタが、前記入力レジスタで保持した前記ビット値までの計算過程で得られたNビットの計算結果を保持するステップと、排他的論理和回路が、前記乱数データと前記計算結果とについてビットごとに排他的論理和を演算し、Nビットの演算結果を出力するステップとを備え、前記ACCレジスタは、前記入力レジスタのビット値が1の場合にのみ、前記排他的論理和回路からの演算結果を新たな計算結果として保持し、前記最終ビットまで取得して得られた前記計算結果を前記ハッシュ値として出力するステップを有している。
Also, the hash function calculation method according to the present invention calculates and outputs a hash value of N (N is an integer smaller than M) from an input M (M is an integer of 2 or more) bits and outputs the hash value. A hash function calculation method used in a computing device, wherein an input register acquires the argument bit by bit from the first bit to the last bit and sequentially holds it as a bit value, and a linear feedback shift register is designated in advance. Generating N-bit random number data every time the input register holds the bit value based on the M sequence;
An ACC register holding an N-bit calculation result obtained in a calculation process up to the bit value held in the input register; and an exclusive OR circuit for each bit of the random number data and the calculation result And an N-bit operation result is output, and the ACC register outputs the operation result from the exclusive-OR circuit only when the bit value of the input register is 1. Is stored as a new calculation result, and the calculation result obtained by acquiring up to the last bit is output as the hash value.

本発明によれば、事前に乱数表をメモリ等に記憶しておくかわりに、LFSRにより乱数データが生成され、この乱数データに基づいて、統計的には一様乱数表を使う場合に近いハッシュ演算を行うことができる。したがって、一様性のある乱数表を準備しておく必要がなくなるため、このような乱数表の記憶もしくは生成のための回路構成や処理が不要となる。また、より大きな引数の変域やハッシュ値の値域を持つハッシュ関数を実現する場合でも、必要となる記憶資源はほとんど増加しない。このため、十分な一様性を確保しつつ、回路規模を削減でき、装置の小型化や集積化、さらには低コスト化を実現することが可能となる。   According to the present invention, instead of storing a random number table in a memory or the like in advance, random number data is generated by LFSR, and based on this random number data, a hash that is statistically close to the case of using a uniform random number table is used. Arithmetic can be performed. Accordingly, it is not necessary to prepare a uniform random number table, and thus a circuit configuration and processing for storing or generating such a random number table are not necessary. Even when a hash function having a larger range of arguments or a range of hash values is realized, the required storage resources hardly increase. For this reason, it is possible to reduce the circuit scale while ensuring sufficient uniformity, and to achieve downsizing and integration of the device and further cost reduction.

本実施の形態にかかるハッシュ関数計算装置の構成を示すブロック図である。It is a block diagram which shows the structure of the hash function calculation apparatus concerning this Embodiment. ハッシュ関数計算処理を示すフローチャートである。It is a flowchart which shows a hash function calculation process. ハッシュ関数計算処理の構成例である。It is an example of a structure of a hash function calculation process.

次に、本発明の一実施の形態について図面を参照して説明する。
[ハッシュ関数計算装置]
まず、図1を参照して、本発明の第1の実施の形態にかかるハッシュ関数計算装置10について説明する。図1は、本実施の形態にかかるハッシュ関数計算装置の構成を示すブロック図である。
Next, an embodiment of the present invention will be described with reference to the drawings.
[Hash function calculator]
First, with reference to FIG. 1, the hash function calculation apparatus 10 concerning the 1st Embodiment of this invention is demonstrated. FIG. 1 is a block diagram showing the configuration of the hash function calculation apparatus according to this embodiment.

このハッシュ関数計算装置10は、全体としてLSIなどの集積回路に実装可能なデジタル回路から構成されており、入力されたM(Mは2以上の整数)ビットの引数INから、N(NはMより小さい整数)ビットのハッシュ値OUTを計算して出力する回路装置である。   The hash function calculation device 10 is composed of a digital circuit that can be mounted on an integrated circuit such as an LSI as a whole. From the input argument IN of M (M is an integer of 2 or more) bits, N (N is M This is a circuit device that calculates and outputs a hash value OUT of (smaller integer) bits.

ハッシュ関数計算装置10には、主な回路部として、線形帰還シフトレジスタ(LFSR:Linear Feedback Shift Register)11、排他的論理和(EXOR)回路12、入力レジスタ13、セレクタ14、ACCレジスタ15、および制御部16が設けられている。   The hash function calculation apparatus 10 includes, as main circuit parts, a linear feedback shift register (LFSR) 11, an exclusive OR (EXOR) circuit 12, an input register 13, a selector 14, an ACC register 15, and A control unit 16 is provided.

線形帰還シフトレジスタ11は、予め指定された多項式で生成される、所定周期のM系列に基づいて、入力レジスタ13でビット値Bを保持するごとにNビットの乱数データRを発生させる機能を有している。LFSRの具体例としては、例えば非特許文献2などの公知技術を用いればよい。   The linear feedback shift register 11 has a function of generating N-bit random number data R every time the bit value B is held in the input register 13 based on an M-sequence having a predetermined period generated by a polynomial specified in advance. doing. As a specific example of the LFSR, for example, a known technique such as Non-Patent Document 2 may be used.

排他的論理和回路12は、線形帰還シフトレジスタ11からの乱数データRと、ACCレジスタ15からの計算結果ACCとについて、ビットごとに排他的論理和を演算し、Nビットの演算結果Qを出力する機能を有している。   The exclusive OR circuit 12 calculates an exclusive OR for each bit of the random number data R from the linear feedback shift register 11 and the calculation result ACC from the ACC register 15 and outputs an N-bit operation result Q. It has a function to do.

入力レジスタ13は、ハッシュ関数計算装置10の外部から入力される引数INを、その先頭ビットから最終ビットまで1ビットずつ取得し、ビット値Bとして順に保持する機能を有している。   The input register 13 has a function of acquiring an argument IN input from the outside of the hash function calculation apparatus 10 one bit at a time from the first bit to the last bit, and sequentially holding it as a bit value B.

セレクタ14は、入力レジスタ13で保持したビット値Bが1の場合には演算結果Qを選択し選択出力Dとして出力する機能と、当該ビット値Bが0の場合には計算結果ACCを選択し選択出力Dとして出力する機能とを有している。   The selector 14 selects the calculation result Q when the bit value B held in the input register 13 is 1, and outputs it as the selection output D. When the bit value B is 0, the selector 14 selects the calculation result ACC. And a function of outputting as a selection output D.

ACCレジスタ15は、入力レジスタで保持したビット値Bまでの計算過程で得られたNビットの計算結果ACCを保持する機能と、入力レジスタ13で保持したビット値Bに基づいてセレクタ14で選択された選択出力Dを、新たな計算結果ACCとして保持する機能と、入力レジスタ13により最終ビットまで取得して得られた計算結果ACCをハッシュ値OUTとして出力する機能とを有している。   The ACC register 15 is selected by the selector 14 based on the function of holding the N-bit calculation result ACC obtained in the calculation process up to the bit value B held in the input register and the bit value B held in the input register 13. A function of holding the selected output D as a new calculation result ACC, and a function of outputting the calculation result ACC obtained up to the last bit by the input register 13 as a hash value OUT.

制御部16は、入力レジスタ13でのビット値Bの保持に応じて、ACCレジスタ15での保持動作を制御する機能と、ACCレジスタ15での保持動作完了後、線形帰還シフトレジスタ11で発生させる乱数データRを更新する機能とを有している。   The control unit 16 controls the holding operation in the ACC register 15 according to the holding of the bit value B in the input register 13 and the linear feedback shift register 11 after the holding operation in the ACC register 15 is completed. And a function of updating the random number data R.

[本実施の形態の動作]
次に、本実施の形態にかかるハッシュ関数計算装置10の動作について説明する。
入力されたハッシュ関数の引数INは、複数のビットにより構成される2進表現において、1単位時間(以下クロック)に1ビットずつ、先頭ビットから最終ビットまで順に到来するものとする。以下では、引数INのビット数MがM=4ビットである場合を例として説明するが、これに限定されるものではない。
[Operation of this embodiment]
Next, the operation of the hash function calculation apparatus 10 according to this embodiment will be described.
The input hash function argument IN is assumed to arrive in order from the first bit to the last bit, one bit per unit time (hereinafter, clock) in a binary representation composed of a plurality of bits. Hereinafter, a case where the number of bits M of the argument IN is M = 4 bits will be described as an example, but the present invention is not limited to this.

線形帰還シフトレジスタ11からは、入力レジスタ13でビット値Bを保持するごとに、M系列に沿って1ビットずつシフトする、Nビットの乱数データRが順に出力される。この乱数データRは、図3の乱数表から読み取られる乱数データ(4ビット分)に相当している。   Each time the bit value B is held in the input register 13, the linear feedback shift register 11 sequentially outputs N-bit random number data R that is shifted by one bit along the M series. This random number data R corresponds to random number data (for 4 bits) read from the random number table of FIG.

したがって、線形帰還シフトレジスタ11から新たな乱数データRが出力されるごとに、排他的論理和回路12で、この乱数データRと、ACCレジスタ15で保持されている計算結果ACCとの排他的論理和が演算されてリダクション処理され、得られた演算結果Qがセレクタ14の一方の選択入力として入力されることになる。   Accordingly, every time new random number data R is output from the linear feedback shift register 11, the exclusive OR circuit 12 performs exclusive logic between the random number data R and the calculation result ACC held in the ACC register 15. The sum is calculated and reduced, and the obtained calculation result Q is input as one selection input of the selector 14.

ここで、セレクタ14は、入力レジスタ13で保持されたビット値Bが1を示す場合、排他的論理和回路12からの演算結果Qを選択してACCレジスタ15に出力し、ビット値Bが0を示す場合、計算結果ACC選択してACCレジスタ15に出力する。   Here, when the bit value B held in the input register 13 indicates 1, the selector 14 selects the operation result Q from the exclusive OR circuit 12 and outputs it to the ACC register 15, and the bit value B is 0. , The calculation result ACC is selected and output to the ACC register 15.

このため、引数INを構成するMビットのうち、ビット値Bが1を示すビットに対応する乱数データRと計算結果ACCとの排他的論理和である演算結果Qだけが、セレクタ14により選択されてマスク処理されることになり、ACCレジスタ15で計算結果ACCとして保持されることになる。   Therefore, only the operation result Q that is the exclusive OR of the random number data R corresponding to the bit whose bit value B indicates 1 and the calculation result ACC among the M bits constituting the argument IN is selected by the selector 14. Thus, the mask process is performed, and the calculation result ACC is held in the ACC register 15.

これにより、入力レジスタ13で新たなビット値Bを保持するごとに、それまで選択されたすべての乱数データRの排他的論理和が排他的論理和回路12で演算されて、セレクタ14で選択出力Dとして選択され、ACCレジスタ15で計算結果ACCとして保持されることになる。したがって、最終ビットが保持されてセレクタ14で選択された選択出力Dが、引数INに対応するハッシュ値OUTに相当することになる。   Thus, every time a new bit value B is held in the input register 13, the exclusive OR of all the random number data R selected so far is calculated by the exclusive OR circuit 12 and selected by the selector 14. D is selected and held in the ACC register 15 as the calculation result ACC. Therefore, the selection output D selected by the selector 14 while the last bit is held corresponds to the hash value OUT corresponding to the argument IN.

[ハッシュ関数計算処理]
次に、図2を参照して、本実施の形態にかかるハッシュ関数計算装置10の動作について説明する。図2は、ハッシュ関数計算処理を示すフローチャートである。
ハッシュ関数計算装置10は、入力された引数INのハッシュ値OUTを計算する際、図2のハッシュ関数計算処理を実行する。
[Hash function calculation processing]
Next, the operation of the hash function calculation apparatus 10 according to the present embodiment will be described with reference to FIG. FIG. 2 is a flowchart showing hash function calculation processing.
When the hash function calculation apparatus 10 calculates the hash value OUT of the input argument IN, the hash function calculation apparatus 10 executes the hash function calculation processing of FIG.

まず、制御部16は、先頭ビットが到来する前に、ACCレジスタ15の計算結果ACCを初期化するとともに、線形帰還シフトレジスタ11の乱数データRを初期化する(ステップ100)。例えば、計算結果ACCが「0000」に初期化されるとともに、乱数データRが「1000」に初期化される。この後、1クロックサイクルごとに、引数INのビット数分のM回だけ、以下のステップ101〜106の処理が繰り返し実行される。   First, the control unit 16 initializes the calculation result ACC of the ACC register 15 and the random number data R of the linear feedback shift register 11 before the first bit arrives (step 100). For example, the calculation result ACC is initialized to “0000” and the random number data R is initialized to “1000”. Thereafter, the processing of the following steps 101 to 106 is repeatedly executed by M times as many as the number of bits of the argument IN every clock cycle.

まず、入力レジスタ13は、引数INを構成する1ビットが到来するのを待機し(ステップ101:NO)、1ビットの到来に応じて(ステップ101:YES)、到来ビットの値をビット値Bとして保持する(ステップ102)。
ここで、ビット値Bが1である場合(ステップ103:YES)、セレクタ14で選択された、排他的論理和回路12から出力されている演算結果Qが、ACCレジスタ15で計算結果ACCとして保持される(ステップ104)。
First, the input register 13 waits for the arrival of 1 bit constituting the argument IN (step 101: NO), and according to the arrival of 1 bit (step 101: YES), the value of the arrival bit is changed to the bit value B. (Step 102).
When the bit value B is 1 (step 103: YES), the operation result Q selected from the selector 14 and output from the exclusive OR circuit 12 is held as the calculation result ACC in the ACC register 15. (Step 104).

一方、ビット値Bが「0」である場合(ステップ103:NO)、セレクタ14で選択された、ACCレジスタ15の計算結果ACCが、ACCレジスタ15で再び保持される。したがって、この場合には、計算結果ACCの値は変化せず、処理としてはなにもしていないことと同じである。   On the other hand, when the bit value B is “0” (step 103: NO), the calculation result ACC of the ACC register 15 selected by the selector 14 is held again in the ACC register 15. Therefore, in this case, the value of the calculation result ACC does not change, which is the same as nothing is processed.

この後、制御部16は、入力レジスタ13で保持した到来ビットが引数INの最終ビットであるか確認し(ステップ105)、最終ビットでなければ(ステップ105:NO)、線形帰還シフトレジスタ11に対して乱数データRの更新を指示する。これにより、線形帰還シフトレジスタ11は、予め指定された多項式で生成されるM系列に基づいて、乱数データRを更新し(ステップ106)、ステップ101戻る。   Thereafter, the control unit 16 confirms whether or not the arrival bit held in the input register 13 is the final bit of the argument IN (step 105). If it is not the final bit (step 105: NO), the control unit 16 stores the arrival bit in the linear feedback shift register 11. Instruct the update of the random number data R. As a result, the linear feedback shift register 11 updates the random number data R based on the M-sequence generated with the polynomial designated in advance (step 106), and returns to step 101.

一方、到来ビットが最終ビットである場合(ステップ105:YES)、ACCレジスタ15は、この最終ビットの保持に応じてセレクタ14で選択された選択出力Dをハッシュ値OUTとして保持出力し(ステップ107)、一連のハッシュ関数計算処理を終了する。   On the other hand, when the incoming bit is the last bit (step 105: YES), the ACC register 15 holds and outputs the selection output D selected by the selector 14 as the hash value OUT in accordance with the holding of the last bit (step 107). ), A series of hash function calculation processing is terminated.

[本実施の形態の効果]
このように、本実施の形態は、線形帰還シフトレジスタ11が、予め指定されたM系列に基づいて、入力レジスタ13でビット値Bを保持するごとにNビットの乱数データRを発生させ、排他的論理和回路12が、乱数データRと計算結果ACCとについてビットごとに排他的論理和を演算してNビットの演算結果Qを出力し、ACCレジスタ15が、入力レジスタ13で保持したビット値Bが1の場合にのみ、排他的論理和回路12からの演算結果Qを新たな計算結果ACCとして保持し、最終ビットまで取得して得られた計算結果ACCをハッシュ値OUTとして出力するようにしたものである。
[Effects of the present embodiment]
As described above, according to the present embodiment, the linear feedback shift register 11 generates the N-bit random number data R every time the input register 13 holds the bit value B based on the M sequence designated in advance. The logical OR circuit 12 calculates an exclusive OR for each bit of the random number data R and the calculation result ACC, and outputs an N-bit calculation result Q. The bit value held in the input register 13 by the ACC register 15 Only when B is 1, the operation result Q from the exclusive OR circuit 12 is held as a new calculation result ACC, and the calculation result ACC obtained up to the last bit is output as the hash value OUT. It is a thing.

これにより、事前に乱数表をメモリ等に記憶しておくかわりに、LFSRにより乱数データRが生成され、この乱数データRに基づいて、統計的には一様乱数表を使う場合に近いハッシュ演算を行うことができる。したがって、一様性のある乱数表を準備しておく必要がなくなるため、このような乱数表の記憶もしくは生成のための回路構成や処理が不要となる。また、より大きな引数iNの変域やハッシュ値OUTの値域を持つハッシュ関数を実現する場合でも、必要となる記憶資源はほとんど増加しない。このため、十分な一様性を確保しつつ、回路規模を削減でき、装置の小型化や集積化、さらには低コスト化を実現することが可能となる。   Thus, instead of storing the random number table in advance in a memory or the like, random number data R is generated by LFSR, and based on this random number data R, a hash operation that is statistically close to the case of using a uniform random number table It can be performed. Accordingly, it is not necessary to prepare a uniform random number table, and thus a circuit configuration and processing for storing or generating such a random number table are not necessary. Even when a hash function having a larger domain of the argument iN or a range of the hash value OUT is realized, the required storage resources are hardly increased. For this reason, it is possible to reduce the circuit scale while ensuring sufficient uniformity, and to achieve downsizing and integration of the device and further cost reduction.

また、本実施の形態において、入力レジスタ13のビット値Bが1の場合には排他的論理和回路12からの演算結果Qを選択するとともに、当該ビット値Bが0の場合にはACCレジスタ15からの計算結果ACCを選択するセレクタ14をさらに備え、ACCレジスタ15が、入力レジスタ13でビット値Bを保持するごとにセレクタ14で選択された選択出力Dを新たな計算結果ACCとして保持するようにしてもよい。
これにより、簡素な回路構成で入力レジスタ13のビット値Bに応じた計算結果ACCの更新処理を実現することができる。
In the present embodiment, when the bit value B of the input register 13 is 1, the operation result Q from the exclusive OR circuit 12 is selected, and when the bit value B is 0, the ACC register 15 The selector 14 for selecting the calculation result ACC from the input register 13 is further provided so that the ACC register 15 holds the selection output D selected by the selector 14 as a new calculation result ACC each time the input register 13 holds the bit value B. It may be.
Thereby, the update process of the calculation result ACC according to the bit value B of the input register 13 can be realized with a simple circuit configuration.

[実施の形態の拡張]
以上、実施形態を参照して本発明を説明したが、本発明は上記実施形態に限定されるものではない。本発明の構成や詳細には、本発明のスコープ内で当業者が理解しうる様々な変更をすることができる。また、各実施形態については、矛盾しない範囲で任意に組み合わせて実施することができる。
[Extended embodiment]
The present invention has been described above with reference to the embodiments, but the present invention is not limited to the above embodiments. Various changes that can be understood by those skilled in the art can be made to the configuration and details of the present invention within the scope of the present invention. In addition, each embodiment can be implemented in any combination within a consistent range.

10…ハッシュ関数計算装置、11…線形帰還シフトレジスタ、12…排他的論理和回路、13…入力レジスタ、14…セレクタ、15…ACCレジスタ、1…6制御部、IN…引数、OUT…ハッシュ値、R…乱数データ、Q…演算結果、B…ビット値、D…選択出力、ACC…計算結果。   DESCRIPTION OF SYMBOLS 10 ... Hash function calculation apparatus, 11 ... Linear feedback shift register, 12 ... Exclusive OR circuit, 13 ... Input register, 14 ... Selector, 15 ... ACC register, 1 ... 6 control part, IN ... Argument, OUT ... Hash value , R: random number data, Q: operation result, B: bit value, D: selection output, ACC: calculation result

Claims (3)

入力されたM(Mは2以上の整数)ビットの引数から、N(NはMより小さい整数)ビットのハッシュ値を計算して出力するハッシュ関数計算装置であって、
前記引数を先頭ビットから最終ビットまで1ビットずつ取得し、ビット値として順次保持する入力レジスタと、
予め指定されたM系列に基づいて、前記入力レジスタで前記ビット値を保持するごとにNビットの乱数データを発生させる線形帰還シフトレジスタと、
前記入力レジスタで保持した前記ビット値までの計算過程で得られたNビットの計算結果を保持するACCレジスタと、
前記乱数データと前記計算結果とについてビットごとに排他的論理和を演算してNビットの演算結果を出力する排他的論理和回路とを備え、
前記ACCレジスタは、前記入力レジスタのビット値が1の場合にのみ、前記排他的論理和回路からの演算結果を新たな計算結果として保持し、前記最終ビットまで取得して得られた前記計算結果を前記ハッシュ値として出力する
ことを特徴とするハッシュ関数計算装置。
A hash function calculation device that calculates and outputs a hash value of N (N is an integer smaller than M) bits from an input M (M is an integer of 2 or more) bit arguments,
An input register that obtains the argument bit by bit from the first bit to the last bit, and sequentially holds the bit value;
A linear feedback shift register that generates N-bit random number data each time the bit value is held in the input register, based on a pre-designated M-sequence;
An ACC register holding an N-bit calculation result obtained in the calculation process up to the bit value held in the input register;
An exclusive OR circuit that calculates an exclusive OR for each bit of the random number data and the calculation result and outputs an N bit operation result;
The ACC register holds the calculation result from the exclusive OR circuit as a new calculation result only when the bit value of the input register is 1, and the calculation result obtained by acquiring up to the last bit Is output as the hash value.
請求項1に記載のハッシュ関数計算装置において、
前記入力レジスタのビット値が1の場合には前記排他的論理和回路からの演算結果を選択するとともに、当該ビット値が0の場合には前記ACCレジスタからの計算結果を選択するセレクタをさらに備え、
前記ACCレジスタは、前記入力レジスタでビット値を保持するごとに前記セレクタで選択された選択出力を新たな計算結果として保持する
ことを特徴とするハッシュ関数計算装置。
The hash function calculation apparatus according to claim 1,
A selector for selecting an operation result from the exclusive OR circuit when the bit value of the input register is 1 and selecting a calculation result from the ACC register when the bit value is 0; ,
The ACC register holds a selection output selected by the selector as a new calculation result every time a bit value is held in the input register.
入力されたM(Mは2以上の整数)ビットの引数から、N(NはMより小さい整数)ビットのハッシュ値を計算して出力するハッシュ関数計算装置で用いられるハッシュ関数計算方法であって、
入力レジスタが、前記引数を先頭ビットから最終ビットまで1ビットずつ取得し、ビット値として順次保持するステップと、
線形帰還シフトレジスタが、予め指定されたM系列に基づいて、前記入力レジスタで前記ビット値を保持するごとにNビットの乱数データを発生させるステップと、
ACCレジスタが、前記入力レジスタで保持した前記ビット値までの計算過程で得られたNビットの計算結果を保持するステップと、
排他的論理和回路が、前記乱数データと前記計算結果とについてビットごとに排他的論理和を演算し、Nビットの演算結果を出力するステップとを備え、
前記ACCレジスタは、前記入力レジスタのビット値が1の場合にのみ、前記排他的論理和回路からの演算結果を新たな計算結果として保持し、前記最終ビットまで取得して得られた前記計算結果を前記ハッシュ値として出力するステップを有する
ことを特徴とするハッシュ関数計算方法。
A hash function calculation method used in a hash function calculation device that calculates and outputs a hash value of N (N is an integer smaller than M) from an input M (M is an integer of 2 or more) bit argument. ,
An input register obtaining the argument bit by bit from the first bit to the last bit, and sequentially holding it as a bit value;
A linear feedback shift register generating N-bit random number data each time the input register holds the bit value based on a pre-designated M sequence;
An ACC register holding an N-bit calculation result obtained in a calculation process up to the bit value held in the input register;
An exclusive OR circuit calculating an exclusive OR for each bit of the random number data and the calculation result, and outputting an N-bit calculation result;
The ACC register holds the calculation result from the exclusive OR circuit as a new calculation result only when the bit value of the input register is 1, and the calculation result obtained by acquiring up to the last bit A hash function calculation method comprising: outputting as a hash value.
JP2015182843A 2015-09-16 2015-09-16 Hash function calculation device and method Pending JP2017058501A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2015182843A JP2017058501A (en) 2015-09-16 2015-09-16 Hash function calculation device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2015182843A JP2017058501A (en) 2015-09-16 2015-09-16 Hash function calculation device and method

Publications (1)

Publication Number Publication Date
JP2017058501A true JP2017058501A (en) 2017-03-23

Family

ID=58390494

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2015182843A Pending JP2017058501A (en) 2015-09-16 2015-09-16 Hash function calculation device and method

Country Status (1)

Country Link
JP (1) JP2017058501A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024007506A1 (en) * 2022-07-04 2024-01-11 广西伯汉科技有限公司 Universal lightweight hash processing method and system, and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024007506A1 (en) * 2022-07-04 2024-01-11 广西伯汉科技有限公司 Universal lightweight hash processing method and system, and storage medium

Similar Documents

Publication Publication Date Title
JP4559505B2 (en) Extending the repetition period of random sequences
US8145692B2 (en) Digital generation of an accelerated or decelerated chaotic numerical sequence
CA2633923C (en) Mixed radix number generator with chosen statistical artifacts
JP6744375B2 (en) Generation of randomness in neural networks
US10768898B2 (en) Efficient modulo calculation
WO2012016588A1 (en) Bit sequence generator
JP6044628B2 (en) Random number generation device, random number generation method, object placement device, and computer program
JP2017058501A (en) Hash function calculation device and method
US10536262B2 (en) Electronic generation device
CN109379191B (en) Dot multiplication operation circuit and method based on elliptic curve base point
JP2016126517A (en) Device and method for generating random numbers
JP4709685B2 (en) Pseudorandom number generation device, pseudorandom number generation method, pseudorandom number generation program, encryption device, and decryption device
CN112764713B (en) Random number generation method and device
JP2018503862A5 (en)
US20140289295A1 (en) Method for generating a random output bit sequence
JP2016126518A (en) Device and method for generating random numbers
US10505710B2 (en) Electronic calculating device
JP5101253B2 (en) Random error generator, M-sequence generator, and design method thereof
CN110457008B (en) m sequence generation method, device and storage medium
JP6059572B2 (en) Image processing device
KR101872329B1 (en) Random number generator for supporting multi entropy pool
JP2017058500A (en) Hash function calculation device and method
JP2004038020A (en) Cryptographic pseudo-random number generator and program
JP2011123693A (en) Method, apparatus and program for determining period of integer sequence
JP5455664B2 (en) Pseudorandom number generator and pseudorandom number generation program