Skip to content

Commit d4b3c54

Browse files
committed
fix(gpu): many minor fixes to the rust bindings
1 parent 7ff06f9 commit d4b3c54

17 files changed

Lines changed: 972 additions & 1428 deletions

File tree

‎Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ serde = { version = "1.0", default-features = false }
4040
wasm-bindgen = "0.2.101"
4141
getrandom = "0.2.8"
4242
# The project maintainers consider that this is the last version of the 1.3 branch, any newer version should not be trusted
43+
bindgen = "0.71"
4344
bincode = "=1.3.3"
45+
cmake = "0.1"
46+
pkg-config = "0.3"
4447

4548
[profile.bench]
4649
lto = "fat"

‎backends/tfhe-cuda-backend/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ readme = "README.md"
1212
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]
1313

1414
[build-dependencies]
15-
cmake = { version = "0.1" }
16-
pkg-config = { version = "0.3" }
17-
bindgen = "0.71"
15+
cmake.workspace = true
16+
pkg-config.workspace = true
17+
bindgen.workspace = true
1818

1919
[features]
2020
experimental-multi-arch = []

‎backends/zk-cuda-backend/Cargo.toml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "zk-cuda-backend"
33
version = "0.1.0"
44
edition = "2021"
5+
rust-version.workspace = true
56
authors = ["Zama team"]
67
license = "BSD-3-Clause-Clear"
78
description = "Cuda implementation of TFHE-rs' ZK primitives."
@@ -16,9 +17,9 @@ name = "zk_cuda_backend"
1617
crate-type = ["rlib"]
1718

1819
[build-dependencies]
19-
cmake = { version = "0.1" }
20-
pkg-config = { version = "0.3" }
21-
bindgen = "0.71"
20+
cmake.workspace = true
21+
pkg-config.workspace = true
22+
bindgen.workspace = true
2223

2324
[dependencies]
2425
ark-ec.workspace = true

‎backends/zk-cuda-backend/build.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ fn main() {
113113
.allowlist_type("Scalar")
114114
.allowlist_type("BigInt")
115115
.allowlist_type("cudaStream_t")
116-
// Derive Default for all types (needed by Rust code)
116+
// Derive Default, PartialEq and Eq for all types so wrapper
117+
// types can use derive macros instead of manual impls
117118
.derive_default(true)
119+
.derive_partialeq(true)
120+
.derive_eq(true)
118121
.clang_arg("-x")
119122
.clang_arg("c++")
120123
.clang_arg("-std=c++17")

‎backends/zk-cuda-backend/src/README.md‎

Lines changed: 0 additions & 271 deletions
This file was deleted.

‎backends/zk-cuda-backend/src/bindings.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct CUstream_st {
77
}
88
pub type cudaStream_t = *mut CUstream_st;
99
#[repr(C)]
10-
#[derive(Debug, Default, Copy, Clone)]
10+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
1111
pub struct Fp {
1212
pub limb: [u64; 7usize],
1313
}
@@ -18,7 +18,7 @@ const _: () = {
1818
["Offset of field: Fp::limb"][::std::mem::offset_of!(Fp, limb) - 0usize];
1919
};
2020
#[repr(C)]
21-
#[derive(Debug, Default, Copy, Clone)]
21+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
2222
pub struct Fp2 {
2323
pub c0: Fp,
2424
pub c1: Fp,
@@ -31,7 +31,7 @@ const _: () = {
3131
["Offset of field: Fp2::c1"][::std::mem::offset_of!(Fp2, c1) - 56usize];
3232
};
3333
#[repr(C)]
34-
#[derive(Debug, Default, Copy, Clone)]
34+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
3535
pub struct BigInt {
3636
pub limb: [u64; 5usize],
3737
}
@@ -43,7 +43,7 @@ const _: () = {
4343
};
4444
pub type Scalar = BigInt;
4545
#[repr(C)]
46-
#[derive(Debug, Default, Copy, Clone)]
46+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
4747
pub struct G1Point {
4848
pub x: Fp,
4949
pub y: Fp,
@@ -58,7 +58,7 @@ const _: () = {
5858
["Offset of field: G1Point::infinity"][::std::mem::offset_of!(G1Point, infinity) - 112usize];
5959
};
6060
#[repr(C)]
61-
#[derive(Debug, Default, Copy, Clone)]
61+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
6262
pub struct G2Point {
6363
pub x: Fp2,
6464
pub y: Fp2,
@@ -73,7 +73,7 @@ const _: () = {
7373
["Offset of field: G2Point::infinity"][::std::mem::offset_of!(G2Point, infinity) - 224usize];
7474
};
7575
#[repr(C)]
76-
#[derive(Debug, Default, Copy, Clone)]
76+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
7777
pub struct G1ProjectivePoint {
7878
pub X: Fp,
7979
pub Y: Fp,
@@ -91,7 +91,7 @@ const _: () = {
9191
[::std::mem::offset_of!(G1ProjectivePoint, Z) - 112usize];
9292
};
9393
#[repr(C)]
94-
#[derive(Debug, Default, Copy, Clone)]
94+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
9595
pub struct G2ProjectivePoint {
9696
pub X: Fp2,
9797
pub Y: Fp2,

0 commit comments

Comments
 (0)