pub struct Ed25519Identity { /* private fields */ }
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.
Implementations§
Source§impl Ed25519Identity
impl Ed25519Identity
Sourcepub fn new(id: [u8; 32]) -> Self
pub fn new(id: [u8; 32]) -> Self
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());
Sourcepub fn from_bytes(id: &[u8]) -> Option<Self>
pub fn from_bytes(id: &[u8]) -> Option<Self>
If id
is of the correct length, wrap it in an Ed25519Identity.
Trait Implementations§
Source§impl Clone for Ed25519Identity
impl Clone for Ed25519Identity
Source§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 moreSource§impl ConstantTimeEq for Ed25519Identity
impl ConstantTimeEq for Ed25519Identity
Source§impl Debug for Ed25519Identity
impl Debug for Ed25519Identity
Source§impl<'de> Deserialize<'de> for Ed25519Identity
impl<'de> Deserialize<'de> for Ed25519Identity
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Ed25519Identity
impl Display for Ed25519Identity
Source§impl From<&PublicKey> for Ed25519Identity
impl From<&PublicKey> for Ed25519Identity
Source§impl From<Ed25519Identity> for [u8; 32]
impl From<Ed25519Identity> for [u8; 32]
Source§fn from(value: Ed25519Identity) -> Self
fn from(value: Ed25519Identity) -> Self
Converts to this type from the input type.
Source§impl From<PublicKey> for Ed25519Identity
impl From<PublicKey> for Ed25519Identity
Source§impl HasMemoryCostStructural for Ed25519Identity
impl HasMemoryCostStructural for Ed25519Identity
Source§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
Source§impl Hash for Ed25519Identity
impl Hash for Ed25519Identity
Source§impl Ord for Ed25519Identity
impl Ord for Ed25519Identity
Source§fn cmp(&self, other: &Ed25519Identity) -> Ordering
fn cmp(&self, other: &Ed25519Identity) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Ed25519Identity
impl PartialEq for Ed25519Identity
Source§impl PartialOrd for Ed25519Identity
impl PartialOrd for Ed25519Identity
Source§impl Redactable for Ed25519Identity
impl Redactable for Ed25519Identity
Source§fn display_redacted(&self, f: &mut Formatter<'_>) -> Result
fn display_redacted(&self, f: &mut Formatter<'_>) -> Result
Warning: This displays 12 bits of the ed25519 identity, which is enough to narrow down a public relay by a great deal.
Source§fn debug_redacted(&self, f: &mut Formatter<'_>) -> Result
fn debug_redacted(&self, f: &mut Formatter<'_>) -> Result
As
Debug::fmt
, but produce a redacted representation.Source§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.
Source§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.Source§impl Serialize for Ed25519Identity
impl Serialize for Ed25519Identity
Source§impl TryFrom<&Ed25519Identity> for PublicKey
impl TryFrom<&Ed25519Identity> for PublicKey
Source§impl TryFrom<Ed25519Identity> for PublicKey
impl TryFrom<Ed25519Identity> for PublicKey
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<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.Source§impl<T> HasMemoryCost for Twhere
T: HasMemoryCostStructural,
impl<T> HasMemoryCost for Twhere
T: HasMemoryCostStructural,
Source§fn memory_cost(&self, et: EnabledToken) -> usize
fn memory_cost(&self, et: EnabledToken) -> usize
Returns the memory cost of
self
, in bytes Read moreSource§impl<T> HasTypedMemoryCost<T> for Twhere
T: HasMemoryCost,
impl<T> HasTypedMemoryCost<T> for Twhere
T: HasMemoryCost,
Source§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>
§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>
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