diff options
author | Pavel V. Shatov (Meister) <meisterpaul1@yandex.ru> | 2018-04-06 21:52:21 +0300 |
---|---|---|
committer | Pavel V. Shatov (Meister) <meisterpaul1@yandex.ru> | 2018-04-06 21:52:21 +0300 |
commit | 5c26d791ba611a00af3a6010c014694f6582bf12 (patch) | |
tree | b739a2f48441d800c5007f42e7d67e8d3ddc5671 /fpga_curve.cpp | |
parent | 5e78217a13bcda8d06db5f4d8c7446bcef940cba (diff) |
* Follow more closely what Verilog does
* Don't use hardcoded numbers, use the ones built into fastecdsa package
* Generate more test vectors to really abuse the core and trigger the rarely
used code path in the point addition procedure
Diffstat (limited to 'fpga_curve.cpp')
-rw-r--r-- | fpga_curve.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fpga_curve.cpp b/fpga_curve.cpp index 46f6f73..1efb8b6 100644 --- a/fpga_curve.cpp +++ b/fpga_curve.cpp @@ -305,9 +305,25 @@ void fpga_curve_scalar_multiply(FPGA_BUFFER *px, FPGA_BUFFER *py, FPGA_BUFFER *k FPGA_BUFFER rx, ry, rz; // intermediate result FPGA_BUFFER tx, ty, tz; // temporary variable + /* prepare for computation */ + fpga_buffer_copy(px, &rx); + fpga_buffer_copy(py, &ry); + fpga_buffer_copy(&ecdsa_one, &rz); + /* obtain quantity 2 * P */ - fpga_curve_double_jacobian(px, py, &ecdsa_one, &tx, &ty, &tz); - fpga_curve_point_to_affine(&tx, &ty, &tz, &ecdh_d_x, &ecdh_d_y); + fpga_curve_double_jacobian(&rx, &ry, &rz, &tx, &ty, &tz); + + /* copy again */ + fpga_buffer_copy(&tx, &rx); + fpga_buffer_copy(&ty, &ry); + fpga_buffer_copy(&tz, &rz); + + /* convert to affine coordinates */ + fpga_curve_point_to_affine(&rx, &ry, &rz, qx, qy); + + /* store for later reuse */ + fpga_buffer_copy(qx, &ecdh_d_x); + fpga_buffer_copy(qy, &ecdh_d_y); /* set initial value of R to point at infinity */ fpga_buffer_copy(&ecdsa_one, &rx); |