Struct Ed25519Identity
pub struct Ed25519Identity {
id: CtByteArray<tor_llcrypto::::pk::ed25519::Ed25519Identity::{constant#0}>,
}
Expand description
An unchecked, unvalidated Ed25519 key.
This key is an “identity” in the sense that it identifies (up to) one Ed25519 key. It may also represent the identity for a particular entity, such as a relay or an onion service.
This type is distinct from an Ed25519 PublicKey
for several reasons:
- We’re storing it in a compact format, whereas the public key implementation might want an expanded form for more efficient key validation.
- This type hasn’t checked whether the bytes here actually are a valid Ed25519 public key.
Fields§
§id: CtByteArray<tor_llcrypto::::pk::ed25519::Ed25519Identity::{constant#0}>
Implementations§
§impl Ed25519Identity
impl Ed25519Identity
pub fn new(id: [u8; 32]) -> Ed25519Identity
pub fn new(id: [u8; 32]) -> Ed25519Identity
Construct a new Ed25519 identity from a 32-byte sequence.
This might or might not actually be a valid Ed25519 public key.
use tor_llcrypto::pk::ed25519::{Ed25519Identity, PublicKey};
let bytes = b"klsadjfkladsfjklsdafkljasdfsdsd!";
let id = Ed25519Identity::new(*bytes);
let pk: Result<PublicKey,_> = (&id).try_into();
assert!(pk.is_ok());
let bytes = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
let id = Ed25519Identity::new(*bytes);
let pk: Result<PublicKey,_> = (&id).try_into();
assert!(pk.is_err());
pub fn from_bytes(id: &[u8]) -> Option<Ed25519Identity>
pub fn from_bytes(id: &[u8]) -> Option<Ed25519Identity>
If id
is of the correct length, wrap it in an Ed25519Identity.
Trait Implementations§
§impl Clone for Ed25519Identity
impl Clone for Ed25519Identity
§fn clone(&self) -> Ed25519Identity
fn clone(&self) -> Ed25519Identity
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl ConstantTimeEq for Ed25519Identity
impl ConstantTimeEq for Ed25519Identity
§impl Debug for Ed25519Identity
impl Debug for Ed25519Identity
§impl<'de> Deserialize<'de> for Ed25519Identity
impl<'de> Deserialize<'de> for Ed25519Identity
§fn deserialize<D>(
deserializer: D,
) -> Result<Ed25519Identity, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Ed25519Identity, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Display for Ed25519Identity
impl Display for Ed25519Identity
§impl From<&PublicKey> for Ed25519Identity
impl From<&PublicKey> for Ed25519Identity
§fn from(pk: &PublicKey) -> Ed25519Identity
fn from(pk: &PublicKey) -> Ed25519Identity
Converts to this type from the input type.
§impl From<[u8; 32]> for Ed25519Identity
impl From<[u8; 32]> for Ed25519Identity
§fn from(id: [u8; 32]) -> Ed25519Identity
fn from(id: [u8; 32]) -> Ed25519Identity
Converts to this type from the input type.
§impl From<Ed25519Identity> for [u8; 32]
impl From<Ed25519Identity> for [u8; 32]
§fn from(value: Ed25519Identity) -> [u8; 32]
fn from(value: Ed25519Identity) -> [u8; 32]
Converts to this type from the input type.
Source§impl From<Ed25519Identity> for HsBlindId
impl From<Ed25519Identity> for HsBlindId
Source§fn from(value: Ed25519Identity) -> HsBlindId
fn from(value: Ed25519Identity) -> HsBlindId
Converts to this type from the input type.
Source§impl From<Ed25519Public> for Ed25519Identity
impl From<Ed25519Public> for Ed25519Identity
Source§fn from(pk: Ed25519Public) -> Ed25519Identity
fn from(pk: Ed25519Public) -> Ed25519Identity
Converts to this type from the input type.
§impl From<PublicKey> for Ed25519Identity
impl From<PublicKey> for Ed25519Identity
§fn from(pk: PublicKey) -> Ed25519Identity
fn from(pk: PublicKey) -> Ed25519Identity
Converts to this type from the input type.
§impl HasMemoryCostStructural for Ed25519Identity
impl HasMemoryCostStructural for Ed25519Identity
§fn indirect_memory_cost(&self, et: EnabledToken) -> usize
fn indirect_memory_cost(&self, et: EnabledToken) -> usize
Memory cost of data stored out-of-line Read more
§impl Hash for Ed25519Identity
impl Hash for Ed25519Identity
§impl Ord for Ed25519Identity
impl Ord for Ed25519Identity
§impl PartialEq for Ed25519Identity
impl PartialEq for Ed25519Identity
§impl PartialOrd for Ed25519Identity
impl PartialOrd for Ed25519Identity
§impl Readable for Ed25519Identity
impl Readable for Ed25519Identity
§fn take_from(b: &mut Reader<'_>) -> Result<Ed25519Identity, Error>
fn take_from(b: &mut Reader<'_>) -> Result<Ed25519Identity, Error>
Try to extract an object of this type from a Reader. Read more
§impl Redactable for Ed25519Identity
impl Redactable for Ed25519Identity
§fn display_redacted(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn display_redacted(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Warning: This displays 12 bits of the ed25519 identity, which is enough to narrow down a public relay by a great deal.
§fn debug_redacted(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug_redacted(&self, f: &mut Formatter<'_>) -> Result<(), Error>
As
Debug::fmt
, but produce a redacted representation.§fn redacted(&self) -> Redacted<&Self>
fn redacted(&self) -> Redacted<&Self>
Return a smart pointer that will display or debug this object as its
redacted form.
§fn maybe_redacted(&self, redact: bool) -> MaybeRedacted<&Self>
fn maybe_redacted(&self, redact: bool) -> MaybeRedacted<&Self>
Return a smart pointer that redacts this object if
redact
is true.§impl Serialize for Ed25519Identity
impl Serialize for Ed25519Identity
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
§impl TryFrom<&Ed25519Identity> for PublicKey
impl TryFrom<&Ed25519Identity> for PublicKey
§impl TryFrom<Ed25519Identity> for PublicKey
impl TryFrom<Ed25519Identity> for PublicKey
Source§impl<'a> TryFrom<RelayIdRef<'a>> for &'a Ed25519Identity
impl<'a> TryFrom<RelayIdRef<'a>> for &'a Ed25519Identity
Source§type Error = TryIntoError<RelayIdRef<'a>>
type Error = TryIntoError<RelayIdRef<'a>>
The type returned in the event of a conversion error.
Source§fn try_from(
value: RelayIdRef<'a>,
) -> Result<&'a Ed25519Identity, TryIntoError<RelayIdRef<'a>>>
fn try_from( value: RelayIdRef<'a>, ) -> Result<&'a Ed25519Identity, TryIntoError<RelayIdRef<'a>>>
Performs the conversion.
§impl Writeable for Ed25519Identity
impl Writeable for Ed25519Identity
impl Copy for Ed25519Identity
impl Eq for Ed25519Identity
impl StructuralPartialEq for Ed25519Identity
Auto Trait Implementations§
impl Freeze for Ed25519Identity
impl RefUnwindSafe for Ed25519Identity
impl Send for Ed25519Identity
impl Sync for Ed25519Identity
impl Unpin for Ed25519Identity
impl UnwindSafe for Ed25519Identity
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> 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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
Checks if this value is equivalent to the given key. Read more
§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
Compare self to
key
and return true
if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> HasMemoryCost for Twhere
T: HasMemoryCostStructural,
impl<T> HasMemoryCost for Twhere
T: HasMemoryCostStructural,
§fn memory_cost(&self, et: EnabledToken) -> usize
fn memory_cost(&self, et: EnabledToken) -> usize
Returns the memory cost of
self
, in bytes Read more§impl<T> HasTypedMemoryCost<T> for Twhere
T: HasMemoryCost,
impl<T> HasTypedMemoryCost<T> for Twhere
T: HasMemoryCost,
§fn typed_memory_cost(&self, enabled: EnabledToken) -> TypedMemoryCost<T>
fn typed_memory_cost(&self, enabled: EnabledToken) -> TypedMemoryCost<T>
The cost, as a
TypedMemoryCost<T>
rather than a raw usize
§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> ⓘ
Converts
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> ⓘ
Converts
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§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.