Skip to main content

MasterKeypair

Struct MasterKeypair 

Source
pub struct MasterKeypair { /* private fields */ }
Expand description

A master keypair for signing BitRouter JWTs across chains.

Stores a 32-byte seed that deterministically derives:

  • Ed25519 keypair (Solana) via solana-keypair
  • secp256k1 keypair (EVM) via alloy-signer-local

Implementations§

Source§

impl MasterKeypair

Source

pub fn generate() -> Self

Generate a new random 32-byte seed.

Source

pub fn from_seed(seed: [u8; 32]) -> Self

Construct from a 32-byte seed.

Source

pub fn seed(&self) -> &[u8; 32]

Return the raw 32-byte seed.

Source

pub fn solana_pubkey_b58(&self) -> String

Solana public key as a base58-encoded string.

Source

pub fn evm_signer(&self) -> Result<PrivateKeySigner, JwtError>

Construct an alloy PrivateKeySigner from the seed.

Source

pub fn evm_address(&self) -> Result<Address, JwtError>

Derive the EVM address (checksummed hex with 0x prefix).

Source

pub fn evm_address_string(&self) -> Result<String, JwtError>

EVM address as a checksummed hex string (e.g. "0xAb5801...").

Source

pub fn caip10(&self, chain: &Chain) -> Result<Caip10, JwtError>

Derive the CAIP-10 account identifier for a given chain.

Source

pub fn public_key_prefix(&self) -> String

A short prefix for display and directory naming.

Uses the first 16 characters of the Solana base58 public key.

Source

pub fn sign_ed25519(&self, message: &[u8]) -> Vec<u8>

Sign a byte slice using Ed25519 (Solana / SOL_EDDSA) via the Solana SDK.

Returns the 64-byte Ed25519 signature.

Source

pub fn sign_eip191(&self, message: &[u8]) -> Result<Vec<u8>, JwtError>

Sign a byte slice using EIP-191 prefixed secp256k1 (EVM / EIP191K).

The alloy signer applies the "\x19Ethereum Signed Message:\n{len}" prefix, hashes with keccak256, and signs with secp256k1 ECDSA.

Returns the 65-byte signature (r[32] + s[32] + v[1]).

Source

pub fn to_json(&self) -> MasterKeyJson

Serialize to the JSON format stored in master.json.

Source

pub fn from_json(json: &MasterKeyJson) -> Result<Self, JwtError>

Deserialize from the JSON format stored in master.json.

Trait Implementations§

Source§

impl Clone for MasterKeypair

Source§

fn clone(&self) -> MasterKeypair

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more