Skip to content

Commit

Permalink
Add binary encoding (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryardley authored Aug 26, 2024
1 parent 31d6872 commit e277f4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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

0 comments on commit e277f4c

Please sign in to comment.