From 54537baf348cb6c7a4b66702314fc809e06026d9 Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Fri, 27 Dec 2024 11:44:15 -0300 Subject: [PATCH] frostd: rename from 'server' (#414) --- Cargo.lock | 86 +++++++-------- Cargo.toml | 5 +- coordinator/Cargo.toml | 2 +- coordinator/src/comms/http.rs | 32 +++--- frost-client/Cargo.toml | 2 +- frost-client/src/session.rs | 14 +-- {server => frostd}/Cargo.toml | 2 +- {server => frostd}/README.md | 4 +- {server => frostd}/build.rs | 0 {server => frostd}/src/args.rs | 0 {server => frostd}/src/functions.rs | 0 {server => frostd}/src/lib.rs | 0 {server => frostd}/src/main.rs | 4 +- {server => frostd}/src/state.rs | 0 {server => frostd}/src/types.rs | 0 {server => frostd}/src/user.rs | 0 {server => frostd}/tests/integration_tests.rs | 100 +++++++++--------- participant/Cargo.toml | 2 +- participant/src/comms/http.rs | 24 ++--- .../migrations/20240627222152_init.down.sql | 3 - server/migrations/20240627222152_init.up.sql | 16 --- tests/Cargo.toml | 2 +- 22 files changed, 140 insertions(+), 158 deletions(-) rename {server => frostd}/Cargo.toml (98%) rename {server => frostd}/README.md (87%) rename {server => frostd}/build.rs (100%) rename {server => frostd}/src/args.rs (100%) rename {server => frostd}/src/functions.rs (100%) rename {server => frostd}/src/lib.rs (100%) rename {server => frostd}/src/main.rs (92%) rename {server => frostd}/src/state.rs (100%) rename {server => frostd}/src/types.rs (100%) rename {server => frostd}/src/user.rs (100%) rename {server => frostd}/tests/integration_tests.rs (89%) delete mode 100644 server/migrations/20240627222152_init.down.sql delete mode 100644 server/migrations/20240627222152_init.up.sql diff --git a/Cargo.lock b/Cargo.lock index 95a86296..80404992 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -680,6 +680,7 @@ dependencies = [ "frost-core", "frost-ed25519", "frost-rerandomized", + "frostd", "hex", "itertools 0.13.0", "message-io", @@ -690,7 +691,6 @@ dependencies = [ "rpassword", "serde_json", "serdect", - "server", "snow", "thiserror 2.0.9", "tokio", @@ -1094,6 +1094,7 @@ dependencies = [ "frost-core", "frost-ed25519", "frost-rerandomized", + "frostd", "hex", "itertools 0.13.0", "participant", @@ -1105,7 +1106,6 @@ dependencies = [ "serde", "serde_json", "serdect", - "server", "snow", "stable-eyre", "tempfile", @@ -1165,6 +1165,45 @@ dependencies = [ "rand_core", ] +[[package]] +name = "frostd" +version = "0.1.0" +dependencies = [ + "axum", + "axum-extra", + "axum-macros", + "axum-server", + "axum-test", + "clap", + "coordinator", + "delay_map", + "derivative", + "eyre", + "frost-core", + "frost-ed25519", + "frost-rerandomized", + "futures", + "futures-util", + "hex", + "rand", + "rcgen", + "reddsa", + "regex", + "reqwest", + "serde", + "serde_json", + "serdect", + "snow", + "tempfile", + "thiserror 2.0.9", + "tokio", + "tower-http", + "tracing", + "tracing-subscriber", + "uuid", + "xeddsa", +] + [[package]] name = "fs_extra" version = "1.3.0" @@ -2024,6 +2063,7 @@ dependencies = [ "frost-core", "frost-ed25519", "frost-rerandomized", + "frostd", "hex", "message-io", "rand", @@ -2032,7 +2072,6 @@ dependencies = [ "rpassword", "serde_json", "serdect", - "server", "snow", "tokio", "xeddsa", @@ -2660,45 +2699,6 @@ dependencies = [ "serde", ] -[[package]] -name = "server" -version = "0.1.0" -dependencies = [ - "axum", - "axum-extra", - "axum-macros", - "axum-server", - "axum-test", - "clap", - "coordinator", - "delay_map", - "derivative", - "eyre", - "frost-core", - "frost-ed25519", - "frost-rerandomized", - "futures", - "futures-util", - "hex", - "rand", - "rcgen", - "reddsa", - "regex", - "reqwest", - "serde", - "serde_json", - "serdect", - "snow", - "tempfile", - "thiserror 2.0.9", - "tokio", - "tower-http", - "tracing", - "tracing-subscriber", - "uuid", - "xeddsa", -] - [[package]] name = "sha1" version = "0.10.6" @@ -2956,12 +2956,12 @@ dependencies = [ "dkg", "exitcode", "frost-ed25519", + "frostd", "hex", "participant", "rand", "reddsa", "serde_json", - "server", "tokio", "trusted-dealer", ] diff --git a/Cargo.toml b/Cargo.toml index 9ad6dd47..23375ed1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,8 @@ members = [ "dkg", "coordinator", "tests", - "server", "frost-client", + "frostd", + "frost-client", # "zcash-sign", ] # TODO: go back to the workspace. It currently can't because it has a dependency @@ -18,6 +19,6 @@ default-members = [ "dkg", "coordinator", "tests", - "server" + "frostd" ] resolver = "2" diff --git a/coordinator/Cargo.toml b/coordinator/Cargo.toml index 0af398a5..0f28396d 100644 --- a/coordinator/Cargo.toml +++ b/coordinator/Cargo.toml @@ -22,7 +22,7 @@ itertools = "0.13.0" exitcode = "1.1.2" clap = { version = "4.5.23", features = ["derive"] } reqwest = { version = "0.12.9", features = ["json"] } -server = { path = "../server" } +frostd = { path = "../frostd" } participant = { path = "../participant" } tokio = { version = "1", features = ["full"] } message-io = "0.18" diff --git a/coordinator/src/comms/http.rs b/coordinator/src/comms/http.rs index e512620a..263261d7 100644 --- a/coordinator/src/comms/http.rs +++ b/coordinator/src/comms/http.rs @@ -16,11 +16,11 @@ use frost_core::{ Identifier, SigningPackage, }; -use participant::comms::http::Noise; -use rand::thread_rng; -use server::{ +use frostd::{ Msg, PublicKey, SendCommitmentsArgs, SendSignatureSharesArgs, SendSigningPackageArgs, Uuid, }; +use participant::comms::http::Noise; +use rand::thread_rng; use xeddsa::{xed25519, Sign as _}; use super::Comms; @@ -344,10 +344,10 @@ impl Comms for HTTPComms { let challenge = self .client .post(format!("{}/challenge", self.host_port)) - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .send() .await? - .json::() + .json::() .await? .challenge; @@ -365,7 +365,7 @@ impl Comms for HTTPComms { self.access_token = Some( self.client .post(format!("{}/login", self.host_port)) - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge, pubkey: self .args @@ -376,7 +376,7 @@ impl Comms for HTTPComms { }) .send() .await? - .json::() + .json::() .await? .access_token .to_string(), @@ -386,13 +386,13 @@ impl Comms for HTTPComms { .client .post(format!("{}/create_new_session", self.host_port)) .bearer_auth(self.access_token.as_ref().expect("was just set")) - .json(&server::CreateNewSessionArgs { + .json(&frostd::CreateNewSessionArgs { pubkeys: self.args.signers.iter().cloned().map(PublicKey).collect(), message_count: 1, }) .send() .await? - .json::() + .json::() .await?; if self.args.signers.is_empty() { @@ -453,13 +453,13 @@ impl Comms for HTTPComms { .client .post(format!("{}/receive", self.host_port)) .bearer_auth(self.access_token.as_ref().expect("was just set")) - .json(&server::ReceiveArgs { + .json(&frostd::ReceiveArgs { session_id: r.session_id, as_coordinator: true, }) .send() .await? - .json::() + .json::() .await?; for msg in r.msgs { let msg = self.decrypt(msg)?; @@ -507,9 +507,9 @@ impl Comms for HTTPComms { .as_ref() .expect("must have been set before"), ) - .json(&server::SendArgs { + .json(&frostd::SendArgs { session_id: self.session_id.unwrap(), - recipients: vec![server::PublicKey(recipient.clone())], + recipients: vec![frostd::PublicKey(recipient.clone())], msg, }) .send() @@ -529,13 +529,13 @@ impl Comms for HTTPComms { .as_ref() .expect("must have been set before"), ) - .json(&server::ReceiveArgs { + .json(&frostd::ReceiveArgs { session_id: self.session_id.unwrap(), as_coordinator: true, }) .send() .await? - .json::() + .json::() .await?; for msg in r.msgs { let msg = self.decrypt(msg)?; @@ -557,7 +557,7 @@ impl Comms for HTTPComms { .as_ref() .expect("must have been set before"), ) - .json(&server::CloseSessionArgs { + .json(&frostd::CloseSessionArgs { session_id: self.session_id.unwrap(), }) .send() diff --git a/frost-client/Cargo.toml b/frost-client/Cargo.toml index b8bd2957..7e4ede59 100644 --- a/frost-client/Cargo.toml +++ b/frost-client/Cargo.toml @@ -9,7 +9,7 @@ reqwest = { version = "0.12.9", features = ["json"] } serde = { version = "1.0", features = ["derive"] } snow = "0.9.6" toml = "0.8.19" -server = { path = "../server" } +frostd = { path = "../frostd" } trusted-dealer = { path = "../trusted-dealer" } coordinator = { path = "../coordinator" } participant = { path = "../participant" } diff --git a/frost-client/src/session.rs b/frost-client/src/session.rs index 2cbb5b34..6eb08b65 100644 --- a/frost-client/src/session.rs +++ b/frost-client/src/session.rs @@ -50,10 +50,10 @@ pub(crate) async fn list(args: &Command) -> Result<(), Box> { let challenge = client .post(format!("{}/challenge", host_port)) - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .send() .await? - .json::() + .json::() .await? .challenge; @@ -65,14 +65,14 @@ pub(crate) async fn list(args: &Command) -> Result<(), Box> { let access_token = client .post(format!("{}/login", host_port)) - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge, pubkey: comm_pubkey.clone(), signature: signature.to_vec(), }) .send() .await? - .json::() + .json::() .await? .access_token .to_string(); @@ -83,7 +83,7 @@ pub(crate) async fn list(args: &Command) -> Result<(), Box> { .bearer_auth(&access_token) .send() .await? - .json::() + .json::() .await?; if r.session_ids.is_empty() { @@ -93,10 +93,10 @@ pub(crate) async fn list(args: &Command) -> Result<(), Box> { let r = client .post(format!("{}/get_session_info", host_port)) .bearer_auth(&access_token) - .json(&server::GetSessionInfoArgs { session_id }) + .json(&frostd::GetSessionInfoArgs { session_id }) .send() .await? - .json::() + .json::() .await?; let coordinator = config.contact_by_pubkey(&r.coordinator_pubkey); let participants: Vec<_> = r diff --git a/server/Cargo.toml b/frostd/Cargo.toml similarity index 98% rename from server/Cargo.toml rename to frostd/Cargo.toml index 187562c0..b6115e10 100644 --- a/server/Cargo.toml +++ b/frostd/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "server" +name = "frostd" version = "0.1.0" edition = "2021" diff --git a/server/README.md b/frostd/README.md similarity index 87% rename from server/README.md rename to frostd/README.md index a336ef86..35cdcac2 100755 --- a/server/README.md +++ b/frostd/README.md @@ -18,8 +18,8 @@ You will need to have [Rust and Cargo](https://doc.rust-lang.org/cargo/getting-s To compile and run: 1. Clone the repo. Run `git clone https://github.com/ZcashFoundation/frost-zcash-demo.git` -2. Run `cargo build --release --bin server` -3. Run `./target/release/server -h` to learn about the command line arguments. +2. Run `cargo build --release --bin frostd` +3. Run `./target/release/frostd -h` to learn about the command line arguments. You will need to specify a TLS certificate and key with the `--tls-cert` and `--tls-key` arguments. diff --git a/server/build.rs b/frostd/build.rs similarity index 100% rename from server/build.rs rename to frostd/build.rs diff --git a/server/src/args.rs b/frostd/src/args.rs similarity index 100% rename from server/src/args.rs rename to frostd/src/args.rs diff --git a/server/src/functions.rs b/frostd/src/functions.rs similarity index 100% rename from server/src/functions.rs rename to frostd/src/functions.rs diff --git a/server/src/lib.rs b/frostd/src/lib.rs similarity index 100% rename from server/src/lib.rs rename to frostd/src/lib.rs diff --git a/server/src/main.rs b/frostd/src/main.rs similarity index 92% rename from server/src/main.rs rename to frostd/src/main.rs index 0da64dde..28c84200 100644 --- a/server/src/main.rs +++ b/frostd/src/main.rs @@ -1,6 +1,6 @@ use clap::Parser; -use server::args::Args; -use server::run; +use frostd::args::Args; +use frostd::run; use tracing::level_filters::LevelFilter; use tracing_subscriber::EnvFilter; diff --git a/server/src/state.rs b/frostd/src/state.rs similarity index 100% rename from server/src/state.rs rename to frostd/src/state.rs diff --git a/server/src/types.rs b/frostd/src/types.rs similarity index 100% rename from server/src/types.rs rename to frostd/src/types.rs diff --git a/server/src/user.rs b/frostd/src/user.rs similarity index 100% rename from server/src/user.rs rename to frostd/src/user.rs diff --git a/server/tests/integration_tests.rs b/frostd/tests/integration_tests.rs similarity index 89% rename from server/tests/integration_tests.rs rename to frostd/tests/integration_tests.rs index 598216d8..3e17908e 100644 --- a/server/tests/integration_tests.rs +++ b/frostd/tests/integration_tests.rs @@ -3,12 +3,12 @@ use std::{collections::BTreeMap, error::Error, time::Duration}; use axum_test::TestServer; use coordinator::comms::http::SessionState; -use rand::thread_rng; -use reqwest::Certificate; -use server::{ +use frostd::{ args::Args, router, AppState, SendCommitmentsArgs, SendSignatureSharesArgs, SendSigningPackageArgs, }; +use rand::thread_rng; +use reqwest::Certificate; use frost_core as frost; use uuid::Uuid; @@ -69,18 +69,18 @@ async fn test_main_router< let res = server .post("/challenge") - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .await; res.assert_status_ok(); - let r: server::ChallengeOutput = res.json(); + let r: frostd::ChallengeOutput = res.json(); let alice_challenge = r.challenge; let res = server .post("/challenge") - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .await; res.assert_status_ok(); - let r: server::ChallengeOutput = res.json(); + let r: frostd::ChallengeOutput = res.json(); let bob_challenge = r.challenge; let alice_private = @@ -88,14 +88,14 @@ async fn test_main_router< let alice_signature: [u8; 64] = alice_private.sign(alice_challenge.as_bytes(), &mut rng); let res = server .post("/login") - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge: alice_challenge, pubkey: alice_keypair.public.clone(), signature: alice_signature.to_vec(), }) .await; res.assert_status_ok(); - let r: server::LoginOutput = res.json(); + let r: frostd::LoginOutput = res.json(); let alice_token = r.access_token; let bob_private = @@ -103,14 +103,14 @@ async fn test_main_router< let bob_signature: [u8; 64] = bob_private.sign(bob_challenge.as_bytes(), &mut rng); let res = server .post("/login") - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge: bob_challenge, pubkey: bob_keypair.public.clone(), signature: bob_signature.to_vec(), }) .await; res.assert_status_ok(); - let r: server::LoginOutput = res.json(); + let r: frostd::LoginOutput = res.json(); let bob_token = r.access_token; let tokens = [alice_token, bob_token]; @@ -119,16 +119,16 @@ async fn test_main_router< let res = server .post("/create_new_session") .authorization_bearer(alice_token) - .json(&server::CreateNewSessionArgs { + .json(&frostd::CreateNewSessionArgs { pubkeys: vec![ - server::PublicKey(alice_keypair.public.clone()), - server::PublicKey(bob_keypair.public.clone()), + frostd::PublicKey(alice_keypair.public.clone()), + frostd::PublicKey(bob_keypair.public.clone()), ], message_count: 2, }) .await; res.assert_status_ok(); - let r: server::CreateNewSessionOutput = res.json(); + let r: frostd::CreateNewSessionOutput = res.json(); let session_id = r.session_id; // Generate commitments (one SigningCommitments for each message) @@ -144,10 +144,10 @@ async fn test_main_router< let res = server .post("/get_session_info") .authorization_bearer(token) - .json(&server::GetSessionInfoArgs { session_id }) + .json(&frostd::GetSessionInfoArgs { session_id }) .await; res.assert_status_ok(); - let r: server::GetSessionInfoOutput = res.json(); + let r: frostd::GetSessionInfoOutput = res.json(); // Generate SigningCommitments and SigningNonces for each message let mut nonces_vec = Vec::new(); @@ -170,7 +170,7 @@ async fn test_main_router< let res = server .post("/send") .authorization_bearer(token) - .json(&server::SendArgs { + .json(&frostd::SendArgs { session_id, // Empty recipients: Coordinator recipients: vec![], @@ -188,13 +188,13 @@ async fn test_main_router< let res = server .post("/receive") .authorization_bearer(alice_token) - .json(&server::ReceiveArgs { + .json(&frostd::ReceiveArgs { session_id, as_coordinator: true, }) .await; res.assert_status_ok(); - let r: server::ReceiveOutput = res.json(); + let r: frostd::ReceiveOutput = res.json(); for msg in r.msgs { coordinator_state.recv(msg)?; } @@ -239,9 +239,9 @@ async fn test_main_router< let res = server .post("/send") .authorization_bearer(alice_token) - .json(&server::SendArgs { + .json(&frostd::SendArgs { session_id, - recipients: usernames.keys().cloned().map(server::PublicKey).collect(), + recipients: usernames.keys().cloned().map(frostd::PublicKey).collect(), msg: serde_json::to_vec(&send_signing_package_args)?, }) .await; @@ -257,12 +257,12 @@ async fn test_main_router< let r = server .post("/receive") .authorization_bearer(token) - .json(&server::ReceiveArgs { + .json(&frostd::ReceiveArgs { session_id, as_coordinator: false, }) .await - .json::(); + .json::(); if r.msgs.is_empty() { tokio::time::sleep(Duration::from_secs(2)).await; } else { @@ -303,7 +303,7 @@ async fn test_main_router< let res = server .post("/send") .authorization_bearer(token) - .json(&server::SendArgs { + .json(&frostd::SendArgs { session_id, // Empty recipients: Coordinator recipients: vec![], @@ -318,12 +318,12 @@ async fn test_main_router< let r = server .post("/receive") .authorization_bearer(alice_token) - .json(&server::ReceiveArgs { + .json(&frostd::ReceiveArgs { session_id, as_coordinator: true, }) .await - .json::(); + .json::(); for msg in r.msgs { coordinator_state.recv(msg)?; } @@ -361,7 +361,7 @@ async fn test_main_router< let res = server .post("/close_session") .authorization_bearer(alice_token) - .json(&server::CloseSessionArgs { session_id }) + .json(&frostd::CloseSessionArgs { session_id }) .await; res.assert_status_ok(); @@ -402,7 +402,7 @@ async fn test_http() -> Result<(), Box> { // Spawn server for testing tokio::spawn(async move { - server::run(&Args { + frostd::run(&Args { ip: "127.0.0.1".to_string(), port: 2744, tls_cert: Some( @@ -446,13 +446,13 @@ async fn test_http() -> Result<(), Box> { // Get challenges for login let r = client .post("https://127.0.0.1:2744/challenge") - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .send() .await?; if r.status() != reqwest::StatusCode::OK { - panic!("{:?}", r.json::().await?) + panic!("{:?}", r.json::().await?) } - let r = r.json::().await?; + let r = r.json::().await?; let alice_challenge = r.challenge; // Call key_login to authenticate @@ -461,7 +461,7 @@ async fn test_http() -> Result<(), Box> { let alice_signature: [u8; 64] = alice_private.sign(alice_challenge.as_bytes(), &mut rng); let r = client .post("https://127.0.0.1:2744/login") - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge: alice_challenge, pubkey: alice_keypair.public.clone(), signature: alice_signature.to_vec(), @@ -469,28 +469,28 @@ async fn test_http() -> Result<(), Box> { .send() .await?; if r.status() != reqwest::StatusCode::OK { - panic!("{:?}", r.json::().await?) + panic!("{:?}", r.json::().await?) } - let r = r.json::().await?; + let r = r.json::().await?; let access_token = r.access_token; // Call create_new_session let r = client .post("https://127.0.0.1:2744/create_new_session") .bearer_auth(access_token) - .json(&server::CreateNewSessionArgs { + .json(&frostd::CreateNewSessionArgs { pubkeys: vec![ - server::PublicKey(alice_keypair.public.clone()), - server::PublicKey(bob_keypair.public.clone()), + frostd::PublicKey(alice_keypair.public.clone()), + frostd::PublicKey(bob_keypair.public.clone()), ], message_count: 1, }) .send() .await?; if r.status() != reqwest::StatusCode::OK { - panic!("{:?}", r.json::().await?) + panic!("{:?}", r.json::().await?) } - let r = r.json::().await?; + let r = r.json::().await?; let session_id = r.session_id; println!("Session ID: {}", session_id); @@ -501,49 +501,49 @@ async fn test_http() -> Result<(), Box> { let r = client .post("https://127.0.0.1:2744/get_session_info") .bearer_auth(access_token) - .json(&server::GetSessionInfoArgs { + .json(&frostd::GetSessionInfoArgs { session_id: wrong_session_id, }) .send() .await?; assert_eq!(r.status(), reqwest::StatusCode::INTERNAL_SERVER_ERROR); - let r = r.json::().await?; - assert_eq!(r.code, server::SESSION_NOT_FOUND); + let r = r.json::().await?; + assert_eq!(r.code, frostd::SESSION_NOT_FOUND); // Test if trying to close the session as a participant fails // Attempt to close the session as a participant (Bob) // Log in as Bob let r = client .post("https://127.0.0.1:2744/challenge") - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .send() .await?; - let r = r.json::().await?; + let r = r.json::().await?; let bob_challenge = r.challenge; let bob_private = xed25519::PrivateKey::from(&TryInto::<[u8; 32]>::try_into(bob_keypair.private).unwrap()); let bob_signature: [u8; 64] = bob_private.sign(bob_challenge.as_bytes(), &mut rng); let r = client .post("https://127.0.0.1:2744/login") - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge: bob_challenge, pubkey: bob_keypair.public.clone(), signature: bob_signature.to_vec(), }) .send() .await?; - let r = r.json::().await?; + let r = r.json::().await?; let bob_access_token = r.access_token; // Try to close the session let r = client .post("https://127.0.0.1:2744/close_session") .bearer_auth(bob_access_token) - .json(&server::CloseSessionArgs { session_id }) + .json(&frostd::CloseSessionArgs { session_id }) .send() .await?; assert_eq!(r.status(), reqwest::StatusCode::INTERNAL_SERVER_ERROR); - let r = r.json::().await?; - assert_eq!(r.code, server::NOT_COORDINATOR); + let r = r.json::().await?; + assert_eq!(r.code, frostd::NOT_COORDINATOR); Ok(()) } diff --git a/participant/Cargo.toml b/participant/Cargo.toml index 81d3a0ad..15781ff8 100644 --- a/participant/Cargo.toml +++ b/participant/Cargo.toml @@ -22,7 +22,7 @@ clap = { version = "4.5.23", features = ["derive"] } tokio = { version = "1", features = ["full"] } message-io = "0.18" reqwest = { version = "0.12.9", features = ["json"] } -server = { path = "../server" } +frostd = { path = "../frostd" } rpassword = "7.3.1" snow = "0.9.6" xeddsa = "1.0.2" diff --git a/participant/src/comms/http.rs b/participant/src/comms/http.rs index a5ca75cc..f0a076e7 100644 --- a/participant/src/comms/http.rs +++ b/participant/src/comms/http.rs @@ -111,7 +111,7 @@ pub struct HTTPComms { _phantom: PhantomData, } -use server::{SendCommitmentsArgs, SendSignatureSharesArgs, SendSigningPackageArgs, Uuid}; +use frostd::{SendCommitmentsArgs, SendSignatureSharesArgs, SendSigningPackageArgs, Uuid}; // TODO: Improve error handling for invalid session id impl HTTPComms @@ -181,10 +181,10 @@ where let challenge = self .client .post(format!("{}/challenge", self.host_port)) - .json(&server::ChallengeArgs {}) + .json(&frostd::ChallengeArgs {}) .send() .await? - .json::() + .json::() .await? .challenge; @@ -202,7 +202,7 @@ where self.access_token = Some( self.client .post(format!("{}/login", self.host_port)) - .json(&server::KeyLoginArgs { + .json(&frostd::KeyLoginArgs { challenge, pubkey: self .args @@ -213,7 +213,7 @@ where }) .send() .await? - .json::() + .json::() .await? .access_token .to_string(), @@ -229,7 +229,7 @@ where .bearer_auth(self.access_token.as_ref().expect("was just set")) .send() .await? - .json::() + .json::() .await?; if r.session_ids.len() > 1 { return Err(eyre!("user has more than one FROST session active; use `frost-client sessions` to list them and specify the session ID with `-S`").into()); @@ -257,11 +257,11 @@ where let session_info = self .client .post(format!("{}/get_session_info", self.host_port)) - .json(&server::GetSessionInfoArgs { session_id }) + .json(&frostd::GetSessionInfoArgs { session_id }) .bearer_auth(self.access_token.as_ref().expect("was just set")) .send() .await? - .json::() + .json::() .await?; let comm_coordinator_pubkey = comm_coordinator_pubkey_getter(&session_info.coordinator_pubkey).ok_or_eyre("The coordinator for the specified FROST session is not registered in the user's address book")?; @@ -299,7 +299,7 @@ where self.client .post(format!("{}/send", self.host_port)) .bearer_auth(self.access_token.as_ref().expect("was just set")) - .json(&server::SendArgs { + .json(&frostd::SendArgs { session_id, // Empty recipients: Coordinator recipients: vec![], @@ -317,13 +317,13 @@ where .client .post(format!("{}/receive", self.host_port)) .bearer_auth(self.access_token.as_ref().expect("was just set")) - .json(&server::ReceiveArgs { + .json(&frostd::ReceiveArgs { session_id, as_coordinator: false, }) .send() .await? - .json::() + .json::() .await?; if r.msgs.is_empty() { tokio::time::sleep(Duration::from_secs(2)).await; @@ -372,7 +372,7 @@ where .client .post(format!("{}/send", self.host_port)) .bearer_auth(self.access_token.as_ref().expect("must be set before")) - .json(&server::SendArgs { + .json(&frostd::SendArgs { session_id: self.session_id.unwrap(), // Empty recipients: Coordinator recipients: vec![], diff --git a/server/migrations/20240627222152_init.down.sql b/server/migrations/20240627222152_init.down.sql deleted file mode 100644 index 3dc5b147..00000000 --- a/server/migrations/20240627222152_init.down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add down migration script here -drop table if exists users; -drop table if exists access_tokens; \ No newline at end of file diff --git a/server/migrations/20240627222152_init.up.sql b/server/migrations/20240627222152_init.up.sql deleted file mode 100644 index 650f0da6..00000000 --- a/server/migrations/20240627222152_init.up.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Create users table. -create table if not exists users -( - id integer primary key not null, - username text not null unique, - password text not null, - pubkey blob not null -); - -create table if not exists access_tokens -( - id integer primary key not null, - user_id integer not null, - access_token blob not null, - foreign key(user_id) references users(id) on delete cascade -); \ No newline at end of file diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 9efc02ec..e93b9c88 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -18,7 +18,7 @@ dkg = { path = "../dkg"} trusted-dealer = { path = "../trusted-dealer"} participant = { path = "../participant"} coordinator = { path = "../coordinator"} -server = { path = "../server"} +frostd = { path = "../frostd"} rand = "0.8" [features]