首先给出SM2p256v1椭圆曲线的建议参数如下:
default_ecc_table = {
'n': 'FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123',
'p': 'FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF',
'g': '32c4ae2c1f1981195f9904466a39c9948fe30bbff2660be1715a4589334c74c7'
'bc3736a2f4f6779c59bdcee36b692153d0a9877cc62a474002df32e52139f0a0',
'a': 'FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC',
'b': '28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93',
}
椭圆曲线点加(x1,y1)+(x2,y2)
tSm2 = sm2.CryptSM2('', '')
xy_h = tSm2._convert_jacb_to_nor(tSm2._add_point(x1_h+y1_h, x2_h+y2_h))
x_h = xy_h[0:64]
y_h = xy_h[64:]
椭圆曲线点减(x1,y1)-(x2,y2)
p = int.from_bytes(bytes.fromhex(sm2.default_ecc_table['p']))
_y2 = p - y2
tSm2 = sm2.CryptSM2('', '')
_y2_h = hex(_y2).replace('0x','')
xy_h = tSm2._convert_jacb_to_nor(tSm2._add_point(x1_h + y1_h, x2_h + _y2_h))
x_h = xy_h[0:64]
y_h = xy_h[64:]
椭圆曲线倍点k*(x1,y1)
tSm2 = sm2.CryptSM2('', '')
xy_h = tSm2._kg(int(k_h, 16), x1_h + y1_h )
x_h = xy_h[0:64]
y_h = xy_h[64:]
实现结果: