pub struct SaplingIncomingViewingKey(/* private fields */);
Expand description
A Sapling Incoming Viewing Key (IVK), which allows detection and decryption of incoming transactions to a Sapling shielded address.
SaplingIncomingViewingKey
is a 32-byte key that enables a wallet to detect when
funds have been sent to its associated Sapling address and to decrypt the incoming
transaction details, without granting the ability to spend those funds.
§Zcash Concept Relation
In Zcash’s Sapling protocol, the privacy features rely on a system of keys with different capabilities:
- Full Viewing Keys can detect both incoming and outgoing transactions
- Incoming Viewing Keys (derived from full viewing keys) can only detect incoming transactions
- Spending Keys provide full control, including spending capability
IVKs enable “watch-only” wallet functionality, where users can monitor their funds without risking theft if the wallet is compromised.
§Data Preservation
During wallet migration, incoming viewing keys are preserved exactly as they exist in the source wallet, maintaining the ability to detect and view incoming transactions in the migrated wallet.
§Examples
use zewif::sapling::SaplingIncomingViewingKey;
use zewif::Blob;
// Wrap the raw bytes of an encoded Sapling incoming viewing key.
let raw_bytes = [0u8; 32]; // In practice, this would be actual key material
let ivk = SaplingIncomingViewingKey::new(raw_bytes);
// The key can be converted to CBOR for storage or transmission
let hex: dcbor::CBOR = ivk.into();
Implementations§
Source§impl SaplingIncomingViewingKey
impl SaplingIncomingViewingKey
Sourcepub fn new(data: [u8; 32]) -> Self
pub fn new(data: [u8; 32]) -> Self
Creates a new instance from a fixed-size byte array.
This is the primary constructor when you have an exact-sized array available.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of this blob in bytes.
This will always return $size
for this type.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this blob contains no bytes.
This will always return false
for this type (unless $size
is 0).
Sourcepub fn to_vec(&self) -> Vec<u8> ⓘ
pub fn to_vec(&self) -> Vec<u8> ⓘ
Converts this blob to a Vec<u8>
, creating a copy of the data.
Sourcepub fn from_slice(data: &[u8]) -> Result<Self, TryFromSliceError>
pub fn from_slice(data: &[u8]) -> Result<Self, TryFromSliceError>
Creates an instance from a slice of bytes.
§Errors
Returns an error if the slice’s length doesn’t match the expected size ($size).
Sourcepub fn from_vec(data: Vec<u8>) -> Result<Self, TryFromSliceError>
pub fn from_vec(data: Vec<u8>) -> Result<Self, TryFromSliceError>
Creates an instance from a Vec<u8>
.
§Errors
Returns an error if the vector’s length doesn’t match the expected size ($size).
Sourcepub fn from_hex(hex: &str) -> Result<Self, HexParseError>
pub fn from_hex(hex: &str) -> Result<Self, HexParseError>
Parses an instance from a hex string.
Sourcepub fn from_reversed_hex(hex: &str) -> Result<Self, HexParseError>
pub fn from_reversed_hex(hex: &str) -> Result<Self, HexParseError>
Parses an instance from a hex string in reversed byte order, such as is used for transaction identifiers and block hashes.
Trait Implementations§
Source§impl AsRef<[u8]> for SaplingIncomingViewingKey
impl AsRef<[u8]> for SaplingIncomingViewingKey
Source§impl Clone for SaplingIncomingViewingKey
impl Clone for SaplingIncomingViewingKey
Source§impl Debug for SaplingIncomingViewingKey
impl Debug for SaplingIncomingViewingKey
Source§impl Display for SaplingIncomingViewingKey
impl Display for SaplingIncomingViewingKey
Source§impl From<&[u8]> for SaplingIncomingViewingKey
impl From<&[u8]> for SaplingIncomingViewingKey
Source§impl From<&SaplingIncomingViewingKey> for CBOR
impl From<&SaplingIncomingViewingKey> for CBOR
Source§fn from(data: &SaplingIncomingViewingKey) -> Self
fn from(data: &SaplingIncomingViewingKey) -> Self
Source§impl From<SaplingIncomingViewingKey> for CBOR
impl From<SaplingIncomingViewingKey> for CBOR
Source§fn from(data: SaplingIncomingViewingKey) -> Self
fn from(data: SaplingIncomingViewingKey) -> Self
Source§impl From<SaplingIncomingViewingKey> for Envelope
impl From<SaplingIncomingViewingKey> for Envelope
Source§fn from(value: SaplingIncomingViewingKey) -> Self
fn from(value: SaplingIncomingViewingKey) -> Self
Source§impl Hash for SaplingIncomingViewingKey
impl Hash for SaplingIncomingViewingKey
Source§impl TryFrom<CBOR> for SaplingIncomingViewingKey
impl TryFrom<CBOR> for SaplingIncomingViewingKey
Source§impl TryFrom<Envelope> for SaplingIncomingViewingKey
impl TryFrom<Envelope> for SaplingIncomingViewingKey
impl Copy for SaplingIncomingViewingKey
impl Eq for SaplingIncomingViewingKey
Auto Trait Implementations§
impl Freeze for SaplingIncomingViewingKey
impl RefUnwindSafe for SaplingIncomingViewingKey
impl Send for SaplingIncomingViewingKey
impl Sync for SaplingIncomingViewingKey
impl Unpin for SaplingIncomingViewingKey
impl UnwindSafe for SaplingIncomingViewingKey
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> CBORDecodable for T
impl<T> CBORDecodable for T
Source§impl<T> CBOREncodable for T
impl<T> CBOREncodable for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnvelopeEncodable for T
impl<T> EnvelopeEncodable for T
Source§fn into_envelope(self) -> Envelope
fn into_envelope(self) -> Envelope
Converts the value into an envelope by using its Into<Envelope>
implementation.
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 moreSource§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)