Skip to main content

ProtoWallet

Struct ProtoWallet 

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

Protocol wallet providing default WalletInterface implementations. ProtoWallet is a crypto-only wallet wrapping KeyDeriver.

It provides foundational cryptographic operations: key derivation, signing, verification, encryption, decryption, HMAC, and key linkage revelation. Unlike a full wallet, it does not create transactions, manage outputs, or interact with the blockchain.

Implementations§

Source§

impl ProtoWallet

Source

pub fn new(private_key: PrivateKey) -> ProtoWallet

Create a new ProtoWallet from a private key.

Source

pub fn from_key_deriver(kd: KeyDeriver) -> ProtoWallet

Create a new ProtoWallet from an existing KeyDeriver.

Source

pub fn anyone() -> ProtoWallet

Create an “anyone” ProtoWallet using the special anyone key (PrivateKey(1)).

Source

pub fn get_public_key_sync( &self, protocol: &Protocol, key_id: &str, counterparty: &Counterparty, for_self: bool, identity_key: bool, ) -> Result<PublicKey, WalletError>

Get a public key, either the identity key or a derived key.

If identity_key is true, returns the root identity public key (protocol, key_id, counterparty, for_self are ignored). Otherwise, derives a public key using the given parameters. If counterparty is Uninitialized, it defaults to Self_.

Source

pub fn create_signature_sync( &self, data: Option<&[u8]>, hash_to_directly_sign: Option<&[u8]>, protocol: &Protocol, key_id: &str, counterparty: &Counterparty, ) -> Result<Vec<u8>, WalletError>

Create an ECDSA signature over data or a pre-computed hash.

If data is provided, hashes it with SHA-256 then signs. If hash_to_directly_sign is provided, signs it directly. Returns the DER-encoded signature bytes.

Source

pub fn verify_signature_sync( &self, data: Option<&[u8]>, hash_to_directly_verify: Option<&[u8]>, signature: &[u8], protocol: &Protocol, key_id: &str, counterparty: &Counterparty, for_self: bool, ) -> Result<bool, WalletError>

Verify an ECDSA signature over data or a pre-computed hash.

If data is provided, hashes it with SHA-256 then verifies. If hash_to_directly_verify is provided, verifies against it directly.

Source

pub fn encrypt_sync( &self, plaintext: &[u8], protocol: &Protocol, key_id: &str, counterparty: &Counterparty, ) -> Result<Vec<u8>, WalletError>

Encrypt plaintext using a derived symmetric key (AES-GCM).

Derives a symmetric key from the protocol, key ID, and counterparty, then encrypts the plaintext. Returns IV || ciphertext || auth tag.

Source

pub fn decrypt_sync( &self, ciphertext: &[u8], protocol: &Protocol, key_id: &str, counterparty: &Counterparty, ) -> Result<Vec<u8>, WalletError>

Decrypt ciphertext using a derived symmetric key (AES-GCM).

Derives the same symmetric key used for encryption and decrypts. Expects format: IV(32) || ciphertext || auth tag(16).

Source

pub fn create_hmac_sync( &self, data: &[u8], protocol: &Protocol, key_id: &str, counterparty: &Counterparty, ) -> Result<Vec<u8>, WalletError>

Create an HMAC-SHA256 over data using a derived symmetric key.

Returns a 32-byte HMAC value.

Source

pub fn verify_hmac_sync( &self, data: &[u8], hmac_value: &[u8], protocol: &Protocol, key_id: &str, counterparty: &Counterparty, ) -> Result<bool, WalletError>

Verify an HMAC-SHA256 value over data using a derived symmetric key.

Computes the expected HMAC and compares it with the provided value using constant-time comparison.

Source

pub fn reveal_counterparty_key_linkage_sync( &self, counterparty: &Counterparty, verifier: &PublicKey, ) -> Result<RevealCounterpartyResult, WalletError>

Reveal counterparty key linkage to a verifier.

Creates an encrypted revelation of the shared secret between this wallet and the counterparty, along with an encrypted HMAC proof. Both are encrypted for the verifier using the “counterparty linkage revelation” protocol.

Source

pub fn reveal_specific_key_linkage_sync( &self, counterparty: &Counterparty, verifier: &PublicKey, protocol: &Protocol, key_id: &str, ) -> Result<RevealSpecificResult, WalletError>

