forked from 0xPolygonZero/plonky2
-
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.
Merge pull request #5 from okx/dev-cliff-support-bn128
Dev cliff support bn128
- Loading branch information
Showing
40 changed files
with
1,506 additions
and
24 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "cryptography_cuda"] | ||
path = cryptography_cuda | ||
url = [email protected]:okx/cryptography_cuda.git | ||
[submodule "depends/cryptography_cuda"] | ||
path = depends/cryptography_cuda | ||
url = [email protected]:okx/cryptography_cuda.git |
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 |
---|---|---|
|
@@ -9,5 +9,4 @@ incremental = true | |
#codegen-units = 1 | ||
|
||
[profile.bench] | ||
opt-level = 3 | ||
|
||
opt-level = 3 |
Submodule cryptography_cuda
deleted from
4a900e
Submodule cryptography_cuda
added at
f22980
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,9 @@ | ||
rustc 1.78.0-nightly will throw below error | ||
``` | ||
error[E0635]: unknown feature `stdsimd` | ||
``` | ||
|
||
``` | ||
rustup toolchian install nightly-2024-02-04 | ||
rustup override set nightly-2024-02-04 | ||
``` |
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
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
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(incomplete_features)] | ||
|
||
#![feature(generic_const_exprs)] | ||
|
||
use std::fs::File; | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Set up Jemalloc | ||
#[cfg(not(target_env = "msvc"))] | ||
#[cfg(not(target_os = "macos"))] | ||
use jemallocator::Jemalloc; | ||
|
||
#[cfg(not(target_env = "msvc"))] | ||
#[cfg(not(target_os = "macos"))] | ||
#[global_allocator] | ||
static GLOBAL: Jemalloc = Jemalloc; |
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,84 @@ | ||
extern crate bindgen; | ||
|
||
use std::env; | ||
use std::path::{Path, PathBuf}; | ||
|
||
fn main() { | ||
let dir = env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
|
||
let poseidon_dir = Path::new(&dir).join("poseidon_bn128"); | ||
|
||
if cfg!(target_os = "macos") { | ||
println!("target os is macos"); | ||
let output = std::process::Command::new("go") | ||
.arg("version") | ||
.output() | ||
.expect("Failed to run command"); | ||
|
||
// Check the exit status | ||
if output.status.success() { | ||
// Go is installed | ||
println!( | ||
"Go is installed: {:?}", | ||
String::from_utf8_lossy(&output.stdout) | ||
); | ||
} else { | ||
// Go is not installed | ||
panic!("Go is not installed"); | ||
} | ||
let poseidon_c_dir = Path::new(&dir).join("go-iden3-crypto"); | ||
println!("poseidon_c_dir: {:?}", poseidon_c_dir); | ||
if poseidon_c_dir.exists() { | ||
std::process::Command::new("sh") | ||
.arg("-c") | ||
.arg("rm") | ||
.arg("-rf") | ||
.arg(poseidon_c_dir.clone()) | ||
.output() | ||
.expect("rm go-iden3-crypto failure"); | ||
} | ||
println!("start clone go iden3"); | ||
std::process::Command::new("git") | ||
.arg("clone") | ||
.arg("https://github.com/polymerdao/go-iden3-crypto.git") | ||
.arg(poseidon_c_dir.clone()) | ||
.output() | ||
.expect("clone go iden3 crypto failure"); | ||
println!("end clone go iden3"); | ||
|
||
let ret = std::process::Command::new("sh") | ||
.arg("-c") | ||
.arg("./compile.sh") | ||
.current_dir(poseidon_c_dir.clone().join("poseidon-permute-c")) | ||
.output() | ||
.expect("compile poseidon permute c failure"); | ||
println!("compile lib ret: {:?}", ret); | ||
|
||
std::process::Command::new("mv") | ||
.arg("libposeidon-permute-c.a") | ||
.arg(poseidon_dir.join("libposeidon-permute-c-mac.a")) | ||
.current_dir(poseidon_c_dir.clone().join("poseidon-permute-c")) | ||
.output() | ||
.expect("mv failure"); | ||
} | ||
println!("cargo:rustc-link-search=native={}", poseidon_dir.display()); | ||
|
||
if cfg!(target_os = "macos") { | ||
println!("link to mac lib"); | ||
println!("cargo:rustc-link-lib=static=poseidon-permute-c-mac"); | ||
} else { | ||
println!("link to linux lib"); | ||
println!("cargo:rustc-link-lib=static=poseidon-permute-c"); | ||
} | ||
|
||
let bindings = bindgen::Builder::default() | ||
.header(poseidon_dir.join("wrapper.h").display().to_string()) | ||
.generate() | ||
.expect("Unable to generate bindings"); | ||
|
||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
println!("{}", out_path.to_str().unwrap()); | ||
bindings | ||
.write_to_file(out_path.join("bindings.rs")) | ||
.expect("Couldn't write bindings!"); | ||
} |
Binary file not shown.
Oops, something went wrong.