CN103929305A - SM2 signature algorithm implementation method - Google Patents
SM2 signature algorithm implementation method Download PDFInfo
- Publication number
- CN103929305A CN103929305A CN201310016288.7A CN201310016288A CN103929305A CN 103929305 A CN103929305 A CN 103929305A CN 201310016288 A CN201310016288 A CN 201310016288A CN 103929305 A CN103929305 A CN 103929305A
- Authority
- CN
- China
- Prior art keywords
- montgomery
- point
- coordinate
- calculates
- represent
- 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
Links
Landscapes
- Storage Device Security (AREA)
Abstract
The invention discloses an SM2 signature algorithm implementation method. The method comprises the steps of step one, mapping a base point G from a weierstrass mode to a Montgomery mode; step two, setting (img file = 'DDA00002742588300011.TIF' wi= '341' he= '85'/); step three, (img file = 'DDA00002742588300012.TIF' wi= '279' he= '84'/); step four, selecting the random number k<[1,n-1]; step five, making kG in the Montgomery mode and setting Kg as (x1,y1), and converting x1 into an integer; step six, calculating r<- (e+x1) modn, and returning to step four if r =m or r+k =m; step seven, calculating s<-((1+dA) -1*(k-r*dA)) modn, and returning to step four if s =0; step eight, returning a digital signature (r, s). According to the method, the SM2 signature algorithm scheme can save storage space during calculation.
Description
Technical field
The present invention relates to field of cryptography, particularly relate to a kind of implementation method of SM2 signature algorithm.
Background technology
Password Management office of country has announced < < SM2 ellipse curve public key cipher algorithm > > in December, 2010, SM2 algorithm is a kind of elliptic curve (ECC) in essence, in detail, SM2 algorithm dictates the details such as signature, checking, cipher key change.
SM2 signature algorithm is a kind of elliptic curve numeral authentication method, and confirmation that can be to Data Source, guarantees signer non-repudiation.
Elliptic curve Montgomery (Montgomery) form is E
m: By
2=x
3+ Ax+x, under this form, point add operation and point doubling are not need y coordinate; And at elliptic curve weierstrass (Weierstrass) form E:y
2=x
3+ ax+b, point add operation and point doubling need to add y coordinate; When being computing, its shortcoming can take a large amount of memory spaces.
Summary of the invention
The technical problem to be solved in the present invention is to provide a kind of implementation method of SM2 signature algorithm, can reduce the memory space of computing.
For solving the problems of the technologies described above, the implementation method of SM2 signature algorithm of the present invention, comprises the steps:
Step 1, is mapped to Montgomery form by basic point G from weierstrass form;
Step 2, puts
wherein, Z
abe user's Hash Value, M is information, ← be assignment;
Step 3, calculates
wherein H (x) is hash function;
Step 4, chooses random number k ∈ [1, n-1];
Step 5 is made kG under the form of Montgomery, and making it is (x
1, y
1), and by x
1be converted into integer;
Step 6, calculates r ← (e+x
1) mod n, if r=0 or r+k=n return to step 4;
Step 7, calculates s ← ((1+d
a)
-1* (k-r*d
a)) mod n, if s=0 returns to step 4, wherein d
ait is private key for user;
Step 8, returns to digital signature (r, s).
The present invention is mapped to Montgomery form regeneration by SM2 signature algorithm from weierstrass form and generates signature to (r, s), because under the form of Montgomery, the point add operation of elliptic curve and point doubling do not need y coordinate, the memory space in the time of can greatly reducing computing.
Accompanying drawing explanation
Below in conjunction with accompanying drawing and embodiment, the present invention is further detailed explanation:
Fig. 1 is the flow chart of the implementation method of described SM2 signature algorithm;
Fig. 2 calculates kG=(x
1, y
1) flow chart.
Embodiment
The present invention, from traditional elliptic curve weierstrass form, is converted into Montgomery form, then signs.Shown in Fig. 1, the implementation method of described SM2 signature algorithm, input parameter is elliptic curve parameter, Z
a, M, P
a, d
a, Z wherein
abe user's Hash Value, M is information, P
aclient public key, d
abe private key for user, comprise the steps:
Step 1, is mapped to Montgomery form by basic point G from weierstrass form;
Step 2, puts
Step 3, calculates
wherein, H (x) is hash function;
Step 4, chooses random number k ∈ [1, n-1];
Step 5 is made kG=(x under the form of Montgomery
1, y
1), and by x
1be converted into integer;
Step 6, calculates r ← (e+x
1) mod n, if r=0 or r+k=n return to step 4;
Step 7, calculates s ← ((1+d
a)
-1* (k-r*d
a)) mod n, if s=0 returns to step 4;
Step 8, returns to digital signature (r, s).
Computing in above steps is all carried out under the form of Montgomery (Montgomery).
In step 1, basic point G is mapped to Montgomery form from weierstrass form also needs to meet specified conditions:
Elliptic curve weierstrass form E:y
2=x
3+ ax+b, at finite field F
pmiddle x
3+ ax+b=0 has root, is made as α, simultaneously 3 α
2+ a is the quadratic residue of p.
Order
Carry out again coordinate transform
Weierstrass form E:y
2=x
3+ ax+b just can be mapped to Montgomery form E
m: By
2=x
3+ Ax+x is upper, B=s wherein, A=3 α s.
In described step 5, by calling the algorithm of following steps, calculate kG=(x
1, y
1):
Step (1), input integer k and G=(x: y: 1);
Step (2), and calculating 2G=(x ': y ': z ');
Step (3), G ' ← 2G;
Step (4), is launched into binary form integer k
k wherein
s-1=1;
Step (5) circulates from i=s-2 to i=0:
Step (6), if k
i=0, Q ' ← G '+G, Q ← 2G, if k
i=1, Q ← G '+G, Q ' ← 2G ';
Step (7), G ' ← Q ', G ← Q;
Step (8), i ← i-1;
Step (9), after circulation finishes, output point G;
Finally, the value of some G just equals required kG.
And all the other steps are to generate to have signed to (r, s).
Described step (6) point add operation and point doubling are to complete under the form of Montgomery, and curve form is E
m: By
2=x
3+ Ax+x.Concrete operation formula used is as follows:
Point add operation:
X
2m+1=Z
1((X
m+1-Z
m+1)(X
m+Z
m)+(X
m+1+Z
m+1)(X
m-Z
m))
2
Z
2m+1=X
1((X
m+1-Z
m+1)(X
m+Z
m)-(X
m+1+Z
m+1)(X
m-Z
m))
2
2 point doublings:
X
2m=(X
m+Z
m)
2(X
m-Z
m)
2
Wherein, X
1represent the X coordinate of basic point, Z
1represent the Z coordinate of basic point, X
mrepresent the X coordinate that m is ordered, Z
mrepresent the Z coordinate that m is ordered.
An embodiment below:
Choose and get prime number p=2
192-2
64-1, set up finite field F
p, for weierstrass form elliptic curve E (F
p): y
2=x
3+ ax+b, wherein:
a=0x6A57BA7CC7CA8D851ACBB58340EB80F0E8372EF409A67DDA
b=0x6C681624BCF461FAB96DE16AA545D775E66382F2CEC977CA
α=0xA4413AD3EF0CF90F91DF3FDBB089DC51876087BA609E7664
Meet α
3+ a α+b=0, and 3 α
2+ a is the quadratic residue of p.Choose
G=(37,234,817,531,077,503,299,542,912,797,226,283,109,347,945,036,092,741,173 35,34,212,690,789,145,242,334,546,290,613,444,983,044,748,276,014,286,432,549 21,1), order
just changed into Montgomery curve form, its X coordinate
X=3860313548999787338078427342307244695792884328213221870944,
With Z coordinate Z=1,
If k=179=1*2
0+ 1*2
1+ 0*2
2+ 0*2
3+ 1*2
4+ 1*2
5+ 0*2
6+ 1*2
7kG is calculated as follows:
k i | k 7 | k 6 | k 5 | k 4 | k 3 | k 2 | k 1 | k 0 |
179 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
Q | G | 2G | 5G | 11G | 22G | 44G | 89G | 1?79G |
Q′ | 2G | 3G | 6G | 12G | 23G | 45G | 90G | 1?80G |
Visible 179P is required.Its X coordinate, it is as follows that Z sits target value:
X=620772673523943864697586076752183162272170717129942472090
Z=154061983259894946655828807576947185385080422622278501903。
So x
1=X/Z.Generating afterwards that the step of signature right (r, s) namely carries out under the form of Montgomery, is also feasible.Sign test process too, so just can not calculated y coordinate, thereby save memory space simultaneously.
Below through the specific embodiment and the embodiment, the present invention is had been described in detail, but protection scope of the present invention is not limited to described execution mode and embodiment.Without departing from the principles of the present invention, those skilled in the art also can make many distortion and improvement, and these also should be considered as protection scope of the present invention.
Claims (4)
1. an implementation method for SM2 signature algorithm, is characterized in that, comprises the steps:
Step 1, is mapped to Montgomery form by basic point G from weierstrass form;
Step 2, puts
wherein, Z
abe user's Hash Value, M is information, ← be assignment;
Step 3, calculates
h(x wherein) be hash function;
Step 4, chooses random number k ∈ [1, n-1], and wherein n is the rank of a G;
Step 5 is made kG under the form of Montgomery, and making it is (x
1, y
1), and by x
1be converted into integer;
Step 6, calculates r ← (e+x
1) modn, if r=0 or r+k=n return to step 4; "
Step 7, calculates s ← ((1+d
a)
-1* (k-r*d
a)) modn, if s=0 returns to step 4, wherein d
abe private key for user, * represents multiplication sign;
Step 8, returns to digital signature (r, s).
2. the method for claim 1, is characterized in that: the computing in each step is all carried out under the form of Montgomery.
3. the method for claim 1, is characterized in that: during implementation step five, calculate by the following method kG=(x
1, y
1);
Step (1), input integer k and G=(x: y: 1);
Step (2), calculates 2G=(x ': y ': z ');
Step (3), G ' ← 2G;
Step (4), is launched into binary form integer k
k wherein
s-1=1;
Step (5) circulates from i=s-2 to i=0:
Step (6), if k
i=W, Q ' ← G '+G, Q ← 2G, if k
i=1, Q ← G '+G, Q ' ← 2G ';
Step (7), G ' ← Q ', G ← Q;
Step (8), i ← i-1;
Step (9), after circulation finishes, output point G;
Finally, the value of some G just equals required kG.
4. method as claimed in claim 3, is characterized in that: point add operation and point doubling in described step (6) complete under the form of Montgomery, and curve form is E
m: Ey
2=X
3+ Ax+x; B, A is elliptic curve parameter, wherein:
Point add operation is calculated as follows:
X
2m+1=Z
1((X
m+1-Z
m+1)(X
m+Z
m)+(X
m+1+Z
m+1)(X
m-Z
m))
2,
Z
2m+1=X
1((X
m+1-Z
m+1)(X
m+Z
m)-(X
m+1+Z
m+1)(X
m-Z
m))
2
2 point doublings are calculated as follows:
X
2m=(X
mten Z
m)
2(X
m-Z
m)
2
Wherein, X
1represent the X coordinate of basic point G, Z
1represent the Z coordinate of basic point G, X
mrepresent the X coordinate that m is ordered, Z
mrepresent the Z coordinate that m is ordered.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310016288.7A CN103929305A (en) | 2013-01-16 | 2013-01-16 | SM2 signature algorithm implementation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310016288.7A CN103929305A (en) | 2013-01-16 | 2013-01-16 | SM2 signature algorithm implementation method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103929305A true CN103929305A (en) | 2014-07-16 |
Family
ID=51147390
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310016288.7A Pending CN103929305A (en) | 2013-01-16 | 2013-01-16 | SM2 signature algorithm implementation method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103929305A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106712942A (en) * | 2017-01-10 | 2017-05-24 | 武汉理工大学 | SM2 digital signature generation method and system based on secret sharing |
CN106850198A (en) * | 2017-01-16 | 2017-06-13 | 武汉理工大学 | SM2 digital signature generation method and system based on the collaboration of many devices |
CN107425968A (en) * | 2017-06-22 | 2017-12-01 | 广东工业大学 | A kind of SM2 elliptic curve public key cryptographic algorithms under binary field F2m realize system |
CN109936455A (en) * | 2017-12-19 | 2019-06-25 | 航天信息股份有限公司 | A kind of methods, devices and systems of digital signature |
CN114895870A (en) * | 2022-04-29 | 2022-08-12 | 中国人民解放军93216部队 | Efficient reconfigurable SM2 dot product method and system based on FPGA |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090207997A1 (en) * | 2001-12-10 | 2009-08-20 | Tsuyoshi Takagi | Elliptic curve cryptosystem apparatus, storage medium storing elliptic curve cryptosystem program and elliptic curve cryptosystem arithmetic method |
CN102761415A (en) * | 2011-04-27 | 2012-10-31 | 航天信息股份有限公司 | System for generating, verifying and mixing digital signatures of p-element domain SM2 elliptic curves |
CN102761413A (en) * | 2011-04-27 | 2012-10-31 | 航天信息股份有限公司 | Implementation system of p-element domain SM2 elliptic curve public key cryptographic algorithm |
CN102761412A (en) * | 2011-04-27 | 2012-10-31 | 航天信息股份有限公司 | P-element domain SM2 elliptic curve public key encryption, decryption and encryption-decryption hybrid system |
-
2013
- 2013-01-16 CN CN201310016288.7A patent/CN103929305A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090207997A1 (en) * | 2001-12-10 | 2009-08-20 | Tsuyoshi Takagi | Elliptic curve cryptosystem apparatus, storage medium storing elliptic curve cryptosystem program and elliptic curve cryptosystem arithmetic method |
CN102761415A (en) * | 2011-04-27 | 2012-10-31 | 航天信息股份有限公司 | System for generating, verifying and mixing digital signatures of p-element domain SM2 elliptic curves |
CN102761413A (en) * | 2011-04-27 | 2012-10-31 | 航天信息股份有限公司 | Implementation system of p-element domain SM2 elliptic curve public key cryptographic algorithm |
CN102761412A (en) * | 2011-04-27 | 2012-10-31 | 航天信息股份有限公司 | P-element domain SM2 elliptic curve public key encryption, decryption and encryption-decryption hybrid system |
Non-Patent Citations (1)
Title |
---|
王潮,时向勇,牛志华: "基于 Montgomery 曲线改进 ECDSA 算法的研究", 《通信学报》 * |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106712942A (en) * | 2017-01-10 | 2017-05-24 | 武汉理工大学 | SM2 digital signature generation method and system based on secret sharing |
CN106712942B (en) * | 2017-01-10 | 2019-08-23 | 武汉理工大学 | SM2 digital signature generation method and system based on privacy sharing |
CN106850198A (en) * | 2017-01-16 | 2017-06-13 | 武汉理工大学 | SM2 digital signature generation method and system based on the collaboration of many devices |
CN106850198B (en) * | 2017-01-16 | 2019-10-25 | 武汉理工大学 | SM2 digital signature generation method and system based on the collaboration of more devices |
CN107425968A (en) * | 2017-06-22 | 2017-12-01 | 广东工业大学 | A kind of SM2 elliptic curve public key cryptographic algorithms under binary field F2m realize system |
CN109936455A (en) * | 2017-12-19 | 2019-06-25 | 航天信息股份有限公司 | A kind of methods, devices and systems of digital signature |
CN109936455B (en) * | 2017-12-19 | 2022-06-07 | 航天信息股份有限公司 | Digital signature method, device and system |
CN114895870A (en) * | 2022-04-29 | 2022-08-12 | 中国人民解放军93216部队 | Efficient reconfigurable SM2 dot product method and system based on FPGA |
CN114895870B (en) * | 2022-04-29 | 2022-11-25 | 中国人民解放军93216部队 | Efficient reconfigurable SM2 dot multiplication method and system based on FPGA |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6682041B2 (en) | Processing method of fully homomorphic encryption based on modulo arithmetic | |
US10778410B2 (en) | Homomorphic data encryption method and apparatus for implementing privacy protection | |
CN103427997B (en) | A kind of method generating digital signature and device | |
CN109145616B (en) | SM2 encryption, signature and key exchange implementation method and system based on efficient modular multiplication | |
US8345864B1 (en) | Elliptic curve cryptography scalar multiplication with on demand acceleration table generation | |
CN104811298B (en) | One kind realizes encrypted method and device | |
WO2015164996A1 (en) | Elliptic domain curve operational method and elliptic domain curve operational unit | |
CN106712965B (en) | Digital signature method and device and password equipment | |
JP2009537025A5 (en) | ||
CN103929305A (en) | SM2 signature algorithm implementation method | |
CN101763241B (en) | Large integer modular arithmetic device for realizing signature algorithm in ECC cryptosystem and modular method therefor | |
US11902432B2 (en) | System and method to optimize generation of coprime numbers in cryptographic applications | |
RU2011134050A (en) | ELLIPTIC CURVE POINT ENCODING | |
CN109962783B (en) | SM9 digital signature collaborative generation method and system based on progressive calculation | |
CN113708927A (en) | Universal designated verifier signature certification system based on SM2 digital signature | |
CN103580869B (en) | A kind of CRT-RSA signature method and device | |
CN105119929A (en) | Safe mode index outsourcing method and system under single malicious cloud server | |
CN102769530A (en) | Efficiently-calculated on-line/off-line digital signature method | |
CN110266486B (en) | SM9 digital signature simple generation method and system based on product secret sharing | |
CN104506316A (en) | Point multiplication operation method based on SM2 base points | |
Pund et al. | Implementation of RSA algorithm using mersenne prime | |
CN108008934B (en) | Composite finite field inversion device based on lookup table | |
RU120303U1 (en) | DEVICE FOR TRANSFORMING DATA BLOCKS DURING ENCRYPTION | |
CN102546160B (en) | For the method for elliptic curve cipher defence differential power attack | |
RU2401513C2 (en) | Method for generating and verification electronic digital signature authenticating electronic document |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20140716 |
|
WD01 | Invention patent application deemed withdrawn after publication |