Skip to content

Commit

Permalink
c2/cuda/groth16_srs.cuh: expose points sets as slices.
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Jun 24, 2023
1 parent 29d82a8 commit 0fa65e2
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions c2/cuda/groth16_srs.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ struct verifying_key {
affine_fp2_t delta_g2;
};

template<typename T> class slice_t {
T* ptr;
size_t nelems;
public:
slice_t(void *p, size_t n) : ptr(reinterpret_cast<T*>(p)), nelems(n) {}
slice_t() : ptr(nullptr), nelems(0) {}
T* data() const { return ptr; }
size_t size() const { return nelems; }
T& operator[](size_t i) const { return ptr[i]; }
};

extern "C" {
int blst_p1_deserialize(affine_t*, const byte[96]);
int blst_p2_deserialize(affine_fp2_t*, const byte[192]);
Expand Down Expand Up @@ -141,17 +152,6 @@ private:
std::string path;
verifying_key vk;

template<typename T> class slice_t {
T* ptr;
size_t nelems;
public:
slice_t(void *p, size_t n) : ptr(reinterpret_cast<T*>(p)), nelems(n) {}
slice_t() : ptr(nullptr), nelems(0) {}
T* data() const { return ptr; }
size_t size() const { return nelems; }
T& operator[](size_t i) const { return ptr[i]; }
};

#if 0
#define H_IS_STD__VECTOR
std::vector<affine_t> h;
Expand Down Expand Up @@ -338,6 +338,31 @@ public:
return ptr->srs.b_g2.data();
}

const slice_t<affine_t>& get_h_slice() const {
std::lock_guard<std::mutex> guard(ptr->srs.mtx);
return ptr->srs.h;
}

const slice_t<affine_t>& get_l_slice() const {
std::lock_guard<std::mutex> guard(ptr->srs.mtx);
return ptr->srs.l;
}

const slice_t<affine_t>& get_a_slice() const {
std::lock_guard<std::mutex> guard(ptr->srs.mtx);
return ptr->srs.a;
}

const slice_t<affine_t>& get_b_g1_slice() const {
std::lock_guard<std::mutex> guard(ptr->srs.mtx);
return ptr->srs.b_g1;
}

const slice_t<affine_fp2_t>& get_b_g2_slice() const {
std::lock_guard<std::mutex> guard(ptr->srs.mtx);
return ptr->srs.b_g2;
}

const std::string& get_path() const {
return ptr->srs.path;
}
Expand Down

0 comments on commit 0fa65e2

Please sign in to comment.