Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnclaveEvent binary encoding #16

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/ciphernode/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 packages/ciphernode/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ tokio = { version = "1.39.3", features = ["full"] }
sha2 = "0.10.8"
bs58 = "0.5.1"
serde = { version = "1.0.208", features = ["derive"] }
bincode = "1.3.3"

13 changes: 12 additions & 1 deletion packages/ciphernode/core/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use actix::Message;
use bincode;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::{
Expand Down Expand Up @@ -64,6 +65,16 @@ pub enum EnclaveEvent {
// CiphernodeDeregistered,
}

impl EnclaveEvent {
pub fn to_bytes(&self) -> Result<Vec<u8>, bincode::Error> {
bincode::serialize(self)
}

pub fn from_bytes(bytes: &[u8]) -> Result<Self, bincode::Error> {
bincode::deserialize(bytes)
}
}

impl From<EnclaveEvent> for EventId {
fn from(value: EnclaveEvent) -> Self {
match value {
Expand Down Expand Up @@ -115,7 +126,7 @@ pub struct PublicKeyAggregated {
pub e3_id: E3id,
}

#[derive(Message, Clone, Debug, PartialEq, Eq, Hash, Serialize,Deserialize)]
#[derive(Message, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[rtype(result = "()")]
pub struct ComputationRequested {
pub e3_id: E3id,
Expand Down
Loading