Skip to content

Commit

Permalink
Dry run fixes (#98)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: Fraccaroli Gianmarco <[email protected]>
  • Loading branch information
grarco and Fraccaman authored Nov 18, 2022
1 parent 625e7fa commit b778ebc
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 31 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion phase2-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
33 changes: 21 additions & 12 deletions phase2-cli/src/bin/namada-ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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());

Expand Down Expand Up @@ -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.")
Expand Down
10 changes: 6 additions & 4 deletions phase2-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>
}

#[derive(Debug, StructOpt)]
Expand All @@ -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),
}
2 changes: 1 addition & 1 deletion phase2-coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion phase2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
description = "Core logic for Phase 1"
homepage = "https://github.com/AleoHQ/aleo-setup"
Expand Down
2 changes: 1 addition & 1 deletion setup-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "setup-utils"
version = "1.0.0-beta.11"
version = "1.0.0"
authors = ["Georgios Konstantopoulos <[email protected]>", "The Aleo Team <[email protected]>"]
edition = "2018"

Expand Down

0 comments on commit b778ebc

Please sign in to comment.