Struct tor_llcrypto::pk::ed25519::Ed25519Identity
source · [−]pub struct Ed25519Identity { /* private fields */ }
Expand description
A relay’s identity, as an unchecked, unvalidated Ed25519 key.
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
sourceimpl 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
sourceimpl Clone for Ed25519Identity
impl Clone for Ed25519Identity
sourcefn clone(&self) -> Ed25519Identity
fn clone(&self) -> Ed25519Identity
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl ConstantTimeEq for Ed25519Identity
impl ConstantTimeEq for Ed25519Identity
sourceimpl Debug for Ed25519Identity
impl Debug for Ed25519Identity
sourceimpl<'de> Deserialize<'de> for Ed25519Identity
impl<'de> Deserialize<'de> for Ed25519Identity
sourcefn 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
sourceimpl Display for Ed25519Identity
impl Display for Ed25519Identity
sourceimpl From<&PublicKey> for Ed25519Identity
impl From<&PublicKey> for Ed25519Identity
sourceimpl From<PublicKey> for Ed25519Identity
impl From<PublicKey> for Ed25519Identity
sourceimpl Hash for Ed25519Identity
impl Hash for Ed25519Identity
sourceimpl Ord for Ed25519Identity
impl Ord for Ed25519Identity
sourceimpl PartialEq<Ed25519Identity> for Ed25519Identity
impl PartialEq<Ed25519Identity> for Ed25519Identity
sourceimpl PartialOrd<Ed25519Identity> for Ed25519Identity
impl PartialOrd<Ed25519Identity> for Ed25519Identity
sourcefn partial_cmp(&self, other: &Ed25519Identity) -> Option<Ordering>
fn partial_cmp(&self, other: &Ed25519Identity) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Ed25519Identity
impl Serialize for Ed25519Identity
sourceimpl TryFrom<&Ed25519Identity> for PublicKey
impl TryFrom<&Ed25519Identity> for PublicKey
sourceimpl TryFrom<Ed25519Identity> for PublicKey
impl TryFrom<Ed25519Identity> for PublicKey
impl Copy for Ed25519Identity
impl Eq for Ed25519Identity
Auto Trait Implementations
impl RefUnwindSafe for Ed25519Identity
impl Send for Ed25519Identity
impl Sync for Ed25519Identity
impl Unpin for Ed25519Identity
impl UnwindSafe for Ed25519Identity
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more