Created
July 1, 2023 21:31
-
-
Save JanisErdmanis/b73f21e2bd0b5a7241ad374181aa004b to your computer and use it in GitHub Desktop.
Testing secp256r1 curve on CryptoGroups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let's test that the curve is on the | |
# https://www.herongyang.com/EC-Cryptography/Curve-secp256r1-for-256-Bit-ECC-Keys.html | |
using CryptoGroups | |
using Base64 | |
curve = CryptoGroups.curve("secp256r1") | |
P_256 = specialize(ECPoint, curve) | |
g = convert(P_256, generator(curve)) | |
priv_key_str = "f5:02:fb:91:1d:74:6b:77:f4:43:8c:67:4e:1c:43:65:0b:68:28:5d:fc:c0:58:3c:49:cd:6e:d8:8f:0f:bb:58" | |
pub_key_str = "04:f9:4c:20:d6:82:da:29:b7:e9:99:85:d8:db:a6:ab:ea:90:51:d1:65:08:74:28:99:83:50:98:b1:11:3d:3d:74:94:66:64:4c:47:b5:59:db:18:45:56:c1:73:3c:33:e5:78:8a:e2:50:b8:fb:45:f2:9d:4c:f4:8f:f7:52:c1:ed" | |
priv_key = parse(BigInt, replace(priv_key_str, ":"=>""), base=16) | |
pub_key = convert(P_256, hex2bytes(replace(pub_key_str, ":"=>""))) | |
@assert pub_key == g * priv_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment