-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
20 changed files
with
814 additions
and
501 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
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,11 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"constantine-rust/ctt-curve-bls12-381", | ||
"constantine-rust/ctt-curve-bn254-snarks", | ||
"constantine-rust/ctt-curve-pasta", | ||
"constantine-rust/ctt-proto-ethereum-bls-signatures", | ||
] | ||
|
||
[profile.dev] | ||
lto = "thin" # The Nim static library is compiled with LTO, always enable it |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "ctt-curve-bls12-381" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
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,35 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use std::process::{Command, Stdio}; | ||
|
||
const LIB_NAME: &str = "constantine_bls12_381"; | ||
|
||
fn main() { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); | ||
let root_dir = cargo_dir | ||
.parent() | ||
.expect("rust library is nested") | ||
.parent() | ||
.expect("constantine-rust is nested"); | ||
|
||
let rust_lib_name = cargo_dir | ||
.file_name() | ||
.expect("Directory exist"); | ||
|
||
println!("Building Constantine library ..."); | ||
|
||
Command::new("nimble") | ||
.arg("make_lib_rust") | ||
.env("CTT_RUST_LIB", rust_lib_name) | ||
.current_dir(root_dir) | ||
.stdout(Stdio::inherit()) | ||
.stderr(Stdio::inherit()) | ||
.status() | ||
.expect("failed to execute process"); | ||
|
||
println!("cargo:rustc-link-search=native={}", out_dir.display()); | ||
println!("cargo:rustc-link-lib=static={}", LIB_NAME); | ||
// Avoid full recompilation | ||
// println!("cargo:rerun-if-changed={}", root_dir.join("constantine").display()); | ||
} |
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,14 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
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,8 @@ | ||
[package] | ||
name = "ctt-curve-bn254-snarks" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
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,35 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use std::process::{Command, Stdio}; | ||
|
||
const LIB_NAME: &str = "constantine_bn254_snarks"; | ||
|
||
fn main() { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); | ||
let root_dir = cargo_dir | ||
.parent() | ||
.expect("rust library is nested") | ||
.parent() | ||
.expect("constantine-rust is nested"); | ||
|
||
let rust_lib_name = cargo_dir | ||
.file_name() | ||
.expect("Directory exist"); | ||
|
||
println!("Building Constantine library ..."); | ||
|
||
Command::new("nimble") | ||
.arg("make_lib_rust") | ||
.env("CTT_RUST_LIB", rust_lib_name) | ||
.current_dir(root_dir) | ||
.stdout(Stdio::inherit()) | ||
.stderr(Stdio::inherit()) | ||
.status() | ||
.expect("failed to execute process"); | ||
|
||
println!("cargo:rustc-link-search=native={}", out_dir.display()); | ||
println!("cargo:rustc-link-lib=static={}", LIB_NAME); | ||
// Avoid full recompilation | ||
// println!("cargo:rerun-if-changed={}", root_dir.join("constantine").display()); | ||
} |
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,14 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
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 @@ | ||
[package] | ||
name = "ctt-curve-pasta" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
Oops, something went wrong.