Struct SignedEnvelope
pub struct SignedEnvelope { /* private fields */ }
Expand description
A signed envelope contains an arbitrary byte string payload, a signature of the payload, and the public key that can be used to verify the signature.
For more details see libp2p RFC0002: https://github.com/libp2p/specs/blob/master/RFC/0002-signed-envelopes.md
Implementations§
§impl SignedEnvelope
impl SignedEnvelope
pub fn new(
key: &Keypair,
domain_separation: String,
payload_type: Vec<u8>,
payload: Vec<u8>,
) -> Result<SignedEnvelope, SigningError>
pub fn new( key: &Keypair, domain_separation: String, payload_type: Vec<u8>, payload: Vec<u8>, ) -> Result<SignedEnvelope, SigningError>
Constructs a new SignedEnvelope
.
pub fn verify(&self, domain_separation: String) -> bool
pub fn verify(&self, domain_separation: String) -> bool
Verify this SignedEnvelope
against the provided domain-separation string.
pub fn payload_and_signing_key(
&self,
domain_separation: String,
expected_payload_type: &[u8],
) -> Result<(&[u8], &PublicKey), ReadPayloadError>
pub fn payload_and_signing_key( &self, domain_separation: String, expected_payload_type: &[u8], ) -> Result<(&[u8], &PublicKey), ReadPayloadError>
Extract the payload and signing key of this SignedEnvelope
.
You must provide the correct domain-separation string and expected payload type in order to get the payload. This guards against accidental mis-use of the payload where the signature was created for a different purpose or payload type.
It is the caller’s responsibility to check that the signing key is what is expected. For example, checking that the signing key is from a certain peer.
pub fn into_protobuf_encoding(self) -> Vec<u8> ⓘ
pub fn into_protobuf_encoding(self) -> Vec<u8> ⓘ
Encode this SignedEnvelope
using the protobuf encoding specified in the RFC.
pub fn from_protobuf_encoding(
bytes: &[u8],
) -> Result<SignedEnvelope, DecodingError>
pub fn from_protobuf_encoding( bytes: &[u8], ) -> Result<SignedEnvelope, DecodingError>
Decode a SignedEnvelope
using the protobuf encoding specified in the RFC.
Trait Implementations§
§impl Clone for SignedEnvelope
impl Clone for SignedEnvelope
§fn clone(&self) -> SignedEnvelope
fn clone(&self) -> SignedEnvelope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for SignedEnvelope
impl Debug for SignedEnvelope
§impl PartialEq for SignedEnvelope
impl PartialEq for SignedEnvelope
impl Eq for SignedEnvelope
impl StructuralPartialEq for SignedEnvelope
Auto Trait Implementations§
impl Freeze for SignedEnvelope
impl RefUnwindSafe for SignedEnvelope
impl Send for SignedEnvelope
impl Sync for SignedEnvelope
impl Unpin for SignedEnvelope
impl UnwindSafe for SignedEnvelope
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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