pub struct Identity { /* private fields */ }Expand description
A FIPS node identity consisting of a keypair and derived identifiers.
The identity holds the secp256k1 keypair and provides methods for signing and verifying protocol messages.
Implementations§
Source§impl Identity
impl Identity
Sourcepub fn from_keypair(keypair: Keypair) -> Identity
pub fn from_keypair(keypair: Keypair) -> Identity
Create an identity from an existing keypair.
Sourcepub fn from_secret_key(secret_key: SecretKey) -> Identity
pub fn from_secret_key(secret_key: SecretKey) -> Identity
Create an identity from a secret key.
Sourcepub fn from_secret_bytes(bytes: &[u8; 32]) -> Result<Identity, IdentityError>
pub fn from_secret_bytes(bytes: &[u8; 32]) -> Result<Identity, IdentityError>
Create an identity from secret key bytes.
Sourcepub fn from_secret_str(s: &str) -> Result<Identity, IdentityError>
pub fn from_secret_str(s: &str) -> Result<Identity, IdentityError>
Create an identity from an nsec string (bech32) or hex-encoded secret.
Sourcepub fn keypair(&self) -> Keypair
pub fn keypair(&self) -> Keypair
Return the underlying keypair.
This is needed for cryptographic operations like Noise handshakes.
Sourcepub fn pubkey(&self) -> XOnlyPublicKey
pub fn pubkey(&self) -> XOnlyPublicKey
Return the x-only public key.
Sourcepub fn pubkey_full(&self) -> PublicKey
pub fn pubkey_full(&self) -> PublicKey
Return the full public key (includes parity).
Sourcepub fn address(&self) -> &FipsAddress
pub fn address(&self) -> &FipsAddress
Return the FIPS address.
Sourcepub fn sign(&self, data: &[u8]) -> Signature
pub fn sign(&self, data: &[u8]) -> Signature
Sign arbitrary data with this identity’s secret key.
Sourcepub fn sign_challenge(
&self,
challenge: &[u8; 32],
timestamp: u64,
) -> AuthResponse
pub fn sign_challenge( &self, challenge: &[u8; 32], timestamp: u64, ) -> AuthResponse
Create an authentication response for a challenge.
The response signs: SHA256(“fips-auth-v1” || challenge || timestamp)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Identity
impl RefUnwindSafe for Identity
impl Send for Identity
impl Sync for Identity
impl Unpin for Identity
impl UnsafeUnpin for Identity
impl UnwindSafe for Identity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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