Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZCash BLS12-381 Powers of Tau #9

Merged
merged 13 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
legacy/** filter=lfs diff=lfs merge=lfs -text
*.lfs filter=lfs diff=lfs merge=lfs -text
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI
on:
push:
schedule:
- cron: '0 0 * * */2'
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
jobs:
lint:
name: Lint (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
channel:
- stable
- nightly
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- run: rustup update ${{ matrix.channel }} && rustup default ${{ matrix.channel }} && rustup component add clippy
- run: cargo install cargo-hack
- run: cargo hack clippy --feature-powerset --bins --examples --tests --workspace
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update nightly && rustup default nightly && rustup component add rustfmt
- run: cargo fmt --all -- --check
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update nightly && rustup default nightly
- run: RUSTDOCFLAGS="-D warnings --cfg doc_cfg" cargo doc --workspace --all-features --no-deps
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "manta-sdk"
edition = "2021"
version = "0.4.0"
version = "0.5.0"
authors = ["Manta Network <contact@manta.network>"]
readme = "README.md"
license-file = "LICENSE"
Expand All @@ -26,27 +26,26 @@ is-it-maintained-open-issues = { repository = "Manta-Network/sdk" }
maintenance = { status = "actively-developed" }

[features]
# Enable Allocation
alloc = []

# Enable Standard Library
std = ["alloc"]
std = []

# Download Data from GitHub
download = ["anyhow/std", "attohttpc", "std"]

[dependencies]
anyhow = { version = "1.0.55", default-features = false, optional = true }
anyhow = { version = "1.0.56", optional = true, default-features = false }
attohttpc = { version = "0.18.0", optional = true }
blake3 = { version = "1.3.1", default-features = false }

[dev-dependencies]
git2 = { version = "0.14.2", default-features = false }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
manta-sdk = { path = ".", default-features = false, features = ["download"] }
tempfile = { version = "3.3.0", default-features = false }
walkdir = { version = "2.3.2", default-features = false }

[build-dependencies]
anyhow = { version = "1.0.55", default-features = false, features = ["std"] }
anyhow = { version = "1.0.56", default-features = false, features = ["std"] }
blake3 = { version = "1.3.1", default-features = false, features = ["std"] }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
walkdir = { version = "2.3.2", default-features = false }
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ To check that the checkfile is up-to-date use the following command:
```sh
b3sum --check data.checkfile
```

## Validating the Dataset

To check that the dataset in the [`data`](./data) directory matches the data exported by the `manta-sdk` crate, run

```sh
cargo test --release -- --nocapture
```

which will download all the files on the GitHub source repository for the current branch and check that all the files match the known checksums.
27 changes: 16 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ use std::{
/// Returns the parent of `path` which should exist relative to `OUT_DIR`.
#[inline]
fn parent(path: &Path) -> Result<&Path> {
path.parent().ok_or(anyhow!(
"The parent should be in the subtree of the `OUT_DIR` directory."
))
path.parent()
.ok_or_else(|| anyhow!("The parent should be in the subtree of the `OUT_DIR` directory."))
}

/// Checksum
Expand Down Expand Up @@ -81,13 +80,13 @@ fn write_checksum<P>(path: P, checksum: Checksum) -> Result<()>
where
P: AsRef<Path>,
{
Ok(fs::write(
path.as_ref().with_extension("checksum"),
checksum,
)?)
let path = path.as_ref();
fs::create_dir_all(parent(path)?)?;
Ok(fs::write(path.with_extension("checksum"), checksum)?)
}

/// Compiles raw data files by copying them to the `out_dir` directory to be interpreted as blobs.
/// Compiles a raw binary file by checking its BLAKE3 checksum with the `checksums` map and copying
/// the data and checksum to the `out_dir`.
#[inline]
fn compile_dat(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result<()> {
let checksum = get_checksum(checksums, source)?;
Expand All @@ -102,12 +101,17 @@ fn compile_dat(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result
data,
);
let target = out_dir.join(source);
fs::create_dir_all(parent(&target)?)?;
fs::copy(source, &target)?;
write_checksum(target, checksum)?;
write_checksum(&target, checksum)?;
fs::copy(source, target)?;
Ok(())
}

/// Compiles a Git LFS file by writing its checksum to the `out_dir`.
#[inline]
fn compile_lfs(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result<()> {
write_checksum(out_dir.join(source), get_checksum(checksums, source)?)
}

/// Loads all the files from `data` into the `OUT_DIR` directory for inclusion into the library.
#[inline]
fn main() -> Result<()> {
Expand All @@ -121,6 +125,7 @@ fn main() -> Result<()> {
match path.extension() {
Some(extension) => match extension.to_str() {
Some("dat") => compile_dat(path, &out_dir, &checksums)?,
Some("lfs") => compile_lfs(path, &out_dir, &checksums)?,
_ => bail!("Unsupported data file extension."),
},
_ => bail!("All data files must have an extension."),
Expand Down
20 changes: 11 additions & 9 deletions data.checkfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
df87563f5a6366a341f4dd1796ecd7eec85354e0e8e0bb9e2a8cdb33be3a31e9 data/pay/testnet/parameters/key-agreement.dat
348d7e0072ffdb56fd19d6115c89a3c9172639c5167e8a7e905dc8a575e4f17d data/pay/testnet/parameters/utxo-commitment-scheme.dat
df87563f5a6366a341f4dd1796ecd7eec85354e0e8e0bb9e2a8cdb33be3a31e9 data/pay/testnet/parameters/note-encryption-scheme.dat
05e6b3b6a0d6d6debe458b6f7ddaefa51a4d38608024a98fc4dedf5ee8b68e99 data/pay/testnet/parameters/utxo-accumulator-model.dat
9dcf5d51f6ffbcda46eaaab64e7350095465f8cc774f8276b46889c46479a2e4 data/pay/testnet/parameters/void-number-hash-function.dat
9748336897c8c98764e5701717871e39a5794e61bbc9e150c613a0ed7024986a data/pay/testnet/proving/mint.dat
d5d73fd62ff0f7bf8945f34e27b1471c0445e9835313ebb689be80a8ea3e7cee data/pay/testnet/proving/private-transfer.dat
22999c822392afd18992dedeb849ae0ccb0bf76399f60fc64a24dff2592ed763 data/pay/testnet/proving/reclaim.dat
2624fa19b9193eec55d83f72b090cd08623c351382c02add861e0626ac59de5f data/pay/testnet/verifying/mint.dat
c90cd08e2ed765b35888e6dc93c963919ed4cbf66db891c1b45d3eb5ec594d29 data/pay/testnet/verifying/private-transfer.dat
69726f8db5b9bf9c5c4592d473c741fff08a909bdfa4c8fc0508c207c9a4ad3d data/pay/testnet/verifying/reclaim.dat
348d7e0072ffdb56fd19d6115c89a3c9172639c5167e8a7e905dc8a575e4f17d data/pay/testnet/parameters/utxo-commitment-scheme.dat
9dcf5d51f6ffbcda46eaaab64e7350095465f8cc774f8276b46889c46479a2e4 data/pay/testnet/parameters/void-number-commitment-scheme.dat
d0dbeec5afcd85025678bf64db3a540622be09e3208ace153446639a7d5de98e data/pay/testnet/proving/mint.lfs
04b294703a2588e6a6a4bd98734fb18fa5f8c10b33be63bb9a73f68c05ccaf2c data/pay/testnet/proving/private-transfer.lfs
eb5c880bdf3c998a9a081f0259fd536e07f4bb71095bcef5664326bcb1ad6428 data/pay/testnet/proving/reclaim.lfs
5719387f9625828f46835a8375656578e028d8fc6da6822b765f47e296c0aaac data/pay/testnet/verifying/mint.dat
29a8229b59490223372c1f2b918f10d806be64ac4ffa5695dbdfe97b4b52e404 data/pay/testnet/verifying/private-transfer.dat
bbe115020d563d63d404437c38741f0d527ab0441b4aaf4de463d9e9452dee09 data/pay/testnet/verifying/reclaim.dat
b0afebeb04bbaafb503393b84003edb1ec515d5bdc822e3df9559285ff23dda3 data/trusted-setup/bls12-381/powers-of-tau-g1.lfs
3add4e890bb3e82f8346e31b0b4bad3c77da38f0605b4af33ba17eab2dd0e56e data/trusted-setup/bls12-381/powers-of-tau-g2.lfs
Binary file removed data/pay/testnet/proving/mint.dat
Binary file not shown.
3 changes: 3 additions & 0 deletions data/pay/testnet/proving/mint.lfs
Git LFS file not shown
Binary file removed data/pay/testnet/proving/private-transfer.dat
Binary file not shown.
3 changes: 3 additions & 0 deletions data/pay/testnet/proving/private-transfer.lfs
Git LFS file not shown
Binary file removed data/pay/testnet/proving/reclaim.dat
Binary file not shown.
3 changes: 3 additions & 0 deletions data/pay/testnet/proving/reclaim.lfs
Git LFS file not shown
Binary file modified data/pay/testnet/verifying/mint.dat
Binary file not shown.
Binary file modified data/pay/testnet/verifying/private-transfer.dat
Binary file not shown.
Binary file modified data/pay/testnet/verifying/reclaim.dat
Binary file not shown.
3 changes: 3 additions & 0 deletions data/trusted-setup/bls12-381/powers-of-tau-g1.lfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/trusted-setup/bls12-381/powers-of-tau-g2.lfs
Git LFS file not shown
3 changes: 0 additions & 3 deletions legacy/proving/private-transfer.dat

This file was deleted.

3 changes: 0 additions & 3 deletions legacy/proving/reclaim.dat

This file was deleted.

Loading