Skip to content

Commit

Permalink
Merge pull request #29 from fjarri/serde-bytes
Browse files Browse the repository at this point in the history
Use `serde-encoded-bytes` instead of the vendored module
  • Loading branch information
fjarri authored Oct 16, 2024
2 parents 336d89f + 63570e3 commit 6bf0d84
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 56 deletions.
1 change: 1 addition & 0 deletions manul/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ categories = ["cryptography", "no-std"]

[dependencies]
serde = { version = "1", default-features = false, features = ["alloc", "serde_derive"] }
serde-encoded-bytes = { version = "0.1", default-features = false, features = ["base64"] }
digest = { version = "0.10", default-features = false }
signature = { version = "2", default-features = false, features = ["digest", "rand_core"] }
rand_core = { version = "0.6.4", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion manul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
extern crate alloc;

pub mod protocol;
mod serde_bytes;
pub mod session;
pub mod testing;
10 changes: 4 additions & 6 deletions manul/src/protocol/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ use core::{any::Any, fmt::Debug};
use digest::Digest;
use rand_core::CryptoRngCore;
use serde::{Deserialize, Serialize};
use serde_encoded_bytes::{Base64, SliceLike};

use super::{
error::{LocalError, RemoteError},
object_safe::{ObjectSafeRound, ObjectSafeRoundWrapper},
};
use crate::{
serde_bytes,
session::{EchoRoundError, SessionId},
};
use crate::session::{EchoRoundError, SessionId};

/// An error that can be returned from [`Round::receive_message`].
#[derive(Debug)]
Expand Down Expand Up @@ -383,7 +381,7 @@ pub struct EchoBroadcastError(DeserializationError);

/// A serialized direct message.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DirectMessage(#[serde(with = "serde_bytes")] Box<[u8]>);
pub struct DirectMessage(#[serde(with = "SliceLike::<Base64>")] Box<[u8]>);

impl DirectMessage {
/// Creates a new serialized direct message.
Expand Down Expand Up @@ -412,7 +410,7 @@ impl DirectMessage {

/// A serialized echo broadcast.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct EchoBroadcast(#[serde(with = "serde_bytes")] Box<[u8]>);
pub struct EchoBroadcast(#[serde(with = "SliceLike::<Base64>")] Box<[u8]>);

impl EchoBroadcast {
/// Creates a new serialized echo broadcast.
Expand Down
42 changes: 0 additions & 42 deletions manul/src/serde_bytes.rs

This file was deleted.

12 changes: 5 additions & 7 deletions manul/src/session/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use core::fmt::Debug;

use rand_core::CryptoRngCore;
use serde::{Deserialize, Serialize};
use serde_encoded_bytes::{Base64, SliceLike};
use signature::{DigestVerifier, Keypair, RandomizedDigestSigner};
use tracing::debug;

Expand All @@ -18,17 +19,14 @@ use super::{
transcript::{SessionOutcome, SessionReport, Transcript},
LocalError, RemoteError,
};
use crate::{
protocol::{
Artifact, DirectMessage, EchoBroadcast, FinalizeError, FinalizeOutcome, FirstRound, ObjectSafeRound,
ObjectSafeRoundWrapper, Payload, Protocol, ReceiveError, ReceiveErrorType, Round, RoundId,
},
serde_bytes,
use crate::protocol::{
Artifact, DirectMessage, EchoBroadcast, FinalizeError, FinalizeOutcome, FirstRound, ObjectSafeRound,
ObjectSafeRoundWrapper, Payload, Protocol, ReceiveError, ReceiveErrorType, Round, RoundId,
};

/// A session identifier shared between the parties.
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct SessionId(#[serde(with = "serde_bytes")] Box<[u8]>);
pub struct SessionId(#[serde(with = "SliceLike::<Base64>")] Box<[u8]>);

/// A session ID.
///
Expand Down

0 comments on commit 6bf0d84

Please sign in to comment.