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
impl ProtoWallet
Sourcepub fn new(private_key: PrivateKey) -> ProtoWallet
pub fn new(private_key: PrivateKey) -> ProtoWallet
Create a new ProtoWallet from a private key.
Sourcepub fn from_key_deriver(kd: KeyDeriver) -> ProtoWallet
pub fn from_key_deriver(kd: KeyDeriver) -> ProtoWallet
Create a new ProtoWallet from an existing KeyDeriver.
Sourcepub fn anyone() -> ProtoWallet
pub fn anyone() -> ProtoWallet
Create an “anyone” ProtoWallet using the special anyone key (PrivateKey(1)).
Sourcepub fn get_public_key_sync(
&self,
protocol: &Protocol,
key_id: &str,
counterparty: &Counterparty,
for_self: bool,
identity_key: bool,
) -> Result<PublicKey, WalletError>
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_.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn encrypt_sync(
&self,
plaintext: &[u8],
protocol: &Protocol,
key_id: &str,
counterparty: &Counterparty,
) -> Result<Vec<u8>, WalletError>
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.
Sourcepub fn decrypt_sync(
&self,
ciphertext: &[u8],
protocol: &Protocol,
key_id: &str,
counterparty: &Counterparty,
) -> Result<Vec<u8>, WalletError>
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).
Sourcepub fn create_hmac_sync(
&self,
data: &[u8],
protocol: &Protocol,
key_id: &str,
counterparty: &Counterparty,
) -> Result<Vec<u8>, WalletError>
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.
Sourcepub fn verify_hmac_sync(
&self,
data: &[u8],
hmac_value: &[u8],
protocol: &Protocol,
key_id: &str,
counterparty: &Counterparty,
) -> Result<bool, WalletError>
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.
Sourcepub fn reveal_counterparty_key_linkage_sync(
&self,
counterparty: &Counterparty,
verifier: &PublicKey,
) -> Result<RevealCounterpartyResult, WalletError>
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.
Sourcepub fn reveal_specific_key_linkage_sync(
&self,
counterparty: &Counterparty,
verifier: &PublicKey,
protocol: &Protocol,
key_id: &str,
) -> Result<RevealSpecificResult, WalletError>
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
impl WalletInterface for ProtoWallet
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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§
impl Freeze for ProtoWallet
impl !RefUnwindSafe for ProtoWallet
impl Send for ProtoWallet
impl Sync for ProtoWallet
impl Unpin for ProtoWallet
impl UnsafeUnpin for ProtoWallet
impl !UnwindSafe for ProtoWallet
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
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>
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>
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