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

Trusted Setup client binaries #257

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
### Added
- [\#257](https://github.com/Manta-Network/manta-rs/pull/257) Add client binaries for the trusted setup
- [\#238](https://github.com/Manta-Network/manta-rs/pull/238) Add trusted setup ceremony primitives for server and client
- [\#237](https://github.com/Manta-Network/manta-rs/pull/237) Public input fuzzing tests for transfer protocol
- [\#215](https://github.com/Manta-Network/manta-rs/pull/215) Add windowed multiplication algorithm for groups
Expand Down
6 changes: 6 additions & 0 deletions manta-trusted-setup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ is-it-maintained-issue-resolution = { repository = "Manta-Network/manta-rs" }
is-it-maintained-open-issues = { repository = "Manta-Network/manta-rs" }
maintenance = { status = "actively-developed" }

[[bin]]
name = "groth16_phase2_client"
required-features = ["bincode", "clap", "csv", "ppot", "tokio"]

[features]
# Bincode for Message Signing
bincode = ["dep:bincode", "serde"]
Expand Down Expand Up @@ -58,6 +62,7 @@ ark-std = { version = "0.3.0", default-features = false }
bincode = { version = "1.3.3", optional = true, default-features = false }
blake2 = { version = "0.10.4", default-features = false }
bs58 = { version = "0.4", default-features = false, features = ["alloc"] }
clap = { version = "3.2.22", optional = true, default-features = false, features = ["color", "derive", "std", "suggestions", "unicode", "wrap_help"] }
colored = { version = "2.0.0", default-features = false }
console = { version = "0.15.1", default-features = false }
csv = { version = "1.1.6", optional = true, default-features = false }
Expand All @@ -67,6 +72,7 @@ manta-crypto = { path = "../manta-crypto", default-features = false, features =
manta-util = { path = "../manta-util", default-features = false, features = ["reqwest"] }
parking_lot = { version = "0.12.1", default-features = false }
tiny-bip39 = { version = "1.0.0", default-features = false }
tokio = { version = "1.21.1", optional = true, default-features = false, features = ["rt-multi-thread"] }

[dev-dependencies]
ark-snark = { version = "0.3.0", default-features = false }
Expand Down
99 changes: 99 additions & 0 deletions manta-trusted-setup/src/bin/groth16_phase2_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2019-2022 Manta Network.
// This file is part of manta-rs.
//
// manta-rs is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// manta-rs is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with manta-rs. If not, see <http://www.gnu.org/licenses/>.

//! Trusted Setup Ceremony Client

extern crate alloc;

use clap::{Parser, Subcommand};
use dialoguer::{theme::ColorfulTheme, Input};
use manta_trusted_setup::groth16::ceremony::{
config::ppot::{client_contribute, get_client_keys, handle_error, register, Config},
CeremonyError,
};

/// Welcome Message
pub const TITLE: &str = r"
__ __ _ _______ _ _ _____ _
| \/ | | | |__ __| | | | | / ____| | |
| \ / | __ _ _ __ | |_ __ _ | |_ __ _ _ ___| |_ ___ __| | | (___ ___| |_ _ _ _ __
| |\/| |/ _` | '_ \| __/ _` | | | '__| | | / __| __/ _ \/ _` | \___ \ / _ | __| | | | '_ \
| | | | (_| | | | | || (_| | | | | | |_| \__ | || __| (_| | ____) | __| |_| |_| | |_) |
|_| |_|\__,_|_| |_|\__\__,_| |_|_| \__,_|___/\__\___|\__,_| |_____/ \___|\__|\__,_| .__/
| |
|_|
";

/// Command
#[derive(Debug, Subcommand)]
pub enum Command {
/// Register for the Trusted Setup Ceremony
Register,

/// Runs the Trusted Setup Ceremony as a Contributor
Contribute,
}

/// Command Line Arguments
#[derive(Debug, Parser)]
pub struct Arguments {
/// Command
#[clap(subcommand)]
command: Command,
}

impl Arguments {
/// Takes command line arguments and executes the corresponding operations.
#[inline]
pub fn run(self) -> Result<(), CeremonyError<Config>> {
println!("{}", TITLE);
match self.command {
Command::Register => {
let twitter_account = Input::with_theme(&ColorfulTheme::default())
.with_prompt("Your twitter account")
.interact_text()
.expect("");
let email = Input::with_theme(&ColorfulTheme::default())
.with_prompt("Your email")
.interact_text()
.expect("");
register(twitter_account, email);
Ok(())
}
Command::Contribute => {
let (sk, pk) = match get_client_keys() {
Ok(keys) => keys,
Err(e) => panic!("Error while extracting the client keys: {}", e),
};
match tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_io()
.enable_time()
.build()
{
Ok(runtime) => {
runtime.block_on(async { client_contribute::<Config>(sk, pk).await })
}
Err(e) => panic!("I/O Error while setting up the tokio Runtime: {:?}", e),
}
}
}
}
}

fn main() {
handle_error(Arguments::parse().run());
}
4 changes: 2 additions & 2 deletions manta-trusted-setup/src/groth16/ceremony/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

//! Groth16 Trusted Setup Ceremony Configurations

#[cfg(feature = "csv")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "csv")))]
#[cfg(all(feature = "csv", feature = "ppot"))]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "csv", feature = "ppot"))))]
pub mod ppot;
Loading