forked from zweib730/SM9-misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm9-key-cap
73 lines (62 loc) · 4.1 KB
/
sm9-key-cap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
*********************** SM9 key Generation ***************************
**********************PublicKey Ppubs=[ke]P1:*************************
787ed7b8a51f3ab84e0a66003f32da5c720b17eca7137d39abc66e3c80a892ff
769de61791e5adc4b9ff85a31354900b202871279a8c49dc3f220f644c57a7b1
**************The private key deB = (xdeB, ydeB):*********************
94736acd2c8c8796cc4785e938301a139a059d3537b6414140b2d31eecf41683115bae85f5d8bc6c3dbd9e5342979acccf3c2f4f28420b1cb4f8c0b59a19b158
7aa5e47570da7600cd760a0cf7beaf71c447f3844753fe74fa7ba92ca7d3b55f27538a62e7f7bfb51dce08704796d94c9d56734f119ea44732b50e31cdeb75c1
///////////////////SM9 Key encapsulation mechanism//////////////////////
************************ H1(IDB||hid,N) ************************
9CB1F6288CE0E51043CE72344582FFC301E0A812A7F5F2004B85547A24B82716
*******************QB:=[H1(IDB||hid,N)]P1+Ppube*****************
709D165808B0A43E2574E203FA885ABCBAB16A240C4C1916552E7C43D09763B8
693269A6BE2456F43333758274786B6051FF87B7F198DA4BA1A2C6E336F51FCC
***********************randnum r: ******************************
74015F8489C01EF4270456F9E6475BFB602BDE7F33FD482AB4E3684A6722
*********************** C=[r]QB: ******************************
1EDEE2C3F465914491DE44CEFB2CB434AB02C308D9DC5E2067B4FED5AAAC8A0F
1C9B4C435ECA35AB83BB734174C0F78FDE81A53374AFF3B3602BBC5E37BE9A4C
***********************g=e(Ppube,P2):****************************
9746FC5B231CEDF36F835C47893D63C6FF652BCB92375CE3C2AB256D1FD56413
232A2F80CFBAE061F196BB99213D50306648AC33CDC78E8F8A1563FFBF3BD3EB
68E8A16C0AC905F692904ABCC004B1ACF12106BD0A15B6E708D76E72B9288EF2
9436A60C403F4F8BAC4DD3E393E25419E634FC2B3DAF247F6092A802F60D5C58
A140EAEF3893D574CB83C01D951A53F51975760BE57F3BBD89817498D2158352
95A2BCCE25359D033FC654BD6A9E462E5BD0686FF6DDD7455F71FFF15AFFD3F0
B04320190B1E90CEDF6AC570147A23AE6F0EAE45034E6C62124DD6E8978F78AD
A504E3B43C1DD36794217FA1B05AC046C4131854C3D3E3A5B5967A64A861F0A2
897F7B35D1C0E21D84D75CFFAC08C73E744A16A47EE76E28A0B03849888D10FF
24443BB424B12C41EAF6D34D925205901F5CBA59CFEBA35224660DB3848B0BF5
825403FB3F681AB2B036DBBA25483D5CB98BD56F3DF95F0A7A705A2F6FD804B
9CE7BC68062182CF5D9F4A98C5A4ED1F3B4CE4EA817D19ED7EF2CE98E6F5864D
************************* w=g^r:*********************************
8EAB0CD6D0C95A6BBB7051AC848FDFB9689E5E5C486B1294557189B338B53B1D
78082BB40152DC35AC774442CC6408FFD68494D9953D77BF55E30E84697F6674
5AAF52239E46B0373B3168BAB75C32E048B5FAEBABFA1F7F9BA6B4C0C90E65B0
75F6A2D9ED54C87CDDD2EAA787032320205E7AC7D7FEAA8695AB2BF7F5710861
247C2034CCF4A1432DA1876D023AD6D74FF1678FDA3AF37A3D9F613CDE805798
8B07151BAC93AF48D78D86C26EA97F24E2DACC84104CCE8791FE90BA61B2049C
AAC6AB38EA07F9966173FD9BBF34AAB58EE84CD3777A9FD00BBCA1DC09CF8696
A1040465BD723AE513C4BE3EF2CFDC088A935F0B207DEED7AAD5CE2FC37D4203
4D874A4CE9B3B58765B1252A0880952B4FF3C97EA1A4CFDC67A0A0072541A03D
3924EABC443B0503510B93BBCD98EB70E0192B821D14D69CCB2513A1A7421EB7
A018A035E8FB61F271DE1C5B3E781C63508C113B3EAC537805EAE164D732FAD0
56BEA27C8624D5064C9C278A193D63F6908EE558DF5F5E0721317FC6E829C242
******************* K=KDF(C||w||IDB,klen):***********************
4ff5cf86d2ad40c8f4bac98d76abdbde0c0e2f0a829d3f911ef5b2bce0695480
///////////////////SM9 Key decapsulation mechanism//////////////////////
***********************w=e(C,deB):****************************
8EAB0CD6D0C95A6BBB7051AC848FDFB9689E5E5C486B1294557189B338B53B1D
78082BB40152DC35AC774442CC6408FFD68494D9953D77BF55E30E84697F6674
5AAF52239E46B0373B3168BAB75C32E048B5FAEBABFA1F7F9BA6B4C0C90E65B0
75F6A2D9ED54C87CDDD2EAA787032320205E7AC7D7FEAA8695AB2BF7F5710861
247C2034CCF4A1432DA1876D023AD6D74FF1678FDA3AF37A3D9F613CDE805798
8B07151BAC93AF48D78D86C26EA97F24E2DACC84104CCE8791FE90BA61B2049C
AAC6AB38EA07F9966173FD9BBF34AAB58EE84CD3777A9FD00BBCA1DC09CF8696
A1040465BD723AE513C4BE3EF2CFDC088A935F0B207DEED7AAD5CE2FC37D4203
4D874A4CE9B3B58765B1252A0880952B4FF3C97EA1A4CFDC67A0A0072541A03D
3924EABC443B0503510B93BBCD98EB70E0192B821D14D69CCB2513A1A7421EB7
A018A035E8FB61F271DE1C5B3E781C63508C113B3EAC537805EAE164D732FAD0
56BEA27C8624D5064C9C278A193D63F6908EE558DF5F5E0721317FC6E829C242
******************* K=KDF(C||w||IDB,klen):***********************
4ff5cf86d2ad40c8f4bac98d76abdbde0c0e2f0a829d3f911ef5b2bce0695480