-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
fn main() { | ||
cxx_build::bridge("src/lib.rs") | ||
.files([ | ||
"src/msm.cc", | ||
#[cfg(feature = "tachyon_msm_gpu")] | ||
"src/msm_gpu.cc", | ||
]) | ||
.flag_if_supported("-std=c++17") | ||
.compile("halo2_proofs"); | ||
|
||
let dep_files = vec![ | ||
"src/lib.rs", | ||
"src/msm.cc", | ||
#[cfg(feature = "tachyon_msm_gpu")] | ||
"src/msm_gpu.cc", | ||
"include/msm.h", | ||
]; | ||
for file in dep_files { | ||
println!("cargo:rerun-if-changed={file}"); | ||
} | ||
|
||
println!("cargo:rustc-link-lib=dylib=tachyon"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef HALO2_PROOFS_INCLUDE_MSM_H_ | ||
#define HALO2_PROOFS_INCLUDE_MSM_H_ | ||
|
||
#include "rust/cxx.h" | ||
|
||
namespace tachyon { | ||
namespace halo2 { | ||
|
||
struct CppG1Affine; | ||
struct CppG1Jacobian; | ||
struct CppFr; | ||
|
||
rust::Box<CppG1Jacobian> msm(rust::Slice<const CppG1Affine> bases, | ||
rust::Slice<const CppFr> scalars); | ||
|
||
void init_msm_gpu(uint8_t degree); | ||
|
||
void release_msm_gpu(); | ||
|
||
rust::Box<CppG1Jacobian> msm_gpu(rust::Slice<const CppG1Affine> bases, | ||
rust::Slice<const CppFr> scalars); | ||
|
||
} // namespace halo2 | ||
} // namespace tachyon | ||
|
||
#endif // HALO2_PROOFS_INCLUDE_MSM_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "halo2_proofs/include/msm.h" | ||
|
||
#include <tachyon/c/math/msm/msm.h> | ||
|
||
#include "halo2_proofs/src/lib.rs.h" | ||
|
||
namespace tachyon { | ||
namespace halo2 { | ||
|
||
rust::Box<CppG1Jacobian> msm(rust::Slice<const CppG1Affine> bases, | ||
rust::Slice<const CppFr> scalars) { | ||
auto ret = tachyon_msm_g1_point2( | ||
reinterpret_cast<const tachyon_bn254_point2*>(bases.data()), | ||
bases.length(), reinterpret_cast<const tachyon_bn254_fr*>(scalars.data()), | ||
scalars.length()); | ||
return rust::Box<CppG1Jacobian>::from_raw(reinterpret_cast<CppG1Jacobian*>(ret)); | ||
} | ||
|
||
} // namespace halo2 | ||
} // namespace tachyon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// clang-format off | ||
#include <tachyon/c/math/msm/msm_gpu.h> | ||
// clang-format on | ||
|
||
#include "halo2_proofs/src/lib.rs.h" | ||
#include "halo2_proofs/include/msm.h" | ||
|
||
namespace tachyon { | ||
|
||
namespace halo2 { | ||
|
||
void init_msm_gpu(uint8_t degree) { tachyon_init_msm_gpu(degree); } | ||
|
||
void release_msm_gpu() { tachyon_release_msm_gpu(); } | ||
|
||
rust::Box<CppG1Jacobian> msm_gpu(rust::Slice<const CppG1Affine> bases, | ||
rust::Slice<const CppFr> scalars) { | ||
auto ret = tachyon_msm_g1_point2_gpu( | ||
reinterpret_cast<const tachyon_bn254_point2*>(bases.data()), | ||
bases.length(), reinterpret_cast<const tachyon_bn254_fr*>(scalars.data()), | ||
scalars.length()); | ||
return rust::Box<CppG1Jacobian>::from_raw(reinterpret_cast<CppG1Jacobian*>(ret)); | ||
} | ||
|
||
} // namespace halo2 | ||
} // namespace tachyon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters