Crate ripple_keypairs

Source
Expand description

Cryptographic key pairs for the XRP Ledger

An implementation of XRP Ledger keypairs & wallet generation which supports rfc6979 and eddsa deterministic signatures.

§Examples

§Generate a random XRP Ledger address

use ripple_keypairs::Seed;

let seed = Seed::random();
let (_, public_key) = seed.derive_keypair()?;
let address = public_key.derive_address();

assert!(address.starts_with("r"));

§Encode a seed in Base58 XRP Legder format

use ripple_keypairs::{Seed, Entropy, Algorithm};

// In the real world you **must** generate random entropy
let entropy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
let seed = Seed::new(Entropy::Array(entropy), &Algorithm::Secp256k1);

assert_eq!(seed.to_string(), "sp5fghtJtpUorTwvof1NpDXAzNwf5");

§Parse a string into a seed

use std::str::FromStr;
use ripple_keypairs::{Seed, error};

let seed = Seed::from_str("sp5fghtJtpUorTwvof1NpDXAzNwf5")?;

assert_eq!(seed, "sp5fghtJtpUorTwvof1NpDXAzNwf5".parse()?);
assert_eq!(Err(error::DecodeError), "bad seed".parse::<Seed>());

Modules§

error
Errors

Structs§

HexBytes
The values of this type can be treated as bytes or as hex encoded strings
PrivateKey
A private key that can be used to sign messages
PublicKey
A public key that can be used to derive an XRP Ledger classic address and verify signatures
Seed
A seed that can be used to generate keypairs

Enums§

Algorithm
The elliptic curve digital signature algorithm with which the seed is intended to be used
Entropy
Entropy which is used to generate seed

Traits§

Signature
Signatures can be treated as bytes or as hex encoded strings.

Type Aliases§

EntropyArray
Seed entropy array