#[non_exhaustive]pub struct SignedMessage;Expand description
Ed25519-signed gossip envelope that prevents identity spoofing.
Wire format: [verifying_key: 32 bytes][signature: 64 bytes][content: N bytes]
Since iroh’s PublicKey (NodeId) is an Ed25519 VerifyingKey, a valid
signature cryptographically proves the message originated from the claimed
NodeId.
Implementations§
Source§impl SignedMessage
impl SignedMessage
Sourcepub fn sign(secret_key: &SigningKey, content: &[u8]) -> Vec<u8> ⓘ
pub fn sign(secret_key: &SigningKey, content: &[u8]) -> Vec<u8> ⓘ
Sign content with the node’s Ed25519 secret key.
Returns the serialized wire format:
[verifying_key: 32B][signature: 64B][content].
Sourcepub fn verify(wire_bytes: &[u8]) -> Result<(VerifyingKey, Vec<u8>)>
pub fn verify(wire_bytes: &[u8]) -> Result<(VerifyingKey, Vec<u8>)>
Verify a wire-format signed message and extract the original content.
Returns (verifying_key, content_bytes) on success.
§Errors
Returns an error if the message is shorter than 96 bytes, the signature is invalid, or the key bytes do not represent a valid Ed25519 public key.
Sourcepub fn verify_with_expected(
wire_bytes: &[u8],
expected_node_id: &PublicKey,
) -> Result<Vec<u8>>
pub fn verify_with_expected( wire_bytes: &[u8], expected_node_id: &PublicKey, ) -> Result<Vec<u8>>
Verify a wire-format message and check that the embedded NodeId matches
the signing key. This is a convenience wrapper around [verify].
§Errors
Returns an error if verification fails or the NodeId does not match.
Sourcepub const fn header_len() -> usize
pub const fn header_len() -> usize
The length of the signing header in bytes.
Trait Implementations§
Source§impl Clone for SignedMessage
impl Clone for SignedMessage
Source§fn clone(&self) -> SignedMessage
fn clone(&self) -> SignedMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SignedMessage
Auto Trait Implementations§
impl Freeze for SignedMessage
impl RefUnwindSafe for SignedMessage
impl Send for SignedMessage
impl Sync for SignedMessage
impl Unpin for SignedMessage
impl UnsafeUnpin for SignedMessage
impl UnwindSafe for SignedMessage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more