Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use crate::{
constants::GROTH_PROOF_SIZE,
note::ExtractedNoteCommitment,
note_encryption::{
CompactOutputDescription, SaplingDomain, COMPACT_NOTE_SIZE, ENC_CIPHERTEXT_SIZE,
CompactEncCiphertext, CompactOutputDescription, EncCiphertext, SaplingDomain,
COMPACT_NOTE_SIZE, ENC_CIPHERTEXT_SIZE,
},
value::ValueCommitment,
Nullifier,
Expand Down Expand Up @@ -433,12 +434,14 @@ impl<A> ShieldedOutput<SaplingDomain> for OutputDescription<A> {
self.cmu.to_bytes()
}

fn enc_ciphertext(&self) -> Option<&NoteBytesData<{ ENC_CIPHERTEXT_SIZE }>> {
fn enc_ciphertext(&self) -> Option<&EncCiphertext> {
Some(&self.enc_ciphertext)
}

fn enc_ciphertext_compact(&self) -> NoteBytesData<{ COMPACT_NOTE_SIZE }> {
unimplemented!("This function is not required for sapling")
fn enc_ciphertext_compact(&self) -> CompactEncCiphertext {
let mut data = [0u8; COMPACT_NOTE_SIZE];
data.copy_from_slice(&self.enc_ciphertext.as_ref()[..COMPACT_NOTE_SIZE]);
NoteBytesData(data)
}
}

Expand Down Expand Up @@ -498,12 +501,12 @@ impl OutputDescriptionV5 {

impl<A> From<OutputDescription<A>> for CompactOutputDescription {
fn from(out: OutputDescription<A>) -> CompactOutputDescription {
let enc_ciphertext = out.enc_ciphertext_compact().0;

CompactOutputDescription {
ephemeral_key: out.ephemeral_key,
cmu: out.cmu,
enc_ciphertext: out.enc_ciphertext.as_ref()[..COMPACT_NOTE_SIZE]
.try_into()
.unwrap(),
enc_ciphertext,
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/note_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ impl SaplingDomain {
}
}

pub(crate) type EncCiphertext = NoteBytesData<{ ENC_CIPHERTEXT_SIZE }>;
pub(crate) type CompactEncCiphertext = NoteBytesData<{ COMPACT_NOTE_SIZE }>;

impl Domain for SaplingDomain {
type EphemeralSecretKey = EphemeralSecretKey;
// It is acceptable for this to be a point rather than a byte array, because we
Expand All @@ -160,9 +163,9 @@ impl Domain for SaplingDomain {
type Memo = [u8; MEMO_SIZE];

type NotePlaintextBytes = NoteBytesData<{ NOTE_PLAINTEXT_SIZE }>;
type NoteCiphertextBytes = NoteBytesData<{ ENC_CIPHERTEXT_SIZE }>;
type NoteCiphertextBytes = EncCiphertext;
type CompactNotePlaintextBytes = NoteBytesData<{ COMPACT_NOTE_SIZE }>;
type CompactNoteCiphertextBytes = NoteBytesData<{ COMPACT_NOTE_SIZE }>;
type CompactNoteCiphertextBytes = CompactEncCiphertext;

fn derive_esk(note: &Self::Note) -> Option<Self::EphemeralSecretKey> {
note.derive_esk()
Expand Down