@@ -82,16 +82,38 @@ If configured correctly, you should be able to add the antelope.ck library to yo
82
82
``` cpp
83
83
#include < ack/ack.hpp>
84
84
85
- // Calculate sum of 2 EC points on secp256k1 curve
85
+ // Calculate sum of 2 EC points on secp256k1 curve using affine coordinates
86
86
const auto p1 = ack::ec_curve::secp256k1.make_point( p1_x, p1_y );
87
87
const auto p2 = ack::ec_curve::secp256k1.generate_point( " 85d0c2e48955214783ecf50a4f041" );
88
88
const auto p3 = p1 + p2;
89
89
90
- // triple the p3 point
90
+ // Triple the p3 point
91
91
const auto p4 = p3 * 3 ;
92
92
93
- // multiply the inverse of p4 by integer 0x73c5f6a67456ae48209b5a32d1b8
93
+ // Multiply the inverse of p4 by integer 0x73c5f6a67456ae48209b5a32d1b8
94
94
const auto p5 = -p4 * " 73c5f6a67456ae48209b5a32d1b8" ;
95
+
96
+ // Generate 2 EC points on secp256r1 curve using Jacobi coordinates representation
97
+ using secp256r1_t = decltype( ack::ec_curve::secp256r1 );
98
+ using point_r1_jacobi = ack::ec_point_fp_jacobi<secp256r1_t >;
99
+
100
+ const auto p1 = ack::ec_curve::secp256k1.generate_point<point_r1_jacobi>( " 5d0c2e48955214783ecf50a4f041" );
101
+ const auto p2_affine = ack::ec_curve::secp256k1.make_point( p2_x, p2_y );
102
+ const auto p2 = point_r1_jacobi( p2_affine );
103
+
104
+ // Calculate sum of 2 EC points on secp256r1 curve in Jacobi coordinates
105
+ const auto p3 = p1 + p2;
106
+
107
+ // Double point p3
108
+ const auto p4 = p3 * 2 ; // or p3.doubled();
109
+
110
+ // Verify point p4 is not identity and lies on the curve
111
+ eosio::check ( !p4.is_identity(), "invalid point" );
112
+ eosio::check( p4.is_on_curve() , "invalid point" );
113
+ eosio::check( p4.is_valid() , "invalid point" );
114
+
115
+ // Convert point p4 to affine coordinates
116
+ const auto p4_affine = p4.to_affine();
95
117
96
118
// Verify secp256k1 ECDSA-SHA256 signature
97
119
auto pub_point = ack::ec_curve::secp256k1.make_point( pubkey_x, pubkey_y );
0 commit comments