CN104750457A - Method and device for processing data on basis of modular exponentiation - Google Patents
Method and device for processing data on basis of modular exponentiation Download PDFInfo
- Publication number
- CN104750457A CN104750457A CN201310754512.2A CN201310754512A CN104750457A CN 104750457 A CN104750457 A CN 104750457A CN 201310754512 A CN201310754512 A CN 201310754512A CN 104750457 A CN104750457 A CN 104750457A
- Authority
- CN
- China
- Prior art keywords
- arithmetic register
- value
- mould
- arithmetical unit
- arithmetic
- 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.)
- Granted
Links
Landscapes
- Executing Machine-Instructions (AREA)
Abstract
The invention provides a method and a device for processing data on the basis of modular exponentiation. The method includes storing module lengths n into first arithmetic registers and storing module numbers N into second arithmetic registers; acquiring modular results X of the module numbers N in the second arithmetic registers and storing the modular results X in third arithmetic registers; calling first modular addition arithmetic units to carry out modular addition operation on values of the third arithmetic registers, acquiring modular results Y of the module numbers N and storing the modular results Y into fourth arithmetic registers; calling modular exponentiation arithmetic units to carry out modular exponentiation on values of the fourth arithmetic registers, acquiring modular results Z of the module numbers N and storing the modular results Z in fifth arithmetic registers. Modular operation is carried out on the modular numbers N by values R to obtain the modular results X, and the values R meet an equation of R=2*n. Modular operation is carried out on the module numbers N by values 2*R to obtain the modular results Y. Modular operation is carried out on the module numbers N by values R*R to obtain the modular results Z. Power exponents of the modular exponentiation arithmetic units are values of the first arithmetic registers, power base numbers of the modular exponentiation arithmetic units are the values of the fourth arithmetic registers, and module numbers of the modular exponentiation arithmetic units are values of the second arithmetic registers. The method and the device have the advantage that the data processing efficiency can be improved by the aid of the method and the device.
Description
Technical field
The present invention relates to the technical field of data security, particularly a kind of data processing method based on Montgomery Algorithm and device.
Background technology
In public key algorithm (RSA, ECC, SM2 etc.) application, frequent use montgomery modulo multiplication arithmetic element carries out efficient algorithm realization, natural number needs the data layout be first converted into needed for montgomery modulo multiplication just can carry out corresponding computing, in the transfer process of data layout, first will realize Montgomery precomputation R*R mod N, and the speed of precomputation directly affects the performance of public key algorithm.
In the prior art, the computing of general employing software calculates the product of R and R to the value of N delivery, but when the position of R is long, described calculating process will consume longer operation time.
Therefore, need to propose a kind of new data processing method based on Montgomery Algorithm and device, to improve the efficiency of data processing.
Summary of the invention
The problem that the present invention solves proposes a kind of new data processing method based on Montgomery Algorithm and device, to improve the efficiency of data processing.
The embodiment provides a kind of data processing method based on Montgomery Algorithm, described method comprises: by long for mould n stored in the first arithmetic register, and by modulus N stored in the second arithmetic register; Obtain R to the result X of the N delivery in the second arithmetic register, by X stored in the 3rd arithmetic register, wherein, R=2
n; Call the first mould to add the value of arithmetical unit to described 3rd arithmetic register and carry out mould and add computing, obtain 2R to the result Y of N delivery, and by Y stored in the 4th arithmetic register; Call the value of Montgomery Algorithm device to the 4th arithmetic register and carry out Montgomery Algorithm, obtain R*R to the result Z of N delivery stored in the 5th arithmetic register, wherein, the power exponent of described Montgomery Algorithm device is the value of described first arithmetic register, the power truth of a matter of described Montgomery Algorithm device is the value of described 4th arithmetic register, and the modulus of described Montgomery Algorithm device is the value of described second arithmetic register.
Alternatively, the result of described acquisition R to N delivery comprises: the radix-minus-one complement calculating N
call the second mould to add arithmetical unit and calculate described radix-minus-one complement
carry out mould add the value after computing with 1, the modulus that described second mould adds arithmetical unit is the value of described second arithmetic register.
Alternatively, call mould and subtract the radix-minus-one complement that arithmetical unit calculates N
Alternatively, the result of described acquisition R to N delivery comprises: by R/2 stored in the 6th arithmetic register; Call the 3rd mould to add the value of arithmetical unit to described 6th arithmetic register and carry out mould and add computing, wherein, described 3rd mould adds the value that the addend of arithmetical unit and summand are respectively described 6th arithmetic register, and the modulus that described 3rd mould adds arithmetical unit is the value of described second arithmetic register.
Alternatively, described Montgomery Algorithm device is Montgomery Montgomery Algorithm device.
Embodiments of the invention additionally provide a kind of data processing equipment based on Montgomery Algorithm, and described device comprises: data capture unit, for by long for mould n stored in the first arithmetic register, and by modulus N stored in the second arithmetic register; Modulo operation device, for obtaining the result X of R to the N delivery in the second arithmetic register, by X stored in the 3rd arithmetic register, wherein, R=2
n; First mould adds arithmetical unit, adds computing for carrying out mould to the value of described 3rd arithmetic register, obtains 2R to the result Y of N delivery, and by Y stored in the 4th arithmetic register; Montgomery Algorithm device, for carrying out Montgomery Algorithm to the value of the 4th arithmetic register, obtain R*R to the result Z of N delivery stored in the 5th arithmetic register, wherein, the power exponent of described Montgomery Algorithm device is the value of described first arithmetic register, the power truth of a matter of described Montgomery Algorithm device is the value of described 4th arithmetic register, and the modulus of described Montgomery Algorithm device is the value of described second arithmetic register.
Alternatively, described modulo operation device comprises: radix-minus-one complement arithmetical unit, for calculating the radix-minus-one complement of N
second mould adds arithmetical unit, for calculating described radix-minus-one complement
carry out mould add the value after computing with 1, the modulus that described second mould adds arithmetical unit is the value of described second arithmetic register.
Alternatively, described radix-minus-one complement arithmetical unit is that mould adds arithmetical unit.
Alternatively, described modulo operation device comprises: data acquisition subelement, for by R/2 stored in the 6th arithmetic register; 3rd mould adds arithmetical unit, computing is added for carrying out mould to the value of described 6th arithmetic register, wherein, described 3rd mould adds the value that the addend of arithmetical unit and summand are respectively described 6th arithmetic register, and the modulus that described 3rd mould adds arithmetical unit is the value of described second arithmetic register.
Alternatively, described Montgomery Algorithm device is Montgomery Montgomery Algorithm device.
Compared with prior art, embodiments of the invention have the following advantages: in technique scheme, adopt that mould adds arithmetical unit, mould subtracts arithmetical unit and the hardware module (Montgomery Algorithm device can select software or hardware implementing) such as modular multiplication device calculates the product of R and R to the value of N delivery, decrease the execution time of computing, thus improve data-handling efficiency.
Accompanying drawing explanation
Fig. 1 is the process flow diagram based on the data processing method of Montgomery Algorithm in the embodiment of the present invention;
Fig. 2 is the structural representation based on the data processing equipment of Montgomery Algorithm in the embodiment of the present invention;
Fig. 3 is the structural representation of modulo operation device in one embodiment of the invention;
Fig. 4 is the structural representation of modulo operation device in another embodiment of the present invention.
Embodiment
By describing technology contents of the present invention, structural attitude in detail, being realized object and effect, below in conjunction with accompanying drawing, the specific embodiment of the present invention is described in detail.Set forth a lot of detail in the following description so that fully understand the present invention, but the present invention can also adopt other to be different from alternate manner described here to implement, therefore the present invention is not by the restriction of following public specific embodiment.
Fig. 1 is the process flow diagram based on the data processing method of Montgomery Algorithm in the embodiment of the present invention.As shown in Figure 1, described method comprises step S101 to S104.
Step S101, by long for mould n stored in the first arithmetic register, and by modulus N stored in the second arithmetic register
Step S102, obtains R to the result X of the N delivery in the second arithmetic register, by X stored in the 3rd arithmetic register, wherein, and R=2
n.
In one embodiment of the invention, the result X of described acquisition R to N delivery comprises: step a and step b.
Due to R=2
n, so the result of R to N delivery equals R-N.
N is equaled again because mould is long,
and R=2
n, (FF ... FF)=2
n-1=R-1, so
From above-mentioned derivation, can by calculating radix-minus-one complement
with 1 and calculate the result of R to N delivery.
So can pass through step a, calculate the radix-minus-one complement of N
then by step b, call the second mould and add arithmetical unit and calculate described radix-minus-one complement
carry out mould add the value after computing with 1, the modulus that described second mould adds arithmetical unit is the value of described second arithmetic register.
In an embodiment of the present invention, can subtract by calling mould the radix-minus-one complement that arithmetical unit calculates N
also other modes are just adopted to calculate the radix-minus-one complement of N
It should be noted that, be have employed the second mould to add arithmetical unit in above-mentioned calculating R is to the process of N delivery, and that is, adopt hardware configuration to perform computing, the time therefore performing computing is relatively short, thus is conducive to the raising of data-handling efficiency.
In another embodiment of the present invention, the result of described acquisition R to N delivery comprises: step c and steps d.
Step c, by R/2 stored in the 6th arithmetic register.
Steps d, call the 3rd mould to add the value of arithmetical unit to described 6th arithmetic register and carry out mould and add computing, wherein, described 3rd mould adds the value that the addend of arithmetical unit and summand are respectively described 6th arithmetic register, and the modulus that described 3rd mould adds arithmetical unit is the value of described second arithmetic register.
Similarly, it should be noted that, be have employed the 3rd mould to add arithmetical unit in above-mentioned calculating R is to the process of N delivery, that is, be all adopt hardware configuration to perform computing, the time therefore performing computing is relatively short, thus is conducive to the raising of data-handling efficiency.
Step S103, calls the first mould and adds the value of arithmetical unit to described 3rd arithmetic register and carry out mould and add computing, obtain 2R to the result Y of N delivery, and by Y stored in the 4th arithmetic register.
Value X due to the 3rd arithmetic register is the result of R to N delivery, so adds computing to X and X execution mould and just can obtain the result of 2R to N delivery, that is, 2RmodN=(R+R) modN.
Step S104, calls the value of Montgomery Algorithm device to the 4th arithmetic register and carries out Montgomery Algorithm, obtains R*R to the result Z of N delivery stored in the 5th arithmetic register.
Due to R*RmodN=(2
nr) modN, Y=2RmodN, so performs the computing of mould power according to the value of Y and just can obtain the value Z of R*R to N delivery.Wherein, the power exponent of described Montgomery Algorithm device is n, and the modulus of described Montgomery Algorithm device is N.Particularly, the power exponent of described Montgomery Algorithm device is the value of described first arithmetic register, and the power truth of a matter of described Montgomery Algorithm device is the value of described 4th arithmetic register, and the modulus of described Montgomery Algorithm device is the value of described second arithmetic register
In an embodiment of the present invention, described Montgomery Algorithm device can be Montgomery modular power operation device.
It should be noted that, in an embodiment of the present invention, adopt that mould adds arithmetical unit, mould subtracts arithmetical unit and the hardware module (Montgomery Algorithm device can select software or hardware implementing) such as modular multiplication device calculates the product of R and R to the value of N delivery, decrease the execution time of computing, thus improve data-handling efficiency.
Embodiments of the invention additionally provide a kind of data processing equipment based on Montgomery Algorithm, please refer to Fig. 2, the described data processing equipment 200 based on Montgomery Algorithm comprises: data capture unit 210, for by long for mould n stored in the first arithmetic register, and by modulus N stored in the second arithmetic register; Modulo operation device 220, for obtaining the result X of R to the N delivery in the second arithmetic register, by X stored in the 3rd arithmetic register, wherein, R=2
n; First mould adds arithmetical unit 230, adds computing for carrying out mould to the value of described 3rd arithmetic register, obtains 2R to the result Y of N delivery, and by Y stored in the 4th arithmetic register; Montgomery Algorithm device 240, for carrying out Montgomery Algorithm to the value of the 4th arithmetic register, obtain R*R to the result Z of N delivery stored in the 5th arithmetic register, wherein, the power exponent of described Montgomery Algorithm device is the value of described first arithmetic register, the power truth of a matter of described Montgomery Algorithm device is the value of described 4th arithmetic register, and the modulus of described Montgomery Algorithm device is the value of described second arithmetic register.
Please refer to Fig. 3, in an embodiment of the present invention, described modulo operation device 220 can comprise: radix-minus-one complement arithmetical unit 221, for calculating the radix-minus-one complement of N
second mould adds arithmetical unit 222, for calculating described radix-minus-one complement
carry out mould add the value after computing with 1, the modulus that described second mould adds arithmetical unit is the value of described second arithmetic register.Particularly, described radix-minus-one complement arithmetical unit 221 can add arithmetical unit for mould.
Please refer to Fig. 4, in an embodiment of the present invention, described modulo operation device 220 also can comprise: data acquisition subelement 223, for by R/2 stored in the 6th arithmetic register; 3rd mould adds arithmetical unit 224, computing is added for carrying out mould to the value of described 6th arithmetic register, wherein, described 3rd mould adds the value that the addend of arithmetical unit and summand are respectively described 6th arithmetic register, and the modulus that described 3rd mould adds arithmetical unit is the value of described second arithmetic register.
In an embodiment of the present invention, described Montgomery Algorithm device 240 can be Montgomery modular power operation device.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment is that the hardware that can carry out instruction relevant by program has come, this program can be stored in a computer-readable recording medium, and storage medium can comprise: ROM, RAM, disk or CD etc.
Although the present invention discloses as above, the present invention is not defined in this.Any those skilled in the art, without departing from the spirit and scope of the present invention, all can make various changes or modifications, and therefore protection scope of the present invention should be as the criterion with claim limited range.
Claims (10)
1. based on a data processing method for Montgomery Algorithm, it is characterized in that, comprising:
By long for mould n stored in the first arithmetic register, and by modulus N stored in the second arithmetic register;
Obtain R to the result X of the N delivery in the second arithmetic register, by X stored in the 3rd arithmetic register,
Wherein, R=2
n;
Call the first mould to add the value of arithmetical unit to described 3rd arithmetic register and carry out mould and add computing, obtain 2R to the result Y of N delivery, and by Y stored in the 4th arithmetic register;
Call the value of Montgomery Algorithm device to the 4th arithmetic register and carry out Montgomery Algorithm, obtain R*R to the result Z of N delivery stored in the 5th arithmetic register, wherein, the power exponent of described Montgomery Algorithm device is the value of described first arithmetic register, the power truth of a matter of described Montgomery Algorithm device is the value of described 4th arithmetic register, and the modulus of described Montgomery Algorithm device is the value of described second arithmetic register.
2. the method for claim 1, is characterized in that, the result of described acquisition R to N delivery comprises:
Calculate the radix-minus-one complement of N
Call the second mould to add arithmetical unit and calculate described radix-minus-one complement
carry out mould add the value after computing with 1, the modulus that described second mould adds arithmetical unit is the value of described second arithmetic register.
3. method as claimed in claim 2, is characterized in that, calls mould and subtracts the radix-minus-one complement that arithmetical unit calculates N
4. the method for claim 1, is characterized in that, the result of described acquisition R to N delivery comprises:
By R/2 stored in the 6th arithmetic register;
Call the 3rd mould to add the value of arithmetical unit to described 6th arithmetic register and carry out mould and add computing, wherein, described 3rd mould adds the value that the addend of arithmetical unit and summand are respectively described 6th arithmetic register, and the modulus that described 3rd mould adds arithmetical unit is the value of described second arithmetic register.
5. the method for claim 1, is characterized in that, described Montgomery Algorithm device is Montgomery Montgomery Algorithm device.
6. based on a data processing equipment for Montgomery Algorithm, it is characterized in that, comprising:
Data capture unit, for by long for mould n stored in the first arithmetic register, and by modulus N stored in the second arithmetic register;
Modulo operation device, for obtaining the result X of R to the N delivery in the second arithmetic register, by X stored in the 3rd arithmetic register, wherein, R=2
n;
First mould adds arithmetical unit, adds computing for carrying out mould to the value of described 3rd arithmetic register, obtains 2R to the result Y of N delivery, and by Y stored in the 4th arithmetic register;
Montgomery Algorithm device, for carrying out Montgomery Algorithm to the value of the 4th arithmetic register, obtain R*R to the result Z of N delivery stored in the 5th arithmetic register, wherein, the power exponent of described Montgomery Algorithm device is the value of described first arithmetic register, the power truth of a matter of described Montgomery Algorithm device is the value of described 4th arithmetic register, and the modulus of described Montgomery Algorithm device is the value of described second arithmetic register.
7. device as claimed in claim 6, it is characterized in that, described modulo operation device comprises:
Radix-minus-one complement arithmetical unit, for calculating the radix-minus-one complement of N
Second mould adds arithmetical unit, for calculating described radix-minus-one complement
carry out mould add the value after computing with 1, the modulus that described second mould adds arithmetical unit is the value of described second arithmetic register.
8. device as claimed in claim 7, it is characterized in that, described radix-minus-one complement arithmetical unit is that mould adds arithmetical unit.
9. device as claimed in claim 6, it is characterized in that, described modulo operation device comprises:
Data acquisition subelement, for by R/2 stored in the 6th arithmetic register;
3rd mould adds arithmetical unit, adds computing for carrying out mould to the value of described 6th arithmetic register, wherein,
Described 3rd mould adds the value that the addend of arithmetical unit and summand are respectively described 6th arithmetic register, institute
State the value that modulus that the 3rd mould adds arithmetical unit is described second arithmetic register.
10. device as claimed in claim 6, it is characterized in that, described Montgomery Algorithm device is Montgomery Montgomery Algorithm device.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310754512.2A CN104750457B (en) | 2013-12-31 | 2013-12-31 | A kind of data processing method and device based on Montgomery Algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310754512.2A CN104750457B (en) | 2013-12-31 | 2013-12-31 | A kind of data processing method and device based on Montgomery Algorithm |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104750457A true CN104750457A (en) | 2015-07-01 |
CN104750457B CN104750457B (en) | 2018-03-06 |
Family
ID=53590216
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310754512.2A Active CN104750457B (en) | 2013-12-31 | 2013-12-31 | A kind of data processing method and device based on Montgomery Algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104750457B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106681691A (en) * | 2015-11-07 | 2017-05-17 | 上海复旦微电子集团股份有限公司 | Data processing method and modular multiplication operation method and apparatus based on Montgomery modular-multiplication |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101834723A (en) * | 2009-03-10 | 2010-09-15 | 上海爱信诺航芯电子科技有限公司 | RSA (Rivest-Shamirh-Adleman) algorithm and IP core |
CN103107879A (en) * | 2012-12-21 | 2013-05-15 | 杭州晟元芯片技术有限公司 | RAS accelerator |
CN103207770A (en) * | 2013-04-16 | 2013-07-17 | 飞天诚信科技股份有限公司 | Method for realizing large number pre-computation in embedded system |
-
2013
- 2013-12-31 CN CN201310754512.2A patent/CN104750457B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101834723A (en) * | 2009-03-10 | 2010-09-15 | 上海爱信诺航芯电子科技有限公司 | RSA (Rivest-Shamirh-Adleman) algorithm and IP core |
CN103107879A (en) * | 2012-12-21 | 2013-05-15 | 杭州晟元芯片技术有限公司 | RAS accelerator |
CN103207770A (en) * | 2013-04-16 | 2013-07-17 | 飞天诚信科技股份有限公司 | Method for realizing large number pre-computation in embedded system |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106681691A (en) * | 2015-11-07 | 2017-05-17 | 上海复旦微电子集团股份有限公司 | Data processing method and modular multiplication operation method and apparatus based on Montgomery modular-multiplication |
CN106681691B (en) * | 2015-11-07 | 2019-01-29 | 上海复旦微电子集团股份有限公司 | Data processing method, modular multiplication method and apparatus based on montgomery modulo multiplication |
Also Published As
Publication number | Publication date |
---|---|
CN104750457B (en) | 2018-03-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Schinianakis et al. | An RNS implementation of an $ F_ {p} $ elliptic curve point multiplier | |
CN102999313B (en) | A kind of data processing method based on montgomery modulo multiplication | |
TWI731543B (en) | Computer data processing method and device | |
CN101782845B (en) | High speed arithmetic device and method of elliptic curve code | |
Kudithi | An efficient hardware implementation of the elliptic curve cryptographic processor over prime field | |
Kocabaş et al. | Implementation of binary Edwards curves for very-constrained devices | |
KR102132261B1 (en) | Method and apparatus for computing montgomery multiplication performing final reduction wihhout comparator | |
CN104679474A (en) | Multiplying unit on finite field GF (2 227) and modular multiplication algorithm | |
CN106681690A (en) | Montgomery modular multiplication based data processing method, modular multiplication operation method and device | |
CN104065478A (en) | Polynomial modular multiplication coprocessor based on lattice-based cryptosystem | |
CN103793199A (en) | Rapid RSA cryptography coprocessor capable of supporting dual domains | |
Xie et al. | High-throughput finite field multipliers using redundant basis for FPGA and ASIC implementations | |
Lee et al. | Improved multi-precision squaring for low-end RISC microcontrollers | |
CN104750455A (en) | Method and device for processing data on basis of Montgomery modular multiplication | |
WO2017012351A1 (en) | Parallel computing method and terminal | |
CN100527073C (en) | High efficiency modular multiplication method and device | |
CN106681691A (en) | Data processing method and modular multiplication operation method and apparatus based on Montgomery modular-multiplication | |
CN104750457A (en) | Method and device for processing data on basis of modular exponentiation | |
Gutub et al. | Serial vs. parallel elliptic curve crypto processor designs | |
Han et al. | Improved computation of square roots in specific finite fields | |
Baktır et al. | A state-of-the-art elliptic curve cryptographic processor operating in the frequency domain | |
Rashidi et al. | High-speed hardware implementations of point multiplication for binary Edwards and generalized Hessian curves | |
Seo et al. | Consecutive operand-caching method for multiprecision multiplication, revisited | |
CN108008934A (en) | A kind of compound finite field inversions device based on look-up table | |
KR20080050054A (en) | Method for generating sparse w-naf key, method for processing and method for encrypting thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |