Skip to content

Commit

Permalink
Merge pull request #1 from dufkan/main
Browse files Browse the repository at this point in the history
chore: sync protobuf
  • Loading branch information
KristianMika committed May 21, 2024
2 parents d3784c2 + 2f7943d commit 67ac68c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::io::Write;
use std::path::{Path, PathBuf};

static PROTO_INPUT_DIRECTORY: &str = "proto";
static PROTO_INPUT_FILE: &str = "mpc.proto";
static PROTO_INPUT_FILE: &str = "meesign.proto";
static PKCS_11_SPEC_VERSION: &str = "v3.0";
static PKCS_11_HEADERS_DIRECTORY: &str = "PKCS11-SPECS";
static PKCS_11_WRAPPER_HEADER: &str = "wrapper.h";
Expand Down
51 changes: 28 additions & 23 deletions proto/mpc.proto → proto/meesign.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
syntax = "proto3";
package meesign;

service MPC {
service MeeSign {
rpc GetServerInfo(ServerInfoRequest) returns (ServerInfo);
rpc Register(RegistrationRequest) returns (RegistrationResponse);
rpc Sign(SignRequest) returns (Task);
rpc Group(GroupRequest) returns (Task);
rpc Decrypt(DecryptRequest) returns (Task);
rpc GetTask(TaskRequest) returns (Task);
rpc UpdateTask(TaskUpdate) returns (Resp); // auth required
rpc DecideTask(TaskDecision) returns (Resp); // auth required
Expand All @@ -25,22 +26,32 @@ message ServerInfo {

enum ProtocolType {
GG18 = 0;
ELGAMAL = 1;
FROST = 2;
}

enum KeyType {
SignPDF = 0;
SignChallenge = 1;
Decrypt = 2;
}

enum TaskType {
GROUP = 0;
SIGN_PDF = 1;
SIGN_CHALLENGE = 2;
DECRYPT = 3;
}

enum DeviceKind {
USER = 0;
BOT = 1;
}

message RegistrationRequest {
string name = 1;
bytes csr = 2; // CSR in DER format
DeviceKind kind = 2;
bytes csr = 3; // CSR in DER format
}

message RegistrationResponse {
Expand All @@ -54,6 +65,7 @@ message GroupRequest {
uint32 threshold = 3;
ProtocolType protocol = 4;
KeyType key_type = 5;
optional string note = 6;
}

message Group {
Expand All @@ -63,6 +75,7 @@ message Group {
ProtocolType protocol = 4;
KeyType key_type = 5;
repeated bytes device_ids = 6;
optional string note = 7;
}

message DevicesRequest {
Expand All @@ -76,8 +89,9 @@ message Devices {
message Device {
bytes identifier = 1;
string name = 2;
bytes certificate = 3;
uint64 last_active = 4;
DeviceKind kind = 3;
bytes certificate = 4;
uint64 last_active = 5;
}

message SignRequest {
Expand All @@ -86,6 +100,13 @@ message SignRequest {
bytes data = 3;
}

message DecryptRequest {
string name = 1;
bytes group_id = 2;
bytes data = 3;
string data_type = 4; // MIME type of the encrypted data
}

message TaskRequest {
bytes task_id = 1;
optional bytes device_id = 2;
Expand All @@ -105,13 +126,13 @@ message Task {
uint32 attempt = 5;
uint32 accept = 6; // Number of task accepts
uint32 reject = 7; // Number of task rejects
optional bytes data = 8; // If present, the task is waiting for recipient's action
repeated bytes data = 8; // If present, the task is waiting for recipient's action; in case a given device controls multiple shares, multiple inputs are sent, ordered by share indices
optional bytes request = 9; // Serialized SignRequest or TaskRequest; present only when queried directly
}

message TaskUpdate {
bytes task = 1;
bytes data = 2;
repeated bytes data = 2; // In case a given device controls multiple shares, send responses ordered by share indices
uint32 attempt = 3;
}

Expand Down Expand Up @@ -148,20 +169,4 @@ message LogRequest {
string message = 1;
};

message SubscribeRequest {};

message GG18KeyGenInit {
uint32 index = 1;
uint32 parties = 2;
uint32 threshold = 3;
}

message GG18SignInit {
repeated uint32 indices = 1;
uint32 index = 2;
bytes hash = 3;
}

message GG18Message {
repeated bytes message = 1;
}
message SubscribeRequest {};
8 changes: 4 additions & 4 deletions src/communicator/meesign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tonic::{

use std::{str::FromStr, time::Duration};

use crate::communicator::meesign::proto::{mpc_client::MpcClient, GroupsRequest, KeyType};
use crate::communicator::meesign::proto::{mee_sign_client::MeeSignClient, GroupsRequest, KeyType};
use crate::communicator::AuthResponse;

use self::proto::{task::TaskState, SignRequest, TaskRequest};
Expand All @@ -24,7 +24,7 @@ static ATTEMPT_SLEEP_SEC: u64 = 3;

/// Communicates with the MeeSign server
pub(crate) struct Meesign {
client: MpcClient<Channel>,
client: MeeSignClient<Channel>,
}

impl Meesign {
Expand All @@ -41,7 +41,7 @@ impl Meesign {
.tls_config(client_tls_config)?
.connect()
.await?;
let client = MpcClient::new(channel);
let client = MeeSignClient::new(channel);
Ok(Self { client })
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Communicator for Meesign {
});
let response = self.client.get_task(request).await?;
if response.get_ref().state == TaskState::Finished as i32 {
return Ok(response.get_ref().data.to_owned());
return Ok(response.get_ref().data.get(0).cloned());
}
if response.get_ref().state == TaskState::Failed as i32 {
return Err(CommunicatorError::TaskFailed);
Expand Down

0 comments on commit 67ac68c

Please sign in to comment.