CN104750457B - A kind of data processing method and device based on Montgomery Algorithm - Google Patents
A kind of data processing method and device based on Montgomery Algorithm Download PDFInfo
- Publication number
- CN104750457B CN104750457B CN201310754512.2A CN201310754512A CN104750457B CN 104750457 B CN104750457 B CN 104750457B CN 201310754512 A CN201310754512 A CN 201310754512A CN 104750457 B CN104750457 B CN 104750457B
- Authority
- CN
- China
- Prior art keywords
- arithmetic
- mould
- value
- modulus
- arithmetic register
- 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.)
- Active
Links
Abstract
The invention provides a kind of data processing method and device based on Montgomery Algorithm, wherein, methods described includes:The long n of mould is stored in the first arithmetic register, and modulus N is stored in the second arithmetic register;Result Xs of the R to the N modulus in the second arithmetic register is obtained, X is stored in the 3rd arithmetic register, wherein, R=2n;Call the first mould to add arithmetic unit to carry out mould to the value of the 3rd arithmetic register and add computing, obtain result Ys of the 2R to N modulus, and Y is stored in the 4th arithmetic register;Montgomery Algorithm device is called to carry out Montgomery Algorithm to the value of the 4th arithmetic register, obtain R*R and the 5th arithmetic register is stored in the result Z of N modulus, wherein, the power exponent of the Montgomery Algorithm device is the value of first arithmetic register, the power truth of a matter of the Montgomery Algorithm device is the value of the 4th arithmetic register, and the modulus of the Montgomery Algorithm device is the value of second arithmetic register.Methods described and device can improve the efficiency of data processing.
Description
Technical field
The present invention relates to the technical field of data safety, more particularly to a kind of data processing method based on Montgomery Algorithm and
Device.
Background technology
In public key algorithm(RSA, ECC, SM2 etc.)Application field, come commonly using montgomery modulo multiplication arithmetic element
Efficient algorithm realization is carried out, the data format that natural number needs first to be converted into needed for montgomery modulo multiplication could be carried out accordingly
Computing, first have to realize Montgomery precomputation R*R mod N in the transfer process of data format, and the speed of precomputation is straight
Connect the performance that have impact on public key algorithm.
In the prior art, it is general that value of R and the R product to N modulus is calculated using software computing, however, when R position
When longer, the calculating process will consume longer operation time.
It is, therefore, desirable to provide a kind of new data processing method and device based on Montgomery Algorithm, to improve data processing
Efficiency.
The content of the invention
The present invention solves the problems, such as it is to propose a kind of new data processing method and device based on Montgomery Algorithm, to improve
The efficiency of data processing.
The embodiment provides a kind of data processing method based on Montgomery Algorithm, methods described includes:By mould
Long n is stored in the first arithmetic register, and modulus N is stored in into the second arithmetic register;R is obtained to the N in the second arithmetic register
The result X of modulus, X is stored in the 3rd arithmetic register, wherein, R=2n;The first mould is called to add arithmetic unit to the 3rd computing
The value of register carries out mould and adds computing, obtains result Ys of the 2R to N modulus, and Y is stored in into the 4th arithmetic register;Call mould power
Arithmetic unit carries out Montgomery Algorithm to the value of the 4th arithmetic register, obtains R*R and is stored in the 5th computing deposit to the result Z of N modulus
Device, wherein, the power exponent of the Montgomery Algorithm device is the value of first arithmetic register, the power truth of a matter of the Montgomery Algorithm device
For the value of the 4th arithmetic register, the modulus of the Montgomery Algorithm device is the value of second arithmetic register.
Alternatively, the acquisition R includes to the result of N modulus:Calculate N radix-minus-one complementThe second mould is called to add arithmetic unit meter
Calculate the radix-minus-one complementAdd the value after computing with 1 progress mould, second mould adds the modulus of arithmetic unit to be deposited for second computing
The value of device.
Alternatively, mould is called to subtract the radix-minus-one complement that arithmetic unit calculates N
Alternatively, the acquisition R includes to the result of N modulus:R/2 is stored in the 6th arithmetic register;Call the 3rd mould
Add arithmetic unit to carry out mould to the value of the 6th arithmetic register and add computing, wherein, the 3rd mould add arithmetic unit addend and
Summand is respectively the value of the 6th arithmetic register, and the 3rd mould adds the modulus of arithmetic unit to be deposited for second computing
The value of device.
Alternatively, the 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 includes:Number
According to acquiring unit, for the long n of mould to be stored in into the first arithmetic register, and modulus N is stored in the second arithmetic register;Modulo operation
Device, for obtaining result Xs of the R to the N modulus in the second arithmetic register, X is stored in the 3rd arithmetic register, wherein, R=2n;
First mould adds arithmetic unit, adds computing for carrying out mould to the value of the 3rd arithmetic register, obtains result Ys of the 2R to N modulus,
And Y is 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 is stored in the 5th arithmetic register to the result Z of N modulus, wherein, the power exponent of the Montgomery Algorithm device is first computing
The value of register, the power truth of a matter of the Montgomery Algorithm device are the value of the 4th arithmetic register, the mould of the Montgomery Algorithm device
Number is the value of second arithmetic register.
Alternatively, the modulo operation device includes:Radix-minus-one complement arithmetic unit, for calculating N radix-minus-one complementSecond mould adds computing
Device, for calculating the radix-minus-one complementAdd the value after computing with 1 progress mould, second mould adds the modulus of arithmetic unit to be described second
The value of arithmetic register.
Alternatively, the radix-minus-one complement arithmetic unit is that mould adds arithmetic unit.
Alternatively, the modulo operation device includes:Data acquisition subelement, for R/2 to be stored in into the 6th arithmetic register;
3rd mould adds arithmetic unit, adds computing for carrying out mould to the value of the 6th arithmetic register, wherein, the 3rd mould adds computing
The addend and summand of device are respectively the value of the 6th arithmetic register, and the 3rd mould adds the modulus of arithmetic unit for described the
The value of two arithmetic registers.
Alternatively, the Montgomery Algorithm device is Montgomery Montgomery Algorithm device.
Compared with prior art, embodiments of the invention have advantages below:In the above-mentioned technical solutions, using mould plus fortune
Calculate device, mould subtracts the hardware module such as arithmetic unit and modular multiplication device(Software is may be selected in Montgomery Algorithm device or hardware is realized)To calculate
R and R product reduces the execution time of computing, so as to improve data-handling efficiency to the value of N modulus.
Brief description of the drawings
Fig. 1 is the flow chart of the data processing method based on Montgomery Algorithm in the embodiment of the present invention;
Fig. 2 is the structural representation of the data processing equipment based on 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
To describe the technology contents of the present invention, construction feature, the objects and the effects in detail, below in conjunction with the accompanying drawings to this
The embodiment of invention is described in detail.Many details are elaborated in the following description in order to fully understand
The present invention, but the present invention can also be different from other manner described here using other to be implemented, thus the present invention not by
The limitation of following public specific embodiment.
Fig. 1 is the flow chart of the data processing method based on Montgomery Algorithm in the embodiment of the present invention.It is as shown in figure 1, described
Method includes step S101 to S104.
Step S101, the long n of mould is stored in the first arithmetic register, and modulus N is stored in the second arithmetic register
Step S102, obtains result Xs of the R to the N modulus in the second arithmetic register, and X is stored in into the 3rd arithmetic register,
Wherein, R=2n。
In one embodiment of the invention, the acquisition R includes to the result X of N modulus:Step a and step b.
Due to R=2n, then R is equal to R-N to the result of N modulus.
Again because mould length is equal to n,And R=2n, (FF ... FF)=2n- 1=R-1, that
, can be by calculating radix-minus-one complement from above-mentioned derivationWith 1 and calculate results of the R to N modulus.
It by step a, can so calculate N radix-minus-one complementThen by step b, the second mould is called to add arithmetic unit to calculate
The radix-minus-one complementAdd the value after computing with 1 progress mould, second mould adds the modulus of arithmetic unit to be second arithmetic register
Value.
In an embodiment of the present invention, can be by calling mould to subtract the radix-minus-one complement that arithmetic unit calculates NAlso just its other party is used
Formula calculates N radix-minus-one complement
It should be noted that be to employ the second mould to add arithmetic unit during above-mentioned calculating R is to N modulus, that is,
Say, computing is performed using hardware configuration, therefore the time for performing computing is relatively short, so as to be advantageous to carrying for data-handling efficiency
It is high.
In another embodiment of the present invention, the acquisition R includes to the result of N modulus:Step c and step d.
Step c, R/2 is stored in the 6th arithmetic register.
Step d, call the 3rd mould to add arithmetic unit to carry out mould to the value of the 6th arithmetic register and add computing, wherein, institute
State the 3rd mould add the addend of arithmetic unit and summand be respectively the 6th arithmetic register value, the 3rd mould adds arithmetic unit
Modulus be second arithmetic register value.
Similarly, it is necessary to which explanation, is to employ the 3rd mould to add arithmetic unit during above-mentioned calculating R is to N modulus,
That is, be all that computing is performed using hardware configuration, therefore the time for performing computing is relatively short, so as to be advantageous at data
Manage the raising of efficiency.
Step S103, call the first mould to add arithmetic unit to carry out mould to the value of the 3rd arithmetic register and add computing, obtain
2R is stored in the 4th arithmetic register to the result Y of N modulus, and by Y.
Because the value X of the 3rd arithmetic register is results of the R to N modulus, then perform mould to X and X and add computing can
Obtain results of the 2R to N modulus, i.e. 2RmodN=(R+R) modN.
Step S104, call Montgomery Algorithm device to carry out Montgomery Algorithm to the value of the 4th arithmetic register, obtain R*R and N is taken
The result Z of mould is stored in the 5th arithmetic register.
Due to R*RmodN=(2nR) modN, Y=2RmodN, then mould power computing can is performed according to Y value and obtained
Obtain value Zs of the R*R to N modulus.Wherein, the power exponent of the Montgomery Algorithm device is n, and the modulus of the Montgomery Algorithm device is N.Specifically
Ground, the power exponent of the Montgomery Algorithm device are the value of first arithmetic register, and the power truth of a matter of the Montgomery Algorithm device is institute
The value of the 4th arithmetic register is stated, the modulus of the Montgomery Algorithm device is the value of second arithmetic register
In an embodiment of the present invention, the Montgomery Algorithm device can be Montgomery modular power operation device.
It is worth noting that, in an embodiment of the present invention, arithmetic unit and modular multiplication device are subtracted using mould plus arithmetic unit, mould
Etc. hardware module(Software is may be selected in Montgomery Algorithm device or hardware is realized)To calculate value of R and the R product to N modulus, reduce
Execution time of computing, so as to improve data-handling efficiency.
Embodiments of the invention additionally provide a kind of data processing equipment based on Montgomery Algorithm, refer to Fig. 2, the base
Include in the data processing equipment 200 of Montgomery Algorithm:Data capture unit 210, for the long n of mould to be stored in into the first computing deposit
Device, and modulus N is stored in the second arithmetic register;Modulo operation device 220, the N in the second arithmetic register is taken for obtaining R
The result X of mould, X is stored in the 3rd arithmetic register, wherein, R=2n;First mould adds arithmetic unit 230, for being transported to the described 3rd
The value progress mould for calculating register adds computing, obtains result Ys of the 2R to N modulus, and Y is stored in into the 4th arithmetic register;Mould power is transported
Device 240 is calculated, for carrying out Montgomery Algorithm to the value of the 4th arithmetic register, obtains result Z deposit fiveth fortune of the R*R to N modulus
Register is calculated, wherein, the power exponent of the Montgomery Algorithm device is the value of first arithmetic register, the Montgomery Algorithm device
The power truth of a matter is the value of the 4th arithmetic register, and the modulus of the Montgomery Algorithm device is the value of second arithmetic register.
Fig. 3 is refer to, in an embodiment of the present invention, the modulo operation device 220 can include:Radix-minus-one complement arithmetic unit 221,
For calculating N radix-minus-one complementSecond mould adds arithmetic unit 222, for calculating the radix-minus-one complementAdd the value after computing with 1 progress mould,
Second mould adds the value that the modulus of arithmetic unit is second arithmetic register.Specifically, the radix-minus-one complement arithmetic unit 221 can be with
For mould plus arithmetic unit.
Fig. 4 is refer to, in an embodiment of the present invention, the modulo operation device 220 can also include:Data acquisition is single
Member 223, for R/2 to be stored in into the 6th arithmetic register;3rd mould adds arithmetic unit 224, for the 6th arithmetic register
Value carry out mould and add computing, wherein, the 3rd mould adds the addend of arithmetic unit and summand is respectively the 6th computing deposit
The value of device, the 3rd mould add the value that the modulus of arithmetic unit is second arithmetic register.
In an embodiment of the present invention, the 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 can
To instruct the hardware of correlation to complete by program, the program can be stored in a computer-readable recording medium, storage
Medium can include:ROM, RAM, disk or CD etc..
Although present disclosure is as above, the present invention is not limited to this.Any those skilled in the art, this is not being departed from
In the spirit and scope of invention, it can make various changes or modifications, therefore protection scope of the present invention should be with claim institute
The scope of restriction is defined.
Claims (6)
- A kind of 1. data processing method based on Montgomery Algorithm, it is characterised in that including:The long n of mould is stored in the first arithmetic register, and modulus N is stored in the second arithmetic register;Result Xs of the R to the N modulus in the second arithmetic register is obtained, X is stored in the 3rd arithmetic register, wherein, R=2n;Institute State acquisition R includes to the result of N modulus:Calculate N radix-minus-one complementThe second mould is called to add arithmetic unit to calculate the radix-minus-one complementCarried out with 1 Mould adds the value after computing, and second mould adds the value that the modulus of arithmetic unit is second arithmetic register;Or R/2 is deposited Enter the 6th arithmetic register, call the 3rd mould to add arithmetic unit to carry out mould to the value of the 6th arithmetic register and add computing, wherein, 3rd mould adds the addend of arithmetic unit and summand is respectively the value of the 6th arithmetic register, and the 3rd mould adds computing The modulus of device is the value of second arithmetic register;Call the first mould to add arithmetic unit to carry out mould to the value of the 3rd arithmetic register and add computing, obtain knots of the 2R to N modulus Fruit Y, and Y is stored in the 4th arithmetic register;Call Montgomery Algorithm device to carry out Montgomery Algorithm to the value of the 4th arithmetic register, obtain R*R and the result Z of N modulus is stored in 5th arithmetic register, wherein, the power exponent of the Montgomery Algorithm device is the value of first arithmetic register, the mould power fortune The power truth of a matter for calculating device is the value of the 4th arithmetic register, and the modulus of the Montgomery Algorithm device is second arithmetic register Value.
- 2. the method as described in claim 1, it is characterised in that call mould to subtract the radix-minus-one complement that arithmetic unit calculates N
- 3. the method as described in claim 1, it is characterised in that the Montgomery Algorithm device is Montgomery Montgomery Algorithm device.
- A kind of 4. data processing equipment based on Montgomery Algorithm, it is characterised in that including:Data capture unit, for the long n of mould to be stored in into the first arithmetic register, and modulus N is stored in the second arithmetic register;Modulo operation device, for obtaining result Xs of the R to the N modulus in the second arithmetic register, X is stored in the 3rd computing deposit Device, wherein, R=2n;The modulo operation device includes:Radix-minus-one complement arithmetic unit, for calculating N radix-minus-one complementSecond mould adds arithmetic unit, For calculating the radix-minus-one complementAdd the value after computing with 1 progress mould, second mould adds the modulus of arithmetic unit to be the described second fortune Calculate the value of register;OrThe modulo operation device includes:Data acquisition subelement, for R/2 to be stored in into the 6th arithmetic register;3rd mould adds arithmetic unit, adds computing for carrying out mould to the value of the 6th arithmetic register, wherein,3rd mould adds the addend of arithmetic unit and summand is respectively the value of the 6th arithmetic register, and the 3rd mould adds The modulus of arithmetic unit is the value of second arithmetic register;First mould adds arithmetic unit, adds computing for carrying out mould to the value of the 3rd arithmetic register, obtains knots of the 2R to N modulus Fruit Y, and Y is 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 and the result Z of N modulus is stored in 5th arithmetic register, wherein, the power exponent of the Montgomery Algorithm device is the value of first arithmetic register, the mould power fortune The power truth of a matter for calculating device is the value of the 4th arithmetic register, and the modulus of the Montgomery Algorithm device is second arithmetic register Value.
- 5. device as claimed in claim 4, it is characterised in that the radix-minus-one complement arithmetic unit is that mould adds arithmetic unit.
- 6. device as claimed in claim 4, it is characterised in that the 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 CN104750457A (en) | 2015-07-01 |
CN104750457B true 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) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106681691B (en) * | 2015-11-07 | 2019-01-29 | 上海复旦微电子集团股份有限公司 | Data processing method, modular multiplication method and apparatus based on montgomery modulo 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 |
Also Published As
Publication number | Publication date |
---|---|
CN104750457A (en) | 2015-07-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Güneysu et al. | Ultra high performance ECC over NIST primes on commercial FPGAs | |
Schinianakis et al. | An RNS implementation of an $ F_ {p} $ elliptic curve point multiplier | |
Kudithi | An efficient hardware implementation of the elliptic curve cryptographic processor over prime field | |
Zhao et al. | Ultra high-speed SM2 ASIC implementation | |
US20100146028A1 (en) | Method and apparatus for modulus reduction | |
CN106681690A (en) | Montgomery modular multiplication based data processing method, modular multiplication operation method and device | |
CN104679474A (en) | Multiplying unit on finite field GF (2 227) and modular multiplication algorithm | |
CN103942031A (en) | Elliptic domain curve operational method and elliptic domain curve arithmetic unit | |
CN107015782A (en) | A kind of Galois field multiplier based on irreducible trinomial | |
Ding et al. | Broken-Karatsuba multiplication and its application to Montgomery modular multiplication | |
KR102132261B1 (en) | Method and apparatus for computing montgomery multiplication performing final reduction wihhout comparator | |
WO2019242562A1 (en) | Elliptic curve point multiplication operation method and apparatus | |
JP4180024B2 (en) | Multiplication remainder calculator and information processing apparatus | |
CN106445464A (en) | Compound finite domain multiplier based on heartbeat model | |
CN102571342B (en) | A kind of RSA Algorithm digital signature method | |
Niasar et al. | Optimized architectures for elliptic curve cryptography over Curve448 | |
CN104660399B (en) | A kind of RSA modular exponentiation operation method and device | |
Hossain et al. | Efficient fpga implementation of modular arithmetic for elliptic curve cryptography | |
CN104750455B (en) | A kind of data processing method and device based on montgomery modulo multiplication | |
CN106681691B (en) | Data processing method, modular multiplication method and apparatus based on montgomery modulo multiplication | |
CN104750457B (en) | A kind of data processing method and device based on Montgomery Algorithm | |
CN103580869B (en) | A kind of CRT-RSA signature method and device | |
CN104506316A (en) | Point multiplication operation method based on SM2 base points | |
Liu et al. | Efficient digit-serial KA-based multiplier over binary extension fields using block recombination approach | |
CN107885486A (en) | A kind of compound finite field inversions device based on search tree |
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 |