-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support receiving own proposals without an error
- Loading branch information
mulmarta
committed
May 2, 2024
1 parent
3662e44
commit cc7489e
Showing
11 changed files
with
200 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use alloc::vec::Vec; | ||
use core::fmt; | ||
use core::fmt::Debug; | ||
|
||
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize}; | ||
use mls_rs_core::crypto::CipherSuiteProvider; | ||
|
||
use crate::{client::MlsError, error::IntoAnyError, MlsMessage}; | ||
|
||
#[derive(Clone, PartialEq, Eq, MlsEncode, MlsDecode, MlsSize)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
pub(crate) struct MessageHash( | ||
#[mls_codec(with = "mls_rs_codec::byte_vec")] | ||
#[cfg_attr(feature = "serde", serde(with = "mls_rs_core::vec_serde"))] | ||
Vec<u8>, | ||
); | ||
|
||
impl Debug for MessageHash { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
mls_rs_core::debug::pretty_bytes(&self.0) | ||
.named("CommitHash") | ||
.fmt(f) | ||
} | ||
} | ||
|
||
impl MessageHash { | ||
#[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)] | ||
pub(crate) async fn compute<CS: CipherSuiteProvider>( | ||
cs: &CS, | ||
message: &MlsMessage, | ||
) -> Result<Self, MlsError> { | ||
cs.hash(&message.mls_encode_to_vec()?) | ||
.await | ||
.map_err(|e| MlsError::CryptoProviderError(e.into_any_error())) | ||
.map(Self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.