Skip to content

Commit

Permalink
Merge branch 'main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Nov 18, 2022
2 parents 6ba819c + b778ebc commit c5502b5
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 43 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.

28 changes: 14 additions & 14 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,28 +131,22 @@ 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]
```
### 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!
<!-- #### Flowchart
![Alt text](./ceremony-contribution-diagram.png?raw=true "Ceremony Contribution Flow") -->
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

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
41 changes: 25 additions & 16 deletions phase2-cli/src/bin/namada-ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {{
Expand All @@ -76,7 +76,7 @@ macro_rules! pretty_hash {
fn initialize_contribution() -> Result<ContributionInfo> {
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, youll be asked to provide us with your name and email address)? [y/n]".bright_yellow(),
Some(&Regex::new(r"^(?i)[yn]$")?),
)?
.to_lowercase();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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());

Expand Down 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 c5502b5

Please sign in to comment.