Skip to content

Commit

Permalink
Move mpc_protocol dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Nov 30, 2023
1 parent 22474f0 commit 84a5fad
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test-utils = ["sos-net/test-utils"]

[workspace.dependencies]
csv-async = { version = "1", features = ["tokio", "with_serde"] }
mpc-protocol = "0.4.1"

[workspace.dependencies.binary-stream]
version = "8.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use futures::stream::StreamExt;
use sos_net::{
client::{changes, connect, Origin},
mpc::{generate_keypair, Keypair},
sdk::{
account::AccountRef, hex, mpc::generate_keypair, mpc::Keypair,
signer::ecdsa::BoxedEcdsaSigner, url::Url,
account::AccountRef, hex, signer::ecdsa::BoxedEcdsaSigner, url::Url,
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn print_events<T: Default + Encodable + Decodable + LogEvent>(
} else {
event_log.iter().await?
};

let version = event_log.read_file_version().await?;
let mut count = 0;
let divider = "-".repeat(80);
Expand Down
5 changes: 2 additions & 3 deletions src/commands/generate_keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use std::path::PathBuf;
//use tokio::{fs, io::AsyncWriteExt};

use crate::{Error, Result};
use sos_net::sdk::{
hex,
use sos_net::{
mpc::{encode_keypair, generate_keypair},
vfs,
sdk::{hex, vfs},
};

/// Generate keypair and write to file.
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub enum Error {
Clipboard(#[from] arboard::Error),

#[error(transparent)]
Mpc(#[from] sos_net::sdk::mpc::Error),
Mpc(#[from] sos_net::mpc::Error),

#[error(transparent)]
Hex(#[from] sos_net::sdk::hex::FromHexError),
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/rpc/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use anyhow::Result;
use http::StatusCode;
use sos_net::{
client::RpcClient,
sdk::{encode, mpc::generate_keypair, vault::Vault},
mpc::generate_keypair,
sdk::{encode, vault::Vault},
};

const TEST_ID: &str = "rpc_session";
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use web3_address::ethereum::Address;

use sos_net::{
client::{NetworkAccount, Origin, RemoteBridge, RemoteSync},
mpc::{Keypair, PATTERN},
sdk::{
account::FolderStorage,
crypto::AccessKey,
events::AuditLogFile,
hex,
mpc::{Keypair, PATTERN},
passwd::diceware::generate_passphrase,
signer::ecdsa::{BoxedEcdsaSigner, SingleParty},
vault::{secret::SecretId, Summary},
Expand Down
1 change: 1 addition & 0 deletions workspace/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mem-fs = ["sos-sdk/mem-fs"]
test-utils = ["sos-sdk/test-utils"]

[dependencies]
mpc-protocol.workspace = true
thiserror = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
Expand Down
2 changes: 1 addition & 1 deletion workspace/net/src/client/account/network_account.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Network aware account.
use mpc_protocol::generate_keypair;
use secrecy::SecretString;
use sos_sdk::{
account::{
Expand All @@ -12,7 +13,6 @@ use sos_sdk::{
commit::{CommitHash, CommitState},
crypto::AccessKey,
events::{Event, ReadEvent},
mpc::generate_keypair,
signer::ecdsa::Address,
vault::{
secret::{Secret, SecretId, SecretMeta, SecretRow},
Expand Down
2 changes: 1 addition & 1 deletion workspace/net/src/client/account/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ use sos_sdk::{
crypto::SecureAccessKey,
decode,
events::{Event, Patch, WriteEvent},
mpc::Keypair,
signer::ecdsa::BoxedEcdsaSigner,
url::Url,
vault::{Summary, VaultId},
vfs,
};

use mpc_protocol::Keypair;
use std::{any::Any, collections::HashMap, fmt, sync::Arc};
use tokio::sync::RwLock;

Expand Down
4 changes: 2 additions & 2 deletions workspace/net/src/client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ pub enum Error {

/// Error generated by the MPC library.
#[error(transparent)]
Mpc(#[from] sos_sdk::mpc::Error),
Mpc(#[from] mpc_protocol::Error),

/// Error generated by the noise library.
#[error(transparent)]
Snow(#[from] sos_sdk::mpc::snow::Error),
Snow(#[from] mpc_protocol::snow::Error),

/// Error generated sending a secure access key
/// from a remote provider to the account storage.
Expand Down
11 changes: 6 additions & 5 deletions workspace/net/src/client/net/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ use sos_sdk::{
crypto::SecureAccessKey,
decode, encode,
events::Patch,
mpc::{
channel::{decrypt_server_channel, encrypt_server_channel},
snow, Keypair, ProtocolState, PATTERN,
},
signer::ecdsa::BoxedEcdsaSigner,
vault::{Summary, VaultId},
};

use mpc_protocol::{
channel::{decrypt_server_channel, encrypt_server_channel},
snow, Keypair, ProtocolState, PATTERN,
};
//use tracing::{span, Level};

#[cfg(feature = "listen")]
Expand Down Expand Up @@ -649,7 +650,7 @@ impl RpcClient {
let message: ServerEnvelope = decode(buffer).await?;
let (encoding, buffer) =
decrypt_server_channel(protocol, message.envelope).await?;
assert!(matches!(encoding, sos_sdk::mpc::Encoding::Blob));
assert!(matches!(encoding, mpc_protocol::Encoding::Blob));
Ok(buffer)
}
}
Expand Down
7 changes: 2 additions & 5 deletions workspace/net/src/client/net/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ use tokio::{
};
use url::Url;

use sos_sdk::{
events::ChangeNotification,
mpc::{generate_keypair, Keypair},
signer::ecdsa::BoxedEcdsaSigner,
};
use mpc_protocol::{generate_keypair, Keypair};
use sos_sdk::{events::ChangeNotification, signer::ecdsa::BoxedEcdsaSigner};

use crate::client::{Origin, Result, RpcClient};

Expand Down
2 changes: 1 addition & 1 deletion workspace/net/src/encoding/v1/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use std::{borrow::Cow, io::Result};

use sos_sdk::{
constants::RPC_IDENTITY, encoding::encoding_error, formats::FileIdentity,
mpc::SealedEnvelope,
};

use async_trait::async_trait;
use binary_stream::futures::{
BinaryReader, BinaryWriter, Decodable, Encodable,
};
use futures::io::{AsyncRead, AsyncSeek, AsyncWrite};
use mpc_protocol::SealedEnvelope;

use crate::rpc::{
Error, Packet, Payload, RequestMessage, ResponseMessage, ServerEnvelope,
Expand Down
1 change: 1 addition & 0 deletions workspace/net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ pub use sos_migrate as migrate;
#[cfg(feature = "client")]
pub use reqwest;

pub use mpc_protocol as mpc;
pub use sos_sdk as sdk;
2 changes: 1 addition & 1 deletion workspace/net/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Message identifiers have the same semantics as JSON-RPC;
//! if a request does not have an `id` than no reply is expected
//! otherwise a service must reply.
use sos_sdk::mpc::SealedEnvelope;
use mpc_protocol::SealedEnvelope;

use http::StatusCode;
use serde::{de::DeserializeOwned, Serialize};
Expand Down
6 changes: 2 additions & 4 deletions workspace/net/src/server/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use url::{Host, Url};
use super::backend::{Backend, FileSystemBackend};
use super::{Error, Result};

use sos_sdk::{
mpc::{decode_keypair, Keypair},
vfs,
};
use mpc_protocol::{decode_keypair, Keypair};
use sos_sdk::vfs;

/// Configuration for the web server.
#[derive(Default, Debug, Serialize, Deserialize)]
Expand Down
8 changes: 4 additions & 4 deletions workspace/net/src/server/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ pub enum Error {
#[error(transparent)]
Address(#[from] web3_address::Error),

/// Error generated by the MPC protocol library.
/// Error generated by the noise protocol library.
#[error(transparent)]
Mpc(#[from] sos_sdk::mpc::Error),
Snow(#[from] mpc_protocol::snow::Error),

/// Error generated by the noise protocol library.
/// Error generated by the MPC protocol library.
#[error(transparent)]
Snow(#[from] sos_sdk::mpc::snow::Error),
Mpc(#[from] mpc_protocol::Error),
}

impl Error {
Expand Down
3 changes: 2 additions & 1 deletion workspace/net/src/server/handlers/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use tokio::sync::{
mpsc,
};

use sos_sdk::{encode, mpc::channel::encrypt_server_channel};
use mpc_protocol::channel::encrypt_server_channel;
use sos_sdk::encode;
use tracing::{span, Level};
use web3_address::ethereum::Address;

Expand Down
4 changes: 3 additions & 1 deletion workspace/net/src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ use axum::{
};
use axum_server::{tls_rustls::RustlsConfig, Handle};
use futures::StreamExt;
use mpc_protocol::Keypair;
use serde::{Deserialize, Serialize};
use sos_sdk::{events::AuditLogFile, mpc::Keypair};
use sos_sdk::events::AuditLogFile;

use std::time::Duration;
use std::{collections::HashMap, net::SocketAddr, sync::Arc};
use tokio::sync::{RwLock, RwLockReadGuard};
Expand Down
6 changes: 2 additions & 4 deletions workspace/net/src/server/services/handshake.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use sos_sdk::{
constants::HANDSHAKE_INITIATE,
mpc::{snow, ProtocolState, PATTERN},
};
use sos_sdk::constants::HANDSHAKE_INITIATE;

use super::Service;
use crate::{
Expand All @@ -10,6 +7,7 @@ use crate::{
};
use async_trait::async_trait;
use axum::http::StatusCode;
use mpc_protocol::{snow, ProtocolState, PATTERN};
use std::borrow::Cow;

/// Handshake service.
Expand Down
4 changes: 2 additions & 2 deletions workspace/net/src/server/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use axum::{
};

use async_trait::async_trait;
use mpc_protocol::channel::{decrypt_server_channel, encrypt_server_channel};
use sos_sdk::{
constants::MIME_TYPE_RPC,
decode, encode,
events::{AuditEvent, AuditProvider, ChangeNotification},
mpc::channel::{decrypt_server_channel, encrypt_server_channel},
};
use web3_address::ethereum::Address;

Expand Down Expand Up @@ -192,7 +192,7 @@ pub(crate) async fn private_service(
)
.await?;

assert!(matches!(encoding, sos_sdk::mpc::Encoding::Blob));
assert!(matches!(encoding, mpc_protocol::Encoding::Blob));

// Parse the bearer token
let token = authenticate::bearer(bearer, &body)
Expand Down
2 changes: 1 addition & 1 deletion workspace/net/src/server/transports.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Manages noise protocol transports with client connections.
use sos_sdk::mpc::ProtocolState;
use mpc_protocol::ProtocolState;
use std::{
collections::HashMap,
time::{Duration, Instant},
Expand Down
1 change: 0 additions & 1 deletion workspace/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async_zip = { version = "0.0.15", default-features = false, features = ["deflate
sanitize-filename = "0.4"
tokio-util = { version = "0.7", default-features = false, features = ["compat"] }
futures-util = "0.3"
mpc-protocol = "0.4.1"

vsss-rs = {version = "3", optional = true }

Expand Down
8 changes: 0 additions & 8 deletions workspace/sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,6 @@ pub enum Error {
#[error(transparent)]
Join(#[from] tokio::task::JoinError),

/// Error generated by the MPC protocol library.
#[error(transparent)]
Mpc(#[from] mpc_protocol::Error),

/// Error generated by the noise protocol library.
#[error(transparent)]
Snow(#[from] mpc_protocol::snow::Error),

/// Error generated by verifiable secret sharing library.
#[error("vss error: {0}")]
Vsss(String),
Expand Down
Loading

0 comments on commit 84a5fad

Please sign in to comment.