Skip to main content

SignerHandle

Struct SignerHandle 

Source
pub struct SignerHandle<K: KeyScheme> { /* private fields */ }
Expand description

The unlocked handle. Drop wipes the secret.

Cloning a SignerHandle clones the underlying zeroizing buffer — both copies are independently wiped on drop. This is expensive for high-frequency signing; prefer sharing an Arc<SignerHandle<K>> for that case.

Implementations§

Source§

impl<K: KeyScheme> SignerHandle<K>

Source

pub fn public_key(&self) -> &K::PublicKey

Borrow the derived public key. Cheap (precomputed at unlock time).

Source

pub fn sign(&self, msg: &[u8]) -> K::Signature

Sign a byte message.

Source

pub fn try_sign(&self, msg: &[u8]) -> Result<K::Signature>

Attempt to sign, surfacing any scheme-level errors instead of panicking.

Source

pub fn expose_secret(&self) -> &[u8]

Borrow the raw secret bytes.

§⚠️ Danger

Prefer sign whenever possible. This method exists for a narrow class of consumers — hierarchical-deterministic (HD) wallets and key-derivation libraries — that need the raw seed bytes to derive child keys (e.g. chia_bls::DerivableKey::derive_unhardened). These callers cannot use sign because they need the SecretKey itself, not a signature.

The returned slice is borrowed from the handle’s internal Zeroizing<Vec<u8>>, so it wipes automatically when the handle drops. Callers must not copy the bytes into a non-zeroizing buffer without re-wrapping them — doing so would leave the secret on the heap past the end of its intended lifetime.

Typical usage:

let signer = get_signer();
let master_sk = chia_bls::SecretKey::from_seed(signer.expose_secret());
// `master_sk` is now the chia-bls master key; HD-derive as needed.

If you catch yourself writing signer.expose_secret().to_vec() or let copy = signer.expose_secret().to_owned();, stop and consider whether you really need to own the bytes — and if so, wrap the copy in Zeroizing::<Vec<u8>>::from(...).

Trait Implementations§

Source§

impl<K: KeyScheme> Clone for SignerHandle<K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<K: KeyScheme> Debug for SignerHandle<K>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K> Freeze for SignerHandle<K>
where <K as KeyScheme>::PublicKey: Freeze,

§

impl<K> RefUnwindSafe for SignerHandle<K>

§

impl<K> Send for SignerHandle<K>

§

impl<K> Sync for SignerHandle<K>

§

impl<K> Unpin for SignerHandle<K>
where <K as KeyScheme>::PublicKey: Unpin,

§

impl<K> UnsafeUnpin for SignerHandle<K>

§

impl<K> UnwindSafe for SignerHandle<K>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.