Small features (#415)

This PR is a compilation of small improvements

 - Lock bindgen version for `icicle-cuda-runtime`
- Add an error message when trying to build on Mac (or any non
windows/linux machine)
 - Add documentation and template files for adding new curve
 - Add documentation on _params.cuh contents
- Add the script to bump all the rust crates versions to the same
version

Resolves #313
This commit is contained in:
ChickenLover
2024-03-06 18:48:34 +07:00
committed by GitHub
parent 87ccd62976
commit 9fc083916d
28 changed files with 410 additions and 65 deletions

View File

@@ -33,7 +33,7 @@ jobs:
# before building the project.
# e.g. icicle-cuda-runtime/src/bindings.rs is generated and icicle-cuda-runtime/src/lib.rs includes that module
# causing rustfmt to fail.
run: if [[ $(find . -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]]; then echo "Please run cargo fmt"; exit 1; fi
run: if [[ $(find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]]; then echo "Please run cargo fmt"; exit 1; fi
build-linux:
name: Build on Linux

View File

@@ -6,7 +6,56 @@ We understand the need for ZK developers to use different curves, some common so
ICICLE core is very generic by design so all algorithms and primitives are designed to work based of configuration files [selected during compile](https://github.com/ingonyama-zk/icicle/blob/main/icicle/curves/curve_config.cuh) time. This is why we compile ICICLE Core per curve.
To add support a new curve you must create a new file under [`icicle/curves`](https://github.com/ingonyama-zk/icicle/tree/main/icicle/curves). The file should be named `<curve_name>_params.cuh`.
To add support for a new curve you must create a new file under [`icicle/curves`](https://github.com/ingonyama-zk/icicle/tree/main/icicle/curves). The file should be named `<curve_name>_params.cuh`.
### Adding curve_name_params.cuh
Start by copying `bn254_params.cuh` contents in your params file. Params should include:
- **fq_config** - parameters of the Base field.
- **limbs_count** - `ceil(field_byte_size / 4)`.
- **modulus_bit_count** - bit-size of the modulus.
- **num_of_reductions** - the number of times to reduce in reduce function. Use 2 if not sure.
- **modulus** - modulus of the field.
- **modulus_2** - modulus * 2.
- **modulus_4** - modulus * 4.
- **neg_modulus** - negated modulus.
- **modulus_wide** - modulus represented as a double-sized integer.
- **modulus_squared** - modulus**2 represented as a double-sized integer.
- **modulus_squared_2** - 2 * modulus**2 represented as a double-sized integer.
- **modulus_squared_4** - 4 * modulus**2 represented as a double-sized integer.
- **m** - value used in multiplication. Can be computed as `2**(2*modulus_bit_count) // modulus`.
- **one** - multiplicative identity.
- **zero** - additive identity.
- **montgomery_r** - `2 ** M % modulus` where M is a closest (larger than) bitsize multiple of 32. E.g. 384 or 768 for bls and bw curves respectively
- **montgomery_r_inv** - `2 ** (-M) % modulus`
- **fp_config** - parameters of the Scalar field.
Same as fq_config, but with additional arguments:
- **omegas_count** - [two-adicity](https://cryptologie.net/article/559/whats-two-adicity/) of the field. And thus the maximum size of NTT.
- **omegas** - an array of omegas for NTTs. An array of size `omegas_count`. The ith element is equal to `1.nth_root(2**(2**(omegas_count-i)))`.
- **inv** - an array of inverses of powers of two in a field. Ith element is equal to `(2 ** (i+1)) ** -1`.
- **G1 generators points** - affine coordinates of the generator point.
- **G2 generators points** - affine coordinates of the extension generator. Remove these if `G2` is not supported.
- **Weierstrass b value** - base field element equal to value of `b` in the curve equation.
- **Weierstrass b value G2** - base field element equal to value of `b` for the extension. Remove this if `G2` is not supported.
:::note
All the params are not in Montgomery form.
:::
:::note
To convert number values into `storage` type you can use the following python function
```python
import struct
def unpack(x, field_size):
return ', '.join(["0x" + format(x, '08x') for x in struct.unpack('I' * (field_size) // 4, int(x).to_bytes(field_size, 'little'))])
```
:::
We also require some changes to [`curve_config.cuh`](https://github.com/ingonyama-zk/icicle/blob/main/icicle/curves/curve_config.cuh#L16-L29), we need to add a new curve id.
@@ -28,58 +77,40 @@ Make sure to modify the [rest of the file](https://github.com/ingonyama-zk/icicl
Finally we must modify the [`make` file](https://github.com/ingonyama-zk/icicle/blob/main/icicle/CMakeLists.txt#L64) to make sure we can compile our new curve.
```
set(SUPPORTED_CURVES bn254;bls12_381;bls12_377;bw6_761;<curve_name>)
set(SUPPORTED_CURVES bn254;bls12_381;bls12_377;bw6_761;grumpkin;<curve_name>)
```
### Adding Poseidon support
If you want your curve to implement a Poseidon hash function or a tree builder, you will need to pre-calculate its optimized parameters.
Copy [constants_template.h](https://github.com/ingonyama-zk/icicle/blob/main/icicle/appUtils/poseidon/constants/constants_template.h) into `icicle/appUtils/poseidon/constants/<CURVE>_poseidon.h`. Run the [constants generation script](https://dev.ingonyama.com/icicle/primitives/poseidon#constants). The script will print the number of partial rounds and generate a `constants.bin` file. Use `xxd -i constants.bin` to parse the file into C declarations. Copy the `unsigned char constants_bin[]` contents inside your new file. Repeat this process for arities 2, 4, 8 and 11.
After you've generated the constants, add your curve in this [SUPPORTED_CURVES_WITH_POSEIDON](https://github.com/ingonyama-zk/icicle/blob/main/icicle/CMakeLists.txt#L72) in the `CMakeLists.txt`.
## Bindings
In order to support a new curves in the binding libraries you first must support it in ICICLE core.
In order to support a new curve in the binding libraries you first must support it in ICICLE core.
### Rust
Create a new folder named `icicle-<curve_name>` under the [rust wrappers folder](https://github.com/ingonyama-zk/icicle/tree/main/wrappers/rust/icicle-curves). Your new directory should look like this.
Go to [rust curves folder](https://github.com/ingonyama-zk/icicle/tree/main/wrappers/rust/icicle-curves) and copy `icicle-curve-template` to a new folder named `icicle-<curve_name>`.
```
└── rust
├── icicle-curves
├── icicle-<curve_name>
│   │   ├── Cargo.toml
│   │   ├── build.rs
│   │   └── src/
│   │   ├── curve.rs
│   │   ├── lib.rs
│   │   ├── msm/
│   │   │   └── mod.rs
│   │   └── ntt/
│   │   └── mod.rs
```
Find all the occurrences of `<CURVE>` placeholder inside the crate. (You can use `Ctrl+Shift+F` in VS Code or `grep -nr "<CURVE>"` in bash). You will then need to replace each occurrence with your new curve name.
Lets look at [`ntt/mod.rs`](https://github.com/ingonyama-zk/icicle/blob/main/wrappers/rust/icicle-curves/icicle-bn254/src/ntt/mod.rs) for example.
#### Limbs
```
...
Go to your curve's `curve.rs` file and set `SCALAR_LIMBS`, `BASE_LIMBS` and `G2_BASE_LIMBS` (if G2 is needed) to a minimum number of `u64` required to store a single scalar field / base field element respectively.
e.g. for bn254, scalar field is 254 bit so `SCALAR_LIMBS` is set to 4.
extern "C" {
#[link_name = "bn254NTTCuda"]
fn ntt_cuda<'a>(
input: *const ScalarField,
size: usize,
is_inverse: bool,
config: &NTTConfig<'a, ScalarField>,
output: *mut ScalarField,
) -> CudaError;
#### Primitives
#[link_name = "bn254DefaultNTTConfig"]
fn default_ntt_config() -> NTTConfig<'static, ScalarField>;
If your curve doesn't support some of the primitives (ntt/msm/poseidon/merkle tree/), or you simply don't want to include it, just remove a corresponding module from `src` and then from `lib.rs`
#[link_name = "bn254InitializeDomain"]
fn initialize_ntt_domain(primitive_root: ScalarField, ctx: &DeviceContext) -> CudaError;
}
#### G2
...
```
If your curve doesn't support G2 - remove all the code under `#[cfg(feature = "g2")]` and remove the feature from [Cargo.toml](https://github.com/ingonyama-zk/icicle/blob/main/wrappers/rust/icicle-curves/icicle-bn254/Cargo.toml#L29) and [build.rs](https://github.com/ingonyama-zk/icicle/blob/main/wrappers/rust/icicle-curves/icicle-bn254/build.rs#L15).
Here you would need to replace `bn254NTTCuda` with `<curve_name>NTTCuda`. Most of these changes are pretty straight forward. One thing you should pay attention to is limb sizes as these change for different curves. For example `BN254` [has limb size of 8](https://github.com/ingonyama-zk/icicle/blob/4beda3a900eda961f39af3a496f8184c52bf3b41/wrappers/rust/icicle-curves/icicle-bn254/src/curve.rs#L15) but for your curve this may be different.
After this is done, add your new crate in the [global Cargo.toml](https://github.com/ingonyama-zk/icicle/tree/main/wrappers/rust/Cargo.toml).
### Golang

View File

@@ -0,0 +1,39 @@
#pragma once
#ifndef CURVE_POSEIDON_H
#define CURVE_POSEIDON_H
namespace poseidon_constants_curve {
/**
* This inner namespace contains optimized constants for running Poseidon.
* These constants were generated using an algorithm defined at
* https://spec.filecoin.io/algorithms/crypto/poseidon/
* The number in the name corresponds to the arity of hash function
* Each array contains:
* RoundConstants | MDSMatrix | Non-sparse matrix | Sparse matrices
*/
int partial_rounds_2 = 0;
int partial_rounds_4 = 0;
int partial_rounds_8 = 0;
int partial_rounds_11 = 0;
unsigned char poseidon_constants_2[] = {
0x00
};
unsigned char poseidon_constants_4[] = {
0x00
};
unsigned char poseidon_constants_8[] = {
0x00
};
unsigned char poseidon_constants_11[] = {
0x00
};
} // namespace poseidon_constants
#endif

15
scripts/bump_rust_versions.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
new_version=$1
if [ -z "$new_version" ]; then
echo "Usage: ./bump_rust_versions.sh <new_version>"
exit 1
fi
cd wrappers/rust
# Update the version in each member crate's Cargo.toml
for crate in $(cat Cargo.toml | grep '"[a-z].*"' | tr -d '[" ],'); do
sed -i "/^\[package\]/,/^$/ s/^version = \".*\"/version = \"$new_version\"/" $crate/Cargo.toml
done

View File

@@ -36,11 +36,11 @@ fi
# Run cargo fmt on Rust files
cd wrappers/rust
if [[ $(find . -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]];
if [[ $(find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]];
then
echo "🚨 There are Rust files that need formatting."
echo "Please format the Rust files using the following command:"
echo "find . -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --"
echo "Please go to wrappers/rust and format the Rust files using the following command:"
echo "find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --"
status=1
fi

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-core"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = ["Ingonyama"]
description = "A library for GPU ZK acceleration by Ingonyama"

View File

@@ -293,17 +293,24 @@ macro_rules! impl_poseidon {
#[macro_export]
macro_rules! impl_poseidon_tests {
(
$field:ident
) => {
#[test]
fn test_poseidon_hash_many() {
check_poseidon_hash_many::<$field>()
}
};
}
#[macro_export]
macro_rules! impl_poseidon_custom_config_test {
(
$field:ident,
$field_bytes:literal,
$field_prefix:literal,
$partial_rounds:literal
) => {
#[test]
fn test_poseidon_hash_many() {
check_poseidon_hash_many::<$field>()
}
#[test]
fn test_poseidon_custom_config() {
check_poseidon_custom_config::<$field>($field_bytes, $field_prefix, $partial_rounds)

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-cuda-runtime"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Ingonyama's Rust wrapper of CUDA runtime"
@@ -12,4 +12,4 @@ rust-version = "1.70.0"
bitflags = "1.3"
[build-dependencies]
bindgen = "*"
bindgen = "0.69.4"

View File

@@ -27,6 +27,11 @@ fn cuda_lib_path() -> &'static str {
}
fn main() {
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
{
panic!("Currently, ICICLE can only be built for Windows or Linux")
}
let cuda_runtime_api_path = PathBuf::from(cuda_include_path())
.join("cuda_runtime_api.h")
.to_string_lossy()

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-bls12-377"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Rust wrapper for the CUDA implementation of BLS12-377 pairing friendly elliptic curve by Ingonyama"

View File

@@ -20,8 +20,9 @@ impl_poseidon!("bw6_761", bw6_761, BaseField, BaseCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_poseidon_tests;
use icicle_core::poseidon::tests::*;
use icicle_core::{impl_poseidon_custom_config_test, impl_poseidon_tests};
impl_poseidon_tests!(ScalarField, 32, "bls12_377", 56);
impl_poseidon_tests!(ScalarField);
impl_poseidon_custom_config_test!(ScalarField, 32, "bls12_377", 56);
}

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-bls12-381"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Rust wrapper for the CUDA implementation of BLS12-381 pairing friendly elliptic curve by Ingonyama"

View File

@@ -15,8 +15,9 @@ impl_poseidon!("bls12_381", bls12_381, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_poseidon_tests;
use icicle_core::poseidon::tests::*;
use icicle_core::{impl_poseidon_custom_config_test, impl_poseidon_tests};
impl_poseidon_tests!(ScalarField, 32, "bls12_381", 55);
impl_poseidon_tests!(ScalarField);
impl_poseidon_custom_config_test!(ScalarField, 32, "bls12_381", 55);
}

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-bn254"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Rust wrapper for the CUDA implementation of BN254 pairing friendly elliptic curve by Ingonyama"

View File

@@ -15,8 +15,9 @@ impl_poseidon!("bn254", bn254, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_poseidon_tests;
use icicle_core::poseidon::tests::*;
use icicle_core::{impl_poseidon_custom_config_test, impl_poseidon_tests};
impl_poseidon_tests!(ScalarField, 32, "bn254", 56);
impl_poseidon_tests!(ScalarField);
impl_poseidon_custom_config_test!(ScalarField, 32, "bn254", 56);
}

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-bw6-761"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Rust wrapper for the CUDA implementation of BW6-761 pairing friendly elliptic curve by Ingonyama"

View File

@@ -1,8 +1,9 @@
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_poseidon_tests;
use icicle_core::poseidon::tests::*;
use icicle_core::{impl_poseidon_custom_config_test, impl_poseidon_tests};
impl_poseidon_tests!(ScalarField, 48, "bw6-761", 56);
impl_poseidon_tests!(ScalarField);
impl_poseidon_custom_config_test!(ScalarField, 48, "bw6-761", 56);
}

View File

@@ -0,0 +1,30 @@
[package]
name = "icicle-<CURVE>"
version = "1.4.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Rust wrapper for the CUDA implementation of <CURVE> elliptic curve by Ingonyama"
homepage = "https://www.ingonyama.com"
repository = "https://github.com/ingonyama-zk/icicle"
[dependencies]
icicle-core = { path = "../../icicle-core" }
icicle-cuda-runtime = { path = "../../icicle-cuda-runtime" }
ark-<CURVE> = { version = "0.4.0", optional = true }
[build-dependencies]
cmake = "0.1.50"
[dev-dependencies]
ark-<CURVE> = "0.4.0"
ark-std = "0.4.0"
ark-ff = "0.4.0"
ark-ec = "0.4.0"
ark-poly = "0.4.0"
icicle-core = { path = "../../icicle-core", features = ["arkworks"] }
icicle-<CURVE> = { path = ".", features = ["arkworks"] }
[features]
default = []
g2 = ["icicle-core/g2"]
arkworks = ["ark-<CURVE>", "icicle-core/arkworks"]

View File

@@ -0,0 +1,28 @@
use cmake::Config;
fn main() {
println!("cargo:rerun-if-env-changed=CXXFLAGS");
println!("cargo:rerun-if-changed=../../../../icicle");
// Base config
let mut config = Config::new("../../../../icicle");
config
.define("BUILD_TESTS", "OFF")
.define("CURVE", "<CURVE>")
.define("CMAKE_BUILD_TYPE", "Release");
// Optional Features
#[cfg(feature = "g2")]
config.define("G2_DEFINED", "ON");
// Build
let out_dir = config
.build_target("icicle")
.build();
println!("cargo:rustc-link-search={}/build", out_dir.display());
println!("cargo:rustc-link-lib=ingo_<CURVE>");
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-lib=cudart");
}

View File

@@ -0,0 +1,61 @@
#[cfg(feature = "arkworks")]
use ark_<CURVE>::{g1::Config as ArkG1Config, Fq, Fr};
#[cfg(all(feature = "arkworks", feature = "g2"))]
use ark_<CURVE>::{g2::Config as ArkG2Config, Fq2};
use icicle_core::curve::{Affine, Curve, Projective};
use icicle_core::field::{Field, MontgomeryConvertibleField};
use icicle_core::traits::{FieldConfig, FieldImpl, GenerateRandom};
use icicle_core::{impl_curve, impl_field, impl_scalar_field};
use icicle_cuda_runtime::device_context::DeviceContext;
use icicle_cuda_runtime::error::CudaError;
use icicle_cuda_runtime::memory::HostOrDeviceSlice;
pub(crate) const SCALAR_LIMBS: usize = ;
pub(crate) const BASE_LIMBS: usize = ;
#[cfg(feature = "g2")]
pub(crate) const G2_BASE_LIMBS: usize = ;
impl_scalar_field!("<CURVE>", <CURVE>_sf, SCALAR_LIMBS, ScalarField, ScalarCfg, Fr);
impl_field!(BASE_LIMBS, BaseField, BaseCfg, Fq);
#[cfg(feature = "g2")]
impl_field!(G2_BASE_LIMBS, G2BaseField, G2BaseCfg, Fq2);
impl_curve!(
"<CURVE>",
<CURVE>,
CurveCfg,
ScalarField,
BaseField,
ArkG1Config,
G1Affine,
G1Projective
);
#[cfg(feature = "g2")]
impl_curve!(
"<CURVE>G2",
<CURVE>_g2,
G2CurveCfg,
ScalarField,
G2BaseField,
ArkG2Config,
G2Affine,
G2Projective
);
#[cfg(test)]
mod tests {
use super::{CurveCfg, ScalarField, BASE_LIMBS};
#[cfg(feature = "g2")]
use super::{G2CurveCfg, G2_BASE_LIMBS};
use icicle_core::curve::Curve;
use icicle_core::tests::*;
use icicle_core::traits::FieldImpl;
use icicle_core::{impl_curve_tests, impl_field_tests};
impl_field_tests!(ScalarField);
impl_curve_tests!(BASE_LIMBS, CurveCfg);
#[cfg(feature = "g2")]
mod g2 {
use super::*;
impl_curve_tests!(G2_BASE_LIMBS, G2CurveCfg);
}
}

View File

@@ -0,0 +1,8 @@
pub mod curve;
pub mod msm;
pub mod ntt;
pub mod poseidon;
pub mod tree;
pub mod vec_ops;
impl icicle_core::SNARKCurve for curve::CurveCfg {}

View File

@@ -0,0 +1,31 @@
use crate::curve::CurveCfg;
#[cfg(feature = "g2")]
use crate::curve::G2CurveCfg;
use icicle_core::{
curve::{Affine, Curve, Projective},
error::IcicleResult,
impl_msm,
msm::{MSMConfig, MSM},
traits::IcicleResultWrap,
};
use icicle_cuda_runtime::{error::CudaError, memory::HostOrDeviceSlice};
impl_msm!("<CURVE>", <CURVE>, CurveCfg);
#[cfg(feature = "g2")]
impl_msm!("<CURVE>G2", <CURVE>_g2, G2CurveCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::CurveCfg;
#[cfg(feature = "g2")]
use crate::curve::G2CurveCfg;
use icicle_core::impl_msm_tests;
use icicle_core::msm::tests::*;
impl_msm_tests!(CurveCfg);
#[cfg(feature = "g2")]
mod g2 {
use super::*;
impl_msm_tests!(G2CurveCfg);
}
}

View File

@@ -0,0 +1,22 @@
use crate::curve::{ScalarCfg, ScalarField};
use icicle_core::error::IcicleResult;
use icicle_core::impl_ntt;
use icicle_core::ntt::{NTTConfig, NTTDir, NTT};
use icicle_core::traits::IcicleResultWrap;
use icicle_cuda_runtime::device_context::{DeviceContext, DEFAULT_DEVICE_ID};
use icicle_cuda_runtime::error::CudaError;
use icicle_cuda_runtime::memory::HostOrDeviceSlice;
impl_ntt!("<CURVE>", <CURVE>, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use crate::ntt::DEFAULT_DEVICE_ID;
use icicle_core::impl_ntt_tests;
use icicle_core::ntt::tests::*;
use std::sync::OnceLock;
impl_ntt_tests!(ScalarField);
}

View File

@@ -0,0 +1,22 @@
use crate::curve::{ScalarCfg, ScalarField};
use icicle_core::error::IcicleResult;
use icicle_core::impl_poseidon;
use icicle_core::poseidon::{Poseidon, PoseidonConfig, PoseidonConstants};
use icicle_core::traits::IcicleResultWrap;
use icicle_cuda_runtime::device_context::DeviceContext;
use icicle_cuda_runtime::error::CudaError;
use icicle_cuda_runtime::memory::HostOrDeviceSlice;
use core::mem::MaybeUninit;
impl_poseidon!("<CURVE>", <CURVE>, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_poseidon_tests;
use icicle_core::poseidon::tests::*;
impl_poseidon_tests!(ScalarField);
}

View File

@@ -0,0 +1,21 @@
use crate::curve::{ScalarCfg, ScalarField};
use icicle_core::error::IcicleResult;
use icicle_core::impl_tree_builder;
use icicle_core::poseidon::PoseidonConstants;
use icicle_core::traits::IcicleResultWrap;
use icicle_core::tree::{TreeBuilder, TreeBuilderConfig};
use icicle_cuda_runtime::device_context::DeviceContext;
use icicle_cuda_runtime::error::CudaError;
use icicle_cuda_runtime::memory::HostOrDeviceSlice;
impl_tree_builder!("<CURVE>", <CURVE>, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_tree_builder_tests;
use icicle_core::tree::tests::*;
impl_tree_builder_tests!(ScalarField);
}

View File

@@ -0,0 +1,20 @@
use crate::curve::{ScalarCfg, ScalarField};
use icicle_core::error::IcicleResult;
use icicle_core::impl_vec_ops_field;
use icicle_core::traits::IcicleResultWrap;
use icicle_core::vec_ops::{VecOps, VecOpsConfig};
use icicle_cuda_runtime::device_context::DeviceContext;
use icicle_cuda_runtime::error::CudaError;
use icicle_cuda_runtime::memory::HostOrDeviceSlice;
impl_vec_ops_field!("<CURVE>", <CURVE>, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_vec_add_tests;
use icicle_core::vec_ops::tests::*;
impl_vec_add_tests!(ScalarField);
}

View File

@@ -1,6 +1,6 @@
[package]
name = "icicle-grumpkin"
version = "1.4.0"
version = "1.6.0"
edition = "2021"
authors = [ "Ingonyama" ]
description = "Rust wrapper for the CUDA implementation of Grumpkin elliptic curve by Ingonyama"

View File

@@ -15,8 +15,9 @@ impl_poseidon!("grumpkin", grumpkin, ScalarField, ScalarCfg);
#[cfg(test)]
pub(crate) mod tests {
use crate::curve::ScalarField;
use icicle_core::impl_poseidon_tests;
use icicle_core::poseidon::tests::*;
use icicle_core::{impl_poseidon_custom_config_test, impl_poseidon_tests};
impl_poseidon_tests!(ScalarField, 32, "grumpkin", 56);
impl_poseidon_tests!(ScalarField);
impl_poseidon_custom_config_test!(ScalarField, 32, "grumpkin", 56);
}