diff options
author | Niels Möller <nisse@lysator.liu.se> | 2014-08-24 21:02:12 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2014-08-24 21:02:12 +0200 |
commit | 40e2b07ab0b69e7fb1c0d6b62212b2ee2b4a7e32 (patch) | |
tree | eca39a829b4464a30caa13521888ad64dcac2849 /misc | |
parent | 8b4816547c1e96b85a6de77021c88f7a818626fa (diff) | |
download | nettle-40e2b07ab0b69e7fb1c0d6b62212b2ee2b4a7e32.tar.gz |
New script ecc-ref.gp.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/ecc-ref.gp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/misc/ecc-ref.gp b/misc/ecc-ref.gp new file mode 100644 index 00000000..2af41755 --- /dev/null +++ b/misc/ecc-ref.gp @@ -0,0 +1,30 @@ +/* Script for pari/gp. Run as gp -q ecc-ref.gp */ + +out(apriv, A, bpriv, B, S) = print( \ + "/* a_s */ \"", apriv, "\",\n", \ + "/* a_x */ \"", component(A[1], 2), "\",\n", \ + "/* a_y */ \"", component(A[2], 2), "\",\n", \ + "/* b_s */ \"", bpriv, "\",\n", \ + "/* b_x */ \"", component(B[1], 2), "\",\n", \ + "/* b_y */ \"", component(B[2], 2), "\",\n", \ + "/* s_x */ \"", component(S[1], 2), "\",\n", \ + "/* s_y */ \"", component(S[2], 2), "\","); + +p192 = 2^192 - 2^64 - 1; +b192 = 2455155546008943817740293915197451784769108058161191238065; +g192 = Mod([602046282375688656758213480587526111916698976636884684818, \ + 174050332293622031404857552280219410364023488927386650641], p192); +secp192 = ellinit(Mod([0,0,0,-3, b192], p192)); +q192 = 6277101735386680763835789423176059013767194773182842284081; +if (ellorder(secp192, g192) != q192, error("secp192 parameter error")); + +a192 = 1+random(q192-1); +b192 = 1+random(q192-1); +A192 = ellpow(secp192, g192, a192); +B192 = ellpow(secp192, g192, b192); +S192 = ellpow(secp192, A192, b192); +if (S192 != ellpow(secp192, B192, a192), error("secp192 dh error")); +print("secp192"); +out(a192, A192, b192, B192, S192); + +quit |