From b778ebcf360f0fb932d30a9fdb44fddf95d1ae43 Mon Sep 17 00:00:00 2001 From: Marco Granelli <73647772+grarco@users.noreply.github.com> Date: Fri, 18 Nov 2022 17:05:14 +0100 Subject: [PATCH] Dry run fixes (#98) * Reorders token and coordinator check in cli * Updates dependencies in README * Fixes string formatting * v1.0.0 * Improves contribution verification command Co-authored-by: Fraccaroli Gianmarco Co-authored-by: Fraccaroli Gianmarco --- Cargo.lock | 8 ++++---- README.md | 21 +++++++++++++++------ install.sh | 2 +- phase2-cli/Cargo.toml | 2 +- phase2-cli/src/bin/namada-ts.rs | 33 +++++++++++++++++++++------------ phase2-cli/src/lib.rs | 10 ++++++---- phase2-coordinator/Cargo.toml | 2 +- phase2/Cargo.toml | 2 +- setup-utils/Cargo.toml | 2 +- 9 files changed, 51 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c37f20cd..083fd73e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2275,7 +2275,7 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "phase2" -version = "1.0.0-beta.11" +version = "1.0.0" dependencies = [ "anyhow", "blake2 0.9.2", @@ -2304,7 +2304,7 @@ dependencies = [ [[package]] name = "phase2-cli" -version = "1.0.0-beta.11" +version = "1.0.0" dependencies = [ "anyhow", "async-stream", @@ -2348,7 +2348,7 @@ dependencies = [ [[package]] name = "phase2-coordinator" -version = "1.0.0-beta.11" +version = "1.0.0" dependencies = [ "anyhow", "base64", @@ -3316,7 +3316,7 @@ dependencies = [ [[package]] name = "setup-utils" -version = "1.0.0-beta.11" +version = "1.0.0" dependencies = [ "blake2 0.9.2", "blake2s_simd 0.5.11", diff --git a/README.md b/README.md index c51125e6..41fcf390 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,13 @@ Participants are also encouraged to participate via their custom clients. For mo ## 1. Building and contributing from source -First, [install Rust](https://www.rust-lang.org/tools/install) by entering the following command: +First, you will need to install some dependencies. On debian-based systems you can use: + +``` +sudo apt update && sudo apt install -y curl git build-essential pkg-config libssl-dev +``` + +After that, you'll need to [install Rust](https://www.rust-lang.org/tools/install) by entering the following command: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` @@ -55,10 +61,10 @@ If you already have Rust installed, make sure it is the most up-to-date version: rustup update ``` -Once Rust is installed, clone the Namada Trusted Setup Ceremony GitHub repository and change directories into `namada-trusted-setup`: +Once everything is installed, clone the Namada Trusted Setup Ceremony GitHub repository and change directories into `namada-trusted-setup`: ``` git clone https://github.com/anoma/namada-trusted-setup.git -cd namada-trusted-setup && git checkout v1.0.0-beta.11 +cd namada-trusted-setup && git checkout v1.0.0 ``` Build the binary: @@ -125,20 +131,23 @@ cargo run --release --bin namada-ts --features cli contribute offline which will compute the contribution itself. This second command expects the file `challenge.params` got from the online machine to be available in the cwd and it will produce a `contribution.params` to be passed back to the online machine for shipment to the coordinator. The user will be responsible for moving these files around. -### Verify your contribution +### Verify a contribution -If you want to verify your contribution you can do it via CLI. After you have successfully contributed, a file called `namada_contributor_info_round_${round_height}.json` will be generated and saved in the same folder of the `namada-ts` binary. The file contains a json structure. You should copy the value following fields: +If you want to verify a contribution you can do it via CLI. After you have successfully contributed, a file called `namada_contributor_info_round_${round_height}.json` will be generated and saved in the same folder of the `namada-ts` binary, together with the parameter file `namada_contribution_round_{ROUND}_public_key_{PUBLIC_KEY}.params`. The file contains a json structure. You should copy the values of following fields: - `public_key` - `contribution_hash` - `contribution_hash_signature` +- `parameter_path` - This is an optional argument, and it's the absolute path to the parameter file generated by the CLI (mentioned above) and input them to: ``` -namada-ts verify-contribution $public_key $contribution_hash $contribution_hash_signature +namada-ts verify-contribution $public_key $contribution_hash $contribution_hash_signature $[parameter_path] ``` +With the same procedure you can also verify any other contribution: you'll find all the data that you need at `https://ceremony.namada.net`. + ## Client Contribution Flow 1. The client will ask you if you want to contribute anonymously: diff --git a/install.sh b/install.sh index 62c5a6ee..0bb04ba0 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ set -u -LAST_BINARY_VERSION="1.0.0-beta.11" +LAST_BINARY_VERSION="1.0.0" BINARY_NAME="namada-ts" BINARY_FOLDER="$HOME/.namada-ts" BINARY_PATH="$BINARY_FOLDER/$BINARY_NAME" diff --git a/phase2-cli/Cargo.toml b/phase2-cli/Cargo.toml index aaecab60..cdf64f33 100644 --- a/phase2-cli/Cargo.toml +++ b/phase2-cli/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://github.com/AleoHQ/aleo-setup" license = "MIT/Apache-2.0" name = "phase2-cli" repository = "https://github.com/AleoHQ/aleo-setup" -version = "1.0.0-beta.11" +version = "1.0.0" [dependencies] phase2 = {path = "../phase2"} diff --git a/phase2-cli/src/bin/namada-ts.rs b/phase2-cli/src/bin/namada-ts.rs index 1db7084b..6ad306d1 100644 --- a/phase2-cli/src/bin/namada-ts.rs +++ b/phase2-cli/src/bin/namada-ts.rs @@ -637,17 +637,7 @@ enum Branch { /// Performs the entire contribution cycle #[inline(always)] async fn contribution_prelude(url: CoordinatorUrl, token: String, branch: Branch) { - // Check that the passed-in coordinator url is correct - let client = Client::new(); - requests::ping_coordinator(&client, &url.coordinator) - .await - .expect(&format!( - "{}", - "ERROR: could not contact the Coordinator, please check the url you provided" - .red() - .bold() - )); - + // Check the token info let decoded_bytes = bs58::decode(token.clone()).into_vec(); if let Ok(token_bytes) = decoded_bytes { let decoded_token = String::from_utf8(token_bytes).expect("Can't decode the token"); @@ -669,10 +659,18 @@ async fn contribution_prelude(url: CoordinatorUrl, token: String, branch: Branch _ => (), } } else { - println!("The token provided is not base58 encoded."); + eprintln!("{}", "The token provided is not base58 encoded.".red().bold()); process::exit(0); }; + // Check that the passed-in coordinator url is correct + let client = Client::new(); + if requests::ping_coordinator(&client, &url.coordinator) + .await.is_err() { + eprintln!("{}", "ERROR: could not contact the Coordinator, please check the url you provided".red().bold()); + process::exit(1); + }; + println!("{}", ASCII_LOGO.bright_yellow()); println!("{}", "Welcome to the Namada Trusted Setup Ceremony!".bold()); @@ -875,7 +873,18 @@ async fn main() { pubkey, message, signature, + parameter_path }) => { + if let Some(path) = parameter_path { + // Check hash of the parameters file + let contribution = std::fs::read(path).expect(&format!("{}", "Failed to read file".red().bold())); + let contribution_file_hash = calculate_hash(contribution.as_ref()); + if hex::encode(contribution_file_hash) != message { + eprintln!("{}", "The computed hash of the file does not match the provided one".red().bold()); + process::exit(1); + } + } + let result = verify_signature(pubkey, signature, message); if result { println!("The contribution signature is correct.") diff --git a/phase2-cli/src/lib.rs b/phase2-cli/src/lib.rs index e52eaf38..a56c1805 100644 --- a/phase2-cli/src/lib.rs +++ b/phase2-cli/src/lib.rs @@ -116,12 +116,14 @@ impl Token { #[derive(Debug, StructOpt)] pub struct VerifySignatureContribution { - #[structopt(about = "The contribution public key")] + #[structopt(help = "The contribution public key")] pub pubkey: String, - #[structopt(about = "The contribution message hash")] + #[structopt(help = "The contribution message hash")] pub message: String, - #[structopt(about = "The contribution signature")] + #[structopt(help = "The contribution signature")] pub signature: String, + #[structopt(help = "The path to the contribution file", parse(try_from_str))] + pub parameter_path: Option } #[derive(Debug, StructOpt)] @@ -148,6 +150,6 @@ pub enum CeremonyOpt { #[cfg(debug_assertions)] #[structopt(about = "Update manually the coordinator")] UpdateCoordinator(CoordinatorUrl), - #[structopt(about = "Verify signature")] + #[structopt(about = "Verify a contribution")] VerifyContribution(VerifySignatureContribution), } diff --git a/phase2-coordinator/Cargo.toml b/phase2-coordinator/Cargo.toml index 8a5fa741..44acfb26 100644 --- a/phase2-coordinator/Cargo.toml +++ b/phase2-coordinator/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://github.com/AleoHQ/aleo-setup" license = "MIT/Apache-2.0" name = "phase2-coordinator" repository = "https://github.com/AleoHQ/aleo-setup" -version = "1.0.0-beta.11" +version = "1.0.0" [[bin]] name = "phase2-coordinator" diff --git a/phase2/Cargo.toml b/phase2/Cargo.toml index a6fe7aeb..23b7e693 100644 --- a/phase2/Cargo.toml +++ b/phase2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "phase2" -version = "1.0.0-beta.11" +version = "1.0.0" authors = ["Sean Bowe", "Alex Vlasov", "The Aleo Team "] description = "Core logic for Phase 1" homepage = "https://github.com/AleoHQ/aleo-setup" diff --git a/setup-utils/Cargo.toml b/setup-utils/Cargo.toml index f91b2376..485296ff 100644 --- a/setup-utils/Cargo.toml +++ b/setup-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "setup-utils" -version = "1.0.0-beta.11" +version = "1.0.0" authors = ["Georgios Konstantopoulos ", "The Aleo Team "] edition = "2018"