Skip to content

Commit

Permalink
Merge branch 'main' into retrieve_transaction_data
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
  • Loading branch information
bhgomes authored Jan 12, 2023
2 parents 70877a6 + d5cf096 commit b31072a
Show file tree
Hide file tree
Showing 61 changed files with 5,233 additions and 211 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
### Added
- [\#295](https://github.com/Manta-Network/manta-rs/pull/295) Transaction data retrieving methods for the signer.
- [\#297](https://github.com/Manta-Network/manta-rs/pull/297) Add trusted setup verification tools, update manta-parameters

### Changed
- [\#293](https://github.com/Manta-Network/manta-rs/pull/293) Add decimals argument to AssetMetadata display
Expand Down
4 changes: 2 additions & 2 deletions manta-parameters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ std = ["anyhow?/std"]
[dependencies]
anyhow = { version = "1.0.66", optional = true, default-features = false }
attohttpc = { version = "0.22.0", optional = true }
blake3 = { version = "1.3.1", default-features = false }
blake3 = { version = "1.3.3", default-features = false }
git2 = { version = "0.15.0", optional = true, default-features = false }

[dev-dependencies]
Expand All @@ -48,7 +48,7 @@ walkdir = { version = "2.3.2", default-features = false }

[build-dependencies]
anyhow = { version = "1.0.66", default-features = false, features = ["std"] }
blake3 = { version = "1.3.1", default-features = false, features = ["std"] }
blake3 = { version = "1.3.3", default-features = false, features = ["std"] }
gitignore = { version = "1.0.7", default-features = false }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
walkdir = { version = "2.3.2", default-features = false }
55 changes: 49 additions & 6 deletions manta-parameters/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Manta Parameters Build Script

use anyhow::{anyhow, bail, ensure, Result};
use core::fmt::Display;
use hex::FromHex;
use std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -86,16 +87,34 @@ where
Ok(fs::write(path.with_extension("checksum"), checksum)?)
}

/// Compiles a raw binary file by checking its BLAKE3 checksum with the `checksums` map and copying
/// the data and checksum to the `out_dir`.
/// Loads a local file from `source` and reads it's checksum from `checksums`.
#[inline]
fn compile_dat(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result<()> {
fn load_local_file(
source: &Path,
checksums: &ChecksumMap,
) -> Result<(Checksum, Vec<u8>, Checksum)> {
let checksum = get_checksum(checksums, source)?;
let data = fs::read(source)?;
let found_checksum = blake3::hash(&data);
Ok((checksum, data, found_checksum.into()))
}

/// Ensures that the `found_checksum` and `checksum` are equal for `data`, and if so writes the
/// checksum to the `out_dir` directory.
#[inline]
fn validate_and_save_checksum<D>(
source: &Path,
out_dir: &Path,
checksum: Checksum,
data: D,
found_checksum: Checksum,
) -> Result<()>
where
D: Display,
{
ensure!(
found_checksum == checksum,
"Checksum did not match for {:?}. Expected: {:?}, Found: {:?}. Data: {:?}",
"Checksum did not match for {:?}. Expected: {:?}, Found: {:?}. Data: \n\n{}",
source,
hex::encode(checksum),
found_checksum,
Expand All @@ -107,6 +126,27 @@ fn compile_dat(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result
Ok(())
}

/// Compiles a local binary file by checking its BLAKE3 checksum with the `checksums` map and copying
/// the data and checksum to the `out_dir`.
#[inline]
fn compile_local_binary_file(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result<()> {
let (checksum, data, found_checksum) = load_local_file(source, checksums)?;
let hex_data = hex::encode(data);
println!("Binary Data for: {}\n\n{hex_data}", source.display());
validate_and_save_checksum(source, out_dir, checksum, hex_data, found_checksum)
}

/// Compiles a local text file by checking its BLAKE3 checksum with the `checksums` map and copying
/// the data and checksum to the `out_dir`.
#[allow(dead_code)] // FIXME: For some reason `.txt` files aren't working on windows.
#[inline]
fn compile_local_text_file(source: &Path, out_dir: &Path, checksums: &ChecksumMap) -> Result<()> {
let (checksum, data, found_checksum) = load_local_file(source, checksums)?;
let string_data = String::from_utf8_lossy(&data);
println!("Text String for {}: \n\n{string_data}", source.display());
validate_and_save_checksum(source, out_dir, checksum, string_data, found_checksum)
}

/// 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<()> {
Expand Down Expand Up @@ -182,9 +222,12 @@ fn main() -> Result<()> {
if !path.is_dir() && !should_ignore(path, &ignore_table)? {
match path.extension() {
Some(extension) => match extension.to_str() {
Some("dat") => compile_dat(path, &out_dir, &checksums)?,
Some("dat") => compile_local_binary_file(path, &out_dir, &checksums)?,
// FIXME: This should work, but for some reason hashing is broken on windows.
//
// Some("txt") => compile_local_text_file(path, &out_dir, &checksums)?,
Some("lfs") => compile_lfs(path, &out_dir, &checksums)?,
Some("md") => {}
Some("md") | Some("txt") => {}
_ => bail!("Unsupported data file extension: {}.", path.display()),
},
_ => bail!("All data files must have an extension: {}.", path.display()),
Expand Down
51 changes: 34 additions & 17 deletions manta-parameters/data.checkfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/testnet/parameters/address-partition-function.dat
65a28898c6f1a27a05682cee72bca89885fb7c27b63153971a5c657dfb246a83 data/pay/testnet/parameters/group-generator.dat
677ddceec2b7758b127381550f2d88a1c82624f4669b656d0167250823a35f58 data/pay/testnet/parameters/incoming-base-encryption-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/testnet/parameters/light-incoming-base-encryption-scheme.dat
d0e90f772d44b0c4b1fb9ed9cd785d8d5451c5ac6ad77a9617c923e7a45a686b data/pay/testnet/parameters/nullifier-commitment-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/testnet/parameters/outgoing-base-encryption-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/testnet/parameters/schnorr-hash-function.dat
d9a787351d03f048494160a90c9895b629f34a5ef12129e937d23f4adef73b97 data/pay/testnet/parameters/utxo-accumulator-item-hash.dat
4211fceef3834f077b71618d9424001df63570542175c83d79a8a7010737554e data/pay/testnet/parameters/utxo-accumulator-model.dat
60e7b366b0e15324263942d29bc1649190b4882987a03fa2a9e4fd21ab6e777a data/pay/testnet/parameters/utxo-commitment-scheme.dat
4211fceef3834f077b71618d9424001df63570542175c83d79a8a7010737554e data/pay/testnet/parameters/viewing-key-derivation-function.dat
7e25d965b4255d8192fdfd6f2c1719e281f308eb7721f6b8cb1b60a169acd9a6 data/pay/testnet/proving/private-transfer.lfs
6302dcbfcd2c40c034bbd35dcf6fe3344e83c572ed9ef673b2154fa6c06c4924 data/pay/testnet/proving/to-private.lfs
438b1971a521ea950cb0fa2cc10c94e54aad88c798736db9d1daf7abad7641f5 data/pay/testnet/proving/to-public.lfs
6ab2557f70f5583779f7cbcd27e73e66f8fcb5704ab21792a4126e89cc15b793 data/pay/testnet/verifying/private-transfer.dat
5e2e618e067c9414fed3ca5b570f8f2b33c9a0a42b925dc723f6fdfdd7436c5c data/pay/testnet/verifying/to-private.dat
d1467307aa8b51b26fb0247eede05cdb3a8d94a3db2a5939f5e181da6024a9a5 data/pay/testnet/verifying/to-public.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/archive/testnet/parameters/address-partition-function.dat
65a28898c6f1a27a05682cee72bca89885fb7c27b63153971a5c657dfb246a83 data/archive/testnet/parameters/group-generator.dat
677ddceec2b7758b127381550f2d88a1c82624f4669b656d0167250823a35f58 data/archive/testnet/parameters/incoming-base-encryption-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/archive/testnet/parameters/light-incoming-base-encryption-scheme.dat
d0e90f772d44b0c4b1fb9ed9cd785d8d5451c5ac6ad77a9617c923e7a45a686b data/archive/testnet/parameters/nullifier-commitment-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/archive/testnet/parameters/outgoing-base-encryption-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/archive/testnet/parameters/schnorr-hash-function.dat
d9a787351d03f048494160a90c9895b629f34a5ef12129e937d23f4adef73b97 data/archive/testnet/parameters/utxo-accumulator-item-hash.dat
4211fceef3834f077b71618d9424001df63570542175c83d79a8a7010737554e data/archive/testnet/parameters/utxo-accumulator-model.dat
60e7b366b0e15324263942d29bc1649190b4882987a03fa2a9e4fd21ab6e777a data/archive/testnet/parameters/utxo-commitment-scheme.dat
4211fceef3834f077b71618d9424001df63570542175c83d79a8a7010737554e data/archive/testnet/parameters/viewing-key-derivation-function.dat
7e25d965b4255d8192fdfd6f2c1719e281f308eb7721f6b8cb1b60a169acd9a6 data/archive/testnet/proving/private-transfer.lfs
6302dcbfcd2c40c034bbd35dcf6fe3344e83c572ed9ef673b2154fa6c06c4924 data/archive/testnet/proving/to-private.lfs
438b1971a521ea950cb0fa2cc10c94e54aad88c798736db9d1daf7abad7641f5 data/archive/testnet/proving/to-public.lfs
6ab2557f70f5583779f7cbcd27e73e66f8fcb5704ab21792a4126e89cc15b793 data/archive/testnet/verifying/private-transfer.dat
5e2e618e067c9414fed3ca5b570f8f2b33c9a0a42b925dc723f6fdfdd7436c5c data/archive/testnet/verifying/to-private.dat
d1467307aa8b51b26fb0247eede05cdb3a8d94a3db2a5939f5e181da6024a9a5 data/archive/testnet/verifying/to-public.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/parameters/address-partition-function.dat
65a28898c6f1a27a05682cee72bca89885fb7c27b63153971a5c657dfb246a83 data/pay/parameters/group-generator.dat
677ddceec2b7758b127381550f2d88a1c82624f4669b656d0167250823a35f58 data/pay/parameters/incoming-base-encryption-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/parameters/light-incoming-base-encryption-scheme.dat
d0e90f772d44b0c4b1fb9ed9cd785d8d5451c5ac6ad77a9617c923e7a45a686b data/pay/parameters/nullifier-commitment-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/parameters/outgoing-base-encryption-scheme.dat
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262 data/pay/parameters/schnorr-hash-function.dat
d9a787351d03f048494160a90c9895b629f34a5ef12129e937d23f4adef73b97 data/pay/parameters/utxo-accumulator-item-hash.dat
4211fceef3834f077b71618d9424001df63570542175c83d79a8a7010737554e data/pay/parameters/utxo-accumulator-model.dat
60e7b366b0e15324263942d29bc1649190b4882987a03fa2a9e4fd21ab6e777a data/pay/parameters/utxo-commitment-scheme.dat
4211fceef3834f077b71618d9424001df63570542175c83d79a8a7010737554e data/pay/parameters/viewing-key-derivation-function.dat
607db6514075bd2be038dcbad897dda52b07d3d87c75477560207de88773c748 data/pay/proving/private-transfer.lfs
eef0801ca4f5cba1d38af88264217b002c12e3b4e428b340e916a7513c161738 data/pay/proving/to-private.lfs
fdd8c77c83965f69ddbf33efdab3b396dd7cc8cd073a76482864ca505ce50853 data/pay/proving/to-public.lfs
6c5255a77a6a06fcf5ed556348432860129b7f30e74e41cf5b7109a6208bdd81 data/pay/verifying/private-transfer.dat
543bc8711ba68e306660a33c37e630513e4bf341d2e7c6bb5171432571c3c95a data/pay/verifying/to-private.dat
967013d7798b4963612143d57a66d5fe5e8afa709eb69c4d274bca99b6e9be96 data/pay/verifying/to-public.dat
25d2368d77dc834774504ca9b001fd4b5926c24c51e87f8e208db5fe40040075 data/ppot/round72powers19.lfs
14 changes: 14 additions & 0 deletions manta-parameters/data/pay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# MantaPay Parameters

The parameters in this directory are the current parameters of the MantaPay protocol, namely the proving and verifying keys for Groth16 proofs and base parameters for crytographic hash functions and accumulators.

Whenever these change the old parameters should be moved to their own directory within `manta-parameters/data/archive` and the new parameters should be placed here at `manta-parameters/data/pay`. The descriptions below should be updated to reflect the changes.

## Current Parameters

The current parameters are the result of the MantaPay trusted setup ceremony after 4,382 rounds of contribution. The list of contribution hashes can be found at `manta-parameters/data/pay/trusted-setup/contribution_hashes.txt`. These keys were computed relative to the base parameters for cryptographic hash functions and accumulators found in `manta-parameters/pay/parameters`, which were randomly sampled.

## Archived Parameters

### Testnet
The parameters in `manta-parameters/data/archive/testnet` are those used for the Dolphin testnet v3. The base parameters for cryptographic hash functions and accumulators were randomly sampled. The Groth16 proving and verifying keys were computed relative to these base parameters and one round of randomly sampled contribution. These proving and verifying keys are not secure for use in production.
Empty file.
2 changes: 2 additions & 0 deletions manta-parameters/data/pay/parameters/group-generator.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
͟�����'����A�|@��
֎X"�������
Binary file not shown.
Empty file.
Binary file not shown.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions manta-parameters/data/pay/proving/private-transfer.lfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions manta-parameters/data/pay/proving/to-private.lfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions manta-parameters/data/pay/proving/to-public.lfs
Git LFS file not shown
Loading

0 comments on commit b31072a

Please sign in to comment.