You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/docs/icicle/programmers_guide/cpp.md
+49-4
Original file line number
Diff line number
Diff line change
@@ -183,15 +183,59 @@ struct DeviceProperties {
183
183
184
184
## Compute APIs
185
185
186
-
### Multi-Scalar Multiplication (MSM) Example
186
+
### Including Curves and Fields
187
+
188
+
To use a specific elliptic curve (e.g., BN254) or its associated fields, include the relevant header files. For example:
189
+
190
+
```cpp
191
+
#include "icicle/msm.h"
192
+
#include "icicle/curves/params/bn254.h"
193
+
```
194
+
195
+
The bn254 namespace includes key types like:
196
+
197
+
-**scalar_t**: Scalar field elements.
198
+
-**projective_t**: Points on the elliptic curve in projective coordinates.
199
+
-**affine_t**: Points on the elliptic curve in affine coordinates.
200
+
201
+
### Namespace Usage
202
+
203
+
There are two ways to access types and functionality for a specific field or curve:
204
+
205
+
1.**Bring the Namespace into Scope**
206
+
This approach simplifies the code but may cause conflicts if multiple curves are used:
207
+
208
+
```cpp
209
+
usingnamespacebn254;
210
+
211
+
scalar_t s; // Scalar field element
212
+
projective_t p; // Point in projective coordinates
213
+
affine_t a; // Point in affine coordinates
214
+
```
215
+
216
+
2.**Use Fully Qualified Names**
217
+
This is recommended if you are working with multiple curves or libraries to avoid namespace conflicts:
218
+
219
+
```cpp
220
+
bn254::scalar_t s; // Scalar field element
221
+
bn254::projective_t p; // Point in projective coordinates
222
+
bn254::affine_t a; // Point in affine coordinates
223
+
```
224
+
225
+
### Leveraging Template APIs
226
+
227
+
ICICLE’s APIs are designed to work seamlessly with templated types, enabling flexibility and type safety. For example:
228
+
229
+
#### Multi-Scalar Multiplication (MSM) Example
187
230
188
231
Icicle provides high-performance compute APIs such as the Multi-Scalar Multiplication (MSM) for cryptographic operations. Here's a simple example of how to use the MSM API.
189
232
190
233
```cpp
191
234
#include<iostream>
192
235
#include"icicle/runtime.h"
193
-
#include "icicle/api/bn254.h"
194
236
237
+
#include"icicle/curves/params/bn254.h"
238
+
#include"icicle/msm.h"
195
239
usingnamespacebn254;
196
240
197
241
intmain()
@@ -245,15 +289,16 @@ int main()
245
289
}
246
290
```
247
291
248
-
### Polynomial Operations Example
292
+
####Polynomial Operations Example
249
293
250
294
Here's another example demonstrating polynomial operations using Icicle:
0 commit comments