-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Denis Varlakov
authored
Jan 4, 2022
1 parent
b1448e2
commit c480a8a
Showing
13 changed files
with
629 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
schedule: | ||
- cron: '0 5 * * *' | ||
workflow_call: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Swatinem/rust-cache@v1 | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: cargo test --verbose | ||
- name: Check formatting | ||
run: cargo fmt --all -- --check | ||
- name: Run clippy | ||
run: cargo clippy -- -D clippy::all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
|
||
jobs: | ||
build: | ||
uses: ZenGo-X/multi-party-ecdsa/.github/workflows/build.yml@master | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Publish crate | ||
env: | ||
TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
run: | | ||
cargo publish --token "$TOKEN" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use anyhow::{anyhow, ensure, Context, Result}; | ||
use futures::StreamExt; | ||
use std::path::PathBuf; | ||
use structopt::StructOpt; | ||
|
||
use multi_party_ecdsa::protocols::multi_party_ecdsa::gg_2020::state_machine::keygen::Keygen; | ||
use round_based::async_runtime::AsyncProtocol; | ||
|
||
mod gg20_sm_client; | ||
use gg20_sm_client::join_computation; | ||
|
||
#[derive(Debug, StructOpt)] | ||
struct Cli { | ||
#[structopt(short, long, default_value = "http://localhost:8000/")] | ||
address: surf::Url, | ||
#[structopt(short, long, default_value = "default-keygen")] | ||
room: String, | ||
#[structopt(short, long)] | ||
output: PathBuf, | ||
|
||
#[structopt(short, long)] | ||
index: u16, | ||
#[structopt(short, long)] | ||
threshold: u16, | ||
#[structopt(short, long)] | ||
number_of_parties: u16, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let args: Cli = Cli::from_args(); | ||
let mut output_file = tokio::fs::OpenOptions::new() | ||
.write(true) | ||
.create_new(true) | ||
.open(args.output) | ||
.await | ||
.context("cannot create output file")?; | ||
|
||
let (_i, incoming, outgoing) = join_computation(args.address, &args.room) | ||
.await | ||
.context("join computation")?; | ||
|
||
let incoming = incoming.fuse(); | ||
tokio::pin!(incoming); | ||
tokio::pin!(outgoing); | ||
|
||
let keygen = Keygen::new(args.index, args.threshold, args.number_of_parties)?; | ||
let output = AsyncProtocol::new(keygen, incoming, outgoing) | ||
.run() | ||
.await | ||
.map_err(|e| anyhow!("protocol execution terminated with error: {}", e))?; | ||
let output = serde_json::to_vec_pretty(&output).context("serialize output")?; | ||
tokio::io::copy(&mut output.as_slice(), &mut output_file) | ||
.await | ||
.context("save output to file")?; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.