-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 828c4c6
Showing
29 changed files
with
2,548 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Rust CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: nvidia/cuda:12.4.0-devel-ubuntu22.04 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
apt-get update | ||
apt-get install -y curl wget | ||
- name: Install libclang | ||
run: apt-get install -y libclang-dev | ||
|
||
- name: Install protobuf-compiler | ||
run: apt-get install -y protobuf-compiler | ||
|
||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
|
||
- name: Set up Rust fmt version | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly-2024-02-04-x86_64-unknown-linux-gnu | ||
|
||
- name: Install rustfmt | ||
run: rustup component add --toolchain nightly-2024-02-04-x86_64-unknown-linux-gnu rustfmt | ||
|
||
- name: Install dependencies | ||
run: rustup target add x86_64-unknown-linux-gnu | ||
|
||
- name: Run tests | ||
run: bash ./dev_support/test.sh |
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,41 @@ | ||
# Generated by Cargo | ||
/target/ | ||
/proptest-regressions | ||
target | ||
|
||
# Data | ||
ppot2ark/data | ||
amt/pp | ||
params | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
# Ignore IDE specific files | ||
.idea/ | ||
.vscode/ | ||
*.swp | ||
*.swo | ||
|
||
# Ignore OS specific files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Ignore any compiled binaries | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Ignore any generated documentation | ||
/doc/ | ||
|
||
# Ignore any environment-specific files | ||
.env |
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,30 @@ | ||
[workspace] | ||
resolver = "2" | ||
|
||
members = [ | ||
"ppot2ark", | ||
"amt" | ||
] | ||
|
||
[workspace.dependencies] | ||
amt = { path = "amt" } | ||
|
||
ark-ec = "0.5" | ||
ark-ff = "0.5" | ||
ark-poly = "0.5" | ||
ark-serialize = "0.5" | ||
ark-bls12-381 = "0.5" | ||
ark-bn254 = "0.5" | ||
ark-std = "0.5" | ||
|
||
rayon = "1.10" | ||
|
||
rand = "0.8" | ||
|
||
parking_lot = "0.12" | ||
|
||
once_cell = "1.19" | ||
|
||
anyhow = "1" | ||
tracing = "0.1.40" | ||
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } |
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 @@ | ||
## Download the trusted setup for BLS12-381 (2^21 powers of tau) from [ZcashFoundation](https://github.com/ZcashFoundation/powersoftau-attestations/tree/master/0087 "Trusted Setup for BLS12-381") | ||
```bash | ||
bash ./dev_support/download_ppot_bls.rs | ||
``` | ||
## Build AMT params based on the powers of tau | ||
```bash | ||
bash ./dev_support/build_params_bls.rs $degree | ||
``` |
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,38 @@ | ||
[package] | ||
name = "amt" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ark-ec = { workspace = true } | ||
ark-ff = { workspace = true } | ||
ark-poly = { workspace = true } | ||
ark-serialize = { workspace = true } | ||
ark-bls12-381 = { workspace = true } | ||
ark-bn254 = { workspace = true } | ||
ark-std = { workspace = true } | ||
|
||
rayon = { workspace = true, optional = true } | ||
|
||
rand = { workspace = true } | ||
|
||
once_cell = { workspace = true } | ||
|
||
anyhow = { workspace = true } | ||
tracing = { workspace = true } | ||
tracing-subscriber = { workspace = true } | ||
|
||
base64 = "0.22" | ||
|
||
error-chain = { version = "0.12", default-features = false } | ||
|
||
[features] | ||
default = [] | ||
parallel = ["ark-poly/parallel", "ark-ec/parallel", "ark-std/parallel", "rayon"] | ||
bn254 = [] | ||
bls12-381 = [] | ||
|
||
[[bin]] | ||
name = "build_params" | ||
test = false | ||
bench = false |
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,43 @@ | ||
use amt::{AmtParams, CreateMode, PowerTau}; | ||
use anyhow::{bail, Result}; | ||
use tracing::Level; | ||
|
||
fn parse_param() -> Result<(usize, usize, Option<String>)> { | ||
let args: Vec<String> = std::env::args().collect(); | ||
|
||
if args.len() < 3 { | ||
bail!( | ||
"Usage: {} <amt-depth> <verify-depth> [<power_tau_dir>]", | ||
args[0] | ||
); | ||
} | ||
|
||
let path = if args.len() == 4 { | ||
Some(args[3].parse()?) | ||
} else { | ||
None | ||
}; | ||
|
||
Ok((args[1].parse()?, args[2].parse()?, path)) | ||
} | ||
|
||
fn main() { | ||
let (depth, verify_depth, ptau_dir) = match parse_param() { | ||
Ok(x) => x, | ||
Err(e) => { | ||
eprintln!("Cannot parse input: {:?}", e); | ||
std::process::exit(1); | ||
} | ||
}; | ||
|
||
tracing_subscriber::fmt() | ||
.with_max_level(Level::DEBUG) | ||
.with_target(false) | ||
.init(); | ||
|
||
let create_mode = ptau_dir.is_none(); | ||
let dir = ptau_dir.unwrap_or("./params/test".into()); | ||
let pp = PowerTau::from_dir(&dir, depth, create_mode); | ||
|
||
AmtParams::from_dir_mont(&dir, depth, verify_depth, CreateMode::AmtOnly, Some(&pp)); | ||
} |
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,29 @@ | ||
// Re-export all the required components | ||
// in Arkworks's repo (original Zexe). | ||
|
||
// Since Zexe's repo doesn't have a | ||
// stable implementation and could be | ||
// refactored in the future, | ||
// we import all the required objects in | ||
// one place and all its usage for this | ||
// repo should import from here. | ||
|
||
#[cfg(test)] | ||
pub use ark_ec::VariableBaseMSM; | ||
#[cfg(test)] | ||
pub use ark_ff::{Field, One}; | ||
|
||
pub use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup}; | ||
pub use ark_ff::{utils::k_adicity, BigInt, BigInteger, PrimeField, UniformRand, Zero}; | ||
pub use ark_poly::{EvaluationDomain, Radix2EvaluationDomain}; | ||
pub use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Read, Write}; | ||
|
||
pub type G1<PE> = <PE as ark_ec::pairing::Pairing>::G1; | ||
pub type G1Aff<PE> = <PE as ark_ec::pairing::Pairing>::G1Affine; | ||
pub type G2<PE> = <PE as ark_ec::pairing::Pairing>::G2; | ||
pub type G2Aff<PE> = <PE as ark_ec::pairing::Pairing>::G2Affine; | ||
pub type Fr<PE> = <PE as ark_ec::pairing::Pairing>::ScalarField; | ||
pub type Fq<PE> = <PE as ark_ec::pairing::Pairing>::BaseField; | ||
pub type FrInt<PE> = <Fr<PE> as PrimeField>::BigInt; | ||
pub type FqInt<PE> = <Fq<PE> as PrimeField>::BigInt; | ||
pub type Fq2<PE> = <G2Aff<PE> as AffineRepr>::BaseField; |
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,28 @@ | ||
use error_chain::error_chain; | ||
|
||
error_chain! { | ||
links { | ||
} | ||
|
||
foreign_links { | ||
File(std::io::Error); | ||
Serialize(ark_serialize::SerializationError); | ||
} | ||
|
||
errors { | ||
InconsistentLength { | ||
description("In consistent length between expected params and real params") | ||
display("In consistent length between expected params and real params") | ||
} | ||
|
||
InconsistentPowersOfTau { | ||
description("In consistent powers of tau") | ||
display("In consistent powers of tau") | ||
} | ||
|
||
RareZeroGenerationError { | ||
description("Failed to generate a non-zero scalar after multiple attempts") | ||
display("Failed to generate a non-zero scalar after multiple attempts") | ||
} | ||
} | ||
} |
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 @@ | ||
#[macro_use] | ||
extern crate tracing; | ||
|
||
pub mod ec_algebra; | ||
mod error; | ||
mod power_tau; | ||
mod proofs; | ||
mod prove_params; | ||
mod utils; | ||
|
||
pub use power_tau::PowerTau; | ||
pub use proofs::AmtProofError; | ||
pub use prove_params::{AmtParams, CreateMode}; | ||
pub use utils::ptau_file_name; | ||
|
||
#[cfg(not(feature = "bls12-381"))] | ||
pub use prove_params::fast_serde_bn254; | ||
|
||
#[cfg(feature = "bls12-381")] | ||
pub use prove_params::fast_serde_bls12_381; |
Oops, something went wrong.