From 2e52d4a5c6f547176bfe31afe68ff1167f7fdf3c Mon Sep 17 00:00:00 2001 From: Awa Sun Yin <11296013+awasunyin@users.noreply.github.com> Date: Fri, 18 Nov 2022 08:03:08 +0100 Subject: [PATCH 1/3] Update README.md Client contribution flow was duplicated --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index a6a7f441..c51125e6 100644 --- a/README.md +++ b/README.md @@ -138,15 +138,6 @@ and input them to: ``` namada-ts verify-contribution $public_key $contribution_hash $contribution_hash_signature ``` -### Client Contribution Flow - -1. The client will generate a secret mnemonic that derives your key pair. Back up your mnemonic and keep it in a safe place! This is the only way to prove your contribution. - -2. Then, you will need to provide the unique token for your cohort you received by email. If the token is valid, you will join the queue of the ceremony. You will need to wait a bit until it is your turn. Each round lasts between 4 min and 20 min. During the whole ceremony, please neither close your terminal, nor your internet connection. If you stay offline for more than 2 min, the coordinator will kick you out from the queue. - -3. When it is your turn, the client will download the challenge from the coordinator and save it to the root folder. You have at most 20 minutes to compute your contribution and send it back to the coordinator. Be creative and good luck! - ## Client Contribution Flow From 625e7fac29deb7b9ddd82aa1c7ae8844914da2d3 Mon Sep 17 00:00:00 2001 From: Jason Davies Date: Fri, 18 Nov 2022 15:53:47 +0000 Subject: [PATCH 2/3] Fix some typos in CLI message strings. (#97) --- phase2-cli/src/bin/namada-ts.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phase2-cli/src/bin/namada-ts.rs b/phase2-cli/src/bin/namada-ts.rs index e2dc0b8b..1db7084b 100644 --- a/phase2-cli/src/bin/namada-ts.rs +++ b/phase2-cli/src/bin/namada-ts.rs @@ -52,7 +52,7 @@ const OFFLINE_CONTRIBUTION_FILE_NAME: &str = "contribution.params"; const OFFLINE_CHALLENGE_FILE_NAME: &str = "challenge.params"; const CUSTOM_SEED_MSG_NO: &str = "Enter a variable-length random string to be used as entropy in combination with your OS randomness.\nYou can type frenetically, smash your keyboard, or enter a string representation of your alternative source of entropy.\nThe only limitation is your terminal’s max command length.\nThis string will be hashed together with your OS randomness to produce the seed for ChaCha RNG"; -const CUSTOM_SEED_MSG_YES: &str = "Provide your custom random seed to initialize the ChaCha random number generator.\nYou seed might come you from an external source of randomness like atmospheric noise, radioactive elements, lava lite etc. or an airgapped machine."; +const CUSTOM_SEED_MSG_YES: &str = "Provide your custom random seed to initialize the ChaCha random number generator.\nYour seed might come from an external source of randomness like atmospheric noise, radioactive elements, lava lite etc. or an airgapped machine."; macro_rules! pretty_hash { ($hash:expr) => {{ @@ -76,7 +76,7 @@ macro_rules! pretty_hash { fn initialize_contribution() -> Result { let mut contrib_info = ContributionInfo::default(); let anonymous = io::get_user_input( - "Do you want to participate anonymously (if not, you'll be asked to provide us with your name and email address)? [y/n]".bright_yellow(), + "Do you want to participate anonymously (if not, you’ll be asked to provide us with your name and email address)? [y/n]".bright_yellow(), Some(&Regex::new(r"^(?i)[yn]$")?), )? .to_lowercase(); @@ -175,7 +175,7 @@ fn compute_contribution_offline() -> Result<()> { println!("{}", msg.bright_cyan()); // Wait for the contribution file to be updated with randomness - // NOTE: we don't actually check for the timeout on the 15 minutes. If the user takes more time than allowed to produce the file we'll keep going on in the contribution, at the following request the Coordinator will reply with an error because ther contributor has been dropped out of the ceremony + // NOTE: we don't actually check for the timeout on the 15 minutes. If the user takes more time than allowed to produce the file we'll keep going on in the contribution, at the following request the Coordinator will reply with an error because the contributor has been dropped out of the ceremony io::get_user_input( "When your contribution file is ready, press enter to upload it".bright_yellow(), None, @@ -512,7 +512,7 @@ async fn contribution_loop( "If you’d like to share that you contributed with your frens and the world, you can use:".bright_cyan(), round_height, contrib_info.contribution_hash, - format!("You also find all the metadata of your contribution (ceremony round, contribution hash, public key, timestamps etc.) in the \"namada_contributior_info_round_{}.json\"",round_height).as_str().bright_cyan() + format!("You’ll also find all the metadata of your contribution (ceremony round, contribution hash, public key, timestamps etc.) in \"namada_contributior_info_round_{}.json\"",round_height).as_str().bright_cyan() ); println!("{}\n", ASCII_CONTRIBUTION_DONE.bright_yellow()); 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 3/3] 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"