pub fn try_sapling_note_decryption<P: consensus::Parameters>(
    params: &P,
    height: BlockHeight,
    ivk: &SaplingIvk,
    epk: &jubjub::ExtendedPoint,
    cmu: &bls12_381::Scalar,
    enc_ciphertext: &[u8],
) -> Option<(Note, PaymentAddress, MemoBytes)> {
    assert_eq!(enc_ciphertext.len(), ENC_CIPHERTEXT_SIZE);

    let shared_secret = sapling_ka_agree(&ivk.0, &epk);
    let key = kdf_sapling(shared_secret, &epk);

    let mut plaintext = [0; ENC_CIPHERTEXT_SIZE];
    assert_eq!(
        ChachaPolyIetf::aead_cipher()
            .open_to(
                &mut plaintext,
                &enc_ciphertext,
                &[],
                key.as_bytes(),
                &[0u8; 12]
            )
            .ok()?,
        NOTE_PLAINTEXT_SIZE
    );

    let (note, to) = parse_note_plaintext_without_memo(params, height, ivk, epk, cmu, &plaintext)?;

    // Memo is the correct length by definition.
    let memo = MemoBytes::from_bytes(&plaintext[COMPACT_NOTE_SIZE..NOTE_PLAINTEXT_SIZE]).unwrap();

    Some((note, to, memo))
}
/// Trial decryption of the full note plaintext by the recipient.
///
/// Attempts to decrypt and validate the given `enc_ciphertext` using the given `ivk`.
/// If successful, the corresponding Sapling note and memo are returned, along with the
/// `PaymentAddress` to which the note was sent.
///
/// Implements section 4.17.2 of the Zcash Protocol Specification.
Trial decryption of the full note plaintext by the recipient.
Attempts to decrypt and validate the given `enc_ciphertext` using the given `ivk`.
If successful, the corresponding Sapling note and memo are returned, along with the
`PaymentAddress` to which the note was sent.

Implements section 4.17.2 of the Zcash Protocol Specification.
Trial decryption of the full note plaintext by the recipient . Attempts to decrypt and validate the given ` enc_ciphertext ` using the given ` ivk ` . If successful the corresponding Sapling note and memo are returned along with the ` PaymentAddress ` to which the note was sent . Implements section 4 . 17 . 2 of the Zcash Protocol Specification .
pub fn try_sapling_note_decryption<P: consensus::Parameters>(
    params: &P,
    height: BlockHeight,
    ivk: &SaplingIvk,
    epk: &jubjub::ExtendedPoint,
    cmu: &bls12_381::Scalar,
    enc_ciphertext: &[u8],
) -> Option<(Note, PaymentAddress, MemoBytes)> {
    assert_eq!(enc_ciphertext.len(), ENC_CIPHERTEXT_SIZE);
    let shared_secret = sapling_ka_agree(&ivk.0, &epk);
    let key = kdf_sapling(shared_secret, &epk);
    let mut plaintext = [0; ENC_CIPHERTEXT_SIZE];
    assert_eq!(
        ChachaPolyIetf::aead_cipher()
            .open_to(
                &mut plaintext,
                &enc_ciphertext,
                &[],
                key.as_bytes(),
                &[0u8; 12]
            )
            .ok()?,
        NOTE_PLAINTEXT_SIZE
    );
    let (note, to) = parse_note_plaintext_without_memo(params, height, ivk, epk, cmu, &plaintext)?;
    // Memo is the correct length by definition.
    let memo = MemoBytes::from_bytes(&plaintext[COMPACT_NOTE_SIZE..NOTE_PLAINTEXT_SIZE]).unwrap();
    Some((note, to, memo))
}
pub fn try_sapling_note_decryption < P : consensus :: Parameters > ( params : & P , height : BlockHeight , ivk : & SaplingIvk , epk : & jubjub :: ExtendedPoint , cmu : & bls12_381 :: Scalar , enc_ciphertext : & [ u8 ] , ) -> Option < ( Note , PaymentAddress , MemoBytes ) > { assert_eq ! ( enc_ciphertext len ( ) ENC_CIPHERTEXT_SIZE ) ; let shared_secret = sapling_ka_agree ( & ivk . 0 , & epk ) ; let key = kdf_sapling ( shared_secret , & epk ) ; let mut plaintext = [ 0 ; ENC_CIPHERTEXT_SIZE ] ; assert_eq ! ( ChachaPolyIetf aead_cipher ( ) open_to ( mut plaintext enc_ciphertext [ ] key as_bytes ( ) [ 0u8 12 ] ) ok ( ) NOTE_PLAINTEXT_SIZE ) ; let ( note , to ) = parse_note_plaintext_without_memo ( params , height , ivk , epk , cmu , & plaintext ) ? ; // Memo is the correct length by definition. let memo = MemoBytes :: from_bytes ( & plaintext [ COMPACT_NOTE_SIZE .. NOTE_PLAINTEXT_SIZE ] ) . unwrap ( ) ; Some ( ( note , to , memo ) ) }
Trial decryption of the full note plaintext by the recipient.
Trial decryption of the full note plaintext by the recipient .
params
&P
height
BlockHeight
ivk
&SaplingIvk
epk
&jubjub::ExtendedPoint
cmu
&bls12_381::Scalar
enc_ciphertext
&[u8]
params
&P
height
BlockHeight
ivk
&SaplingIvk
epk
&jubjub::ExtendedPoint
cmu
&bls12_381::Scalar
enc_ciphertext
&[u8]