예제 #1
0
 def test_stb_verify(self):
     p = 0x43FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     p = reverse(p)
     a = 0x40FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     a = reverse(a)
     b = 0xF1039CD66B7D2EB253928B976950F54CBEFBD8E4AB3AC1D2EDA8F315156CCE77
     b = reverse(b)
     q = 0x07663D2699BF5A7EFC4DFB0DD68E5CD9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     q = reverse(q)
     y = 0x936A510418CF291E52F608C4663991785D83D651A3C9E45C9FD616FB3CFCF76B
     y = reverse(y)
     message = 0xB194BAC80A08F53B366D008E584A5DE48504FA9D1BB6C7AC252E72C202FDCE0D5BE3D61217B96181FE6786AD716B890B
     q_x = 0xBD1A5650179D79E03FCEE49D4C2BD5DDF54CE46D0CF11E4FF87BF7A890857FD0
     q_x = reverse(q_x)
     q_y = 0x7AC6A60361E8C8173491686D461B2826190C2EDA5909054A9AB84D2AB9D99A90
     q_y = reverse(q_y)
     s = (0x47A63C8B9C936E94B5FAB3D9CBD78366, 0x290F3210E163EEC8DB4E921E8479D4138F112CC23E6DCE65EC5FF21DF4231C28)
     pub_key = (q_x, q_y)
     stb = STB(p, a, b, q, y, 128)
     self.assertEqual(stb.verify(message, pub_key, s), True)
예제 #2
0
 def test_stb_sign(self):
     p = 0x43FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     p = reverse(p)
     a = 0x40FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     a = reverse(a)
     b = 0xF1039CD66B7D2EB253928B976950F54CBEFBD8E4AB3AC1D2EDA8F315156CCE77
     b = reverse(b)
     q = 0x07663D2699BF5A7EFC4DFB0DD68E5CD9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     q = reverse(q)
     y = 0x936A510418CF291E52F608C4663991785D83D651A3C9E45C9FD616FB3CFCF76B
     y = reverse(y)
     d = 0x1F66B5B84B7339674533F0329C74F21834281FED0732429E0C79235FC273E269
     d = reverse(d)
     stb = STB(p, a, b, q, y, 128)
     message = 0xB194BAC80A08F53B366D008E58
     k = 0x4C0E74B2CD5811AD21F23DE7E0FA742C3ED6EC483C461CE15C33A77AA308B7D2
     k = reverse(k)
     signature = stb.sign(message, d, k)
     expected = (0xE36B7F0377AE4C524027C387FADF1B20,
                 0xCE72F1530B71F2B5FD3A8C584FE2E1AED20082E30C8AF65011F4FB54649DFD3D)
     self.assertEqual(signature, expected)