Reveal specific key linkage for a given protocol and key ID to a verifier.

Encrypts the specific secret and a proof byte for the verifier using a special “specific linkage revelation” protocol.

Trait Implementations§

Source§

impl WalletInterface for ProtoWallet

Source§

fn create_action<'life0, 'life1, 'async_trait>( &'life0 self, _args: CreateActionArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<CreateActionResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn sign_action<'life0, 'life1, 'async_trait>( &'life0 self, _args: SignActionArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<SignActionResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn abort_action<'life0, 'life1, 'async_trait>( &'life0 self, _args: AbortActionArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<AbortActionResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn list_actions<'life0, 'life1, 'async_trait>( &'life0 self, _args: ListActionsArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<ListActionsResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn internalize_action<'life0, 'life1, 'async_trait>( &'life0 self, _args: InternalizeActionArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<InternalizeActionResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn list_outputs<'life0, 'life1, 'async_trait>( &'life0 self, _args: ListOutputsArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<ListOutputsResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn relinquish_output<'life0, 'life1, 'async_trait>( &'life0 self, _args: RelinquishOutputArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<RelinquishOutputResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn get_public_key<'life0, 'life1, 'async_trait>( &'life0 self, args: GetPublicKeyArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<GetPublicKeyResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn reveal_counterparty_key_linkage<'life0, 'life1, 'async_trait>( &'life0 self, args: RevealCounterpartyKeyLinkageArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<RevealCounterpartyKeyLinkageResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn reveal_specific_key_linkage<'life0, 'life1, 'async_trait>( &'life0 self, args: RevealSpecificKeyLinkageArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<RevealSpecificKeyLinkageResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn encrypt<'life0, 'life1, 'async_trait>( &'life0 self, args: EncryptArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<EncryptResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn decrypt<'life0, 'life1, 'async_trait>( &'life0 self, args: DecryptArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<DecryptResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn create_hmac<'life0, 'life1, 'async_trait>( &'life0 self, args: CreateHmacArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<CreateHmacResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn verify_hmac<'life0, 'life1, 'async_trait>( &'life0 self, args: VerifyHmacArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<VerifyHmacResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn create_signature<'life0, 'life1, 'async_trait>( &'life0 self, args: CreateSignatureArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<CreateSignatureResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn verify_signature<'life0, 'life1, 'async_trait>( &'life0 self, args: VerifySignatureArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<VerifySignatureResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn acquire_certificate<'life0, 'life1, 'async_trait>( &'life0 self, _args: AcquireCertificateArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Certificate, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn list_certificates<'life0, 'life1, 'async_trait>( &'life0 self, _args: ListCertificatesArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<ListCertificatesResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn prove_certificate<'life0, 'life1, 'async_trait>( &'life0 self, _args: ProveCertificateArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<ProveCertificateResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn relinquish_certificate<'life0, 'life1, 'async_trait>( &'life0 self, _args: RelinquishCertificateArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<RelinquishCertificateResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn discover_by_identity_key<'life0, 'life1, 'async_trait>( &'life0 self, _args: DiscoverByIdentityKeyArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<DiscoverCertificatesResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn discover_by_attributes<'life0, 'life1, 'async_trait>( &'life0 self, _args: DiscoverByAttributesArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<DiscoverCertificatesResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn is_authenticated<'life0, 'life1, 'async_trait>( &'life0 self, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<AuthenticatedResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn wait_for_authentication<'life0, 'life1, 'async_trait>( &'life0 self, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<AuthenticatedResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn get_height<'life0, 'life1, 'async_trait>( &'life0 self, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<GetHeightResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn get_header_for_height<'life0, 'life1, 'async_trait>( &'life0 self, _args: GetHeaderArgs, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<GetHeaderResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn get_network<'life0, 'life1, 'async_trait>( &'life0 self, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<GetNetworkResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

Source§

fn get_version<'life0, 'life1, 'async_trait>( &'life0 self, _originator: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<GetVersionResult, WalletError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, ProtoWallet: 'async_trait,

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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