[][src]Struct ripple_keypairs::PublicKey

pub struct PublicKey { /* fields omitted */ }

A public key that can be used to derive an XRP Ledger classic address and verify signatures

Examples

use ripple_keypairs::{Seed, error};

let seed = "sp5fghtJtpUorTwvof1NpDXAzNwf5".parse::<Seed>()?;

let (private_key, public_key) = seed.derive_keypair()?;

assert_eq!(public_key.derive_address(), "rU6K7V3Po4snVhBBaU29sesqs2qTQJWDw1");

assert_eq!(public_key.to_string(), "030D58EB48B4420B1F7B9DF55087E0E29FEF0E8468F9A6825B01CA2C361042D435");

let msg = "Test message";

assert_eq!(public_key.verify(&msg, &private_key.sign(&msg)), Ok(()));
assert_eq!(public_key.verify(&msg, &"bad signature"), Err(error::InvalidSignature));

Implementations

impl PublicKey[src]

pub fn verify(
    &self,
    message: &impl AsRef<[u8]>,
    signature: &impl AsRef<[u8]>
) -> Result<()>
[src]

Verify a signature

Errors

Returns error::InvalidSignature if the signature is invalid.

pub fn derive_address(&self) -> String[src]

Derive an XRP Ledger classic address

Trait Implementations

impl Clone for PublicKey[src]

impl Debug for PublicKey[src]

impl Display for PublicKey[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Display as a hex encoded string

impl Eq for PublicKey[src]

impl Hash for PublicKey[src]

impl PartialEq<PublicKey> for PublicKey[src]

impl StructuralEq for PublicKey[src]

impl StructuralPartialEq for PublicKey[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,