zcash_client_backend: Address compact_formats.proto comments

This commit is contained in:
Jack Grigg 2022-02-17 23:58:20 +00:00
parent 18562c71dc
commit cceae3ac34
5 changed files with 19 additions and 14 deletions

View File

@ -44,7 +44,9 @@ and this library adheres to Rust's notion of
- MSRV is now 1.51.0.
- Bumped dependencies to `ff 0.11`, `group 0.11`, `bls12_381 0.6`, `jubjub 0.8`.
- `zcash_client_backend::proto`:
- `compact_formats::CompactSpend` has been renamed to `CompactSaplingSpend`.
- `compact_formats::CompactSpend` has been renamed to `CompactSaplingSpend`,
and its `epk` field (and associated `set_epk` method) has been renamed to
`ephemeralKey` (and `set_ephemeralKey`).
- `compact_formats::CompactOutput` has been renamed to `CompactSaplingOutput`.
- `epk: jubjub::ExtendedPoint` has been replaced by
`ephemeral_key: zcash_note_encryption::EphemeralKeyBytes` in various places:

View File

@ -37,8 +37,8 @@ message CompactTx {
// The transaction fee: present if server can provide. In the case of a
// stateless server and a transaction with transparent inputs, this will be
// unset because the calculation requires reference to prior transactions.
// in a pure-Sapling context, the fee will be calculable as:
// valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
// If there are no transparent inputs, the fee will be calculable as:
// valueBalanceSapling + valueBalanceOrchard + sum(vPubNew) - sum(vPubOld) - sum(tOut)
uint32 fee = 3;
repeated CompactSaplingSpend spends = 4;
@ -52,11 +52,14 @@ message CompactSaplingSpend {
bytes nf = 1; // nullifier (see the Zcash protocol specification)
}
// output is a Sapling Output Description as described in section 7.4 of the
// Zcash protocol spec. Total size is 948.
// output encodes the `cmu` field, `ephemeralKey` field, and a 52-byte prefix of the
// `encCiphertext` field of a Sapling Output Description. These fields are described in
// section 7.4 of the Zcash protocol spec:
// https://zips.z.cash/protocol/protocol.pdf#outputencodingandconsensus
// Total size is 116 bytes.
message CompactSaplingOutput {
bytes cmu = 1; // note commitment u-coordinate
bytes epk = 2; // ephemeral public key
bytes ephemeralKey = 2; // ephemeral public key
bytes ciphertext = 3; // first 52 bytes of ciphertext
}
@ -66,5 +69,5 @@ message CompactOrchardAction {
bytes nullifier = 1; // [32] The nullifier of the input note
bytes cmx = 2; // [32] The x-coordinate of the note commitment for the output note
bytes ephemeralKey = 3; // [32] An encoding of an ephemeral Pallas public key
bytes encCiphertext = 4; // [580] The encrypted contents of the note plaintext
bytes ciphertext = 4; // [52] The first 52 bytes of the encCiphertext field
}

View File

@ -100,7 +100,7 @@ impl compact_formats::CompactSaplingOutput {
///
/// [`CompactOutput.epk`]: #structfield.epk
pub fn ephemeral_key(&self) -> Result<EphemeralKeyBytes, ()> {
self.epk[..]
self.ephemeralKey[..]
.try_into()
.map(EphemeralKeyBytes)
.map_err(|_| ())
@ -113,7 +113,7 @@ impl<A: sapling::Authorization> From<sapling::OutputDescription<A>>
fn from(out: sapling::OutputDescription<A>) -> compact_formats::CompactSaplingOutput {
let mut result = compact_formats::CompactSaplingOutput::new();
result.set_cmu(out.cmu.to_repr().to_vec());
result.set_epk(out.ephemeral_key.as_ref().to_vec());
result.set_ephemeralKey(out.ephemeral_key.as_ref().to_vec());
result.set_ciphertext(out.enc_ciphertext[..COMPACT_NOTE_SIZE].to_vec());
result
}

View File

@ -346,7 +346,7 @@ mod tests {
cspend.set_nf(fake_nf);
let mut cout = CompactSaplingOutput::new();
cout.set_cmu(fake_cmu);
cout.set_epk(fake_epk);
cout.set_ephemeralKey(fake_epk);
cout.set_ciphertext(vec![0; 52]);
let mut ctx = CompactTx::new();
let mut txid = vec![0; 32];
@ -404,7 +404,7 @@ mod tests {
cspend.set_nf(nf.0.to_vec());
let mut cout = CompactSaplingOutput::new();
cout.set_cmu(cmu);
cout.set_epk(epk);
cout.set_ephemeralKey(epk);
cout.set_ciphertext(enc_ciphertext.as_ref()[..52].to_vec());
let mut ctx = CompactTx::new();
let mut txid = vec![0; 32];

View File

@ -844,7 +844,7 @@ mod tests {
// Create a fake CompactBlock containing the note
let mut cout = CompactSaplingOutput::new();
cout.set_cmu(cmu);
cout.set_epk(epk);
cout.set_ephemeralKey(epk);
cout.set_ciphertext(enc_ciphertext.as_ref()[..52].to_vec());
let mut ctx = CompactTx::new();
let mut txid = vec![0; 32];
@ -903,7 +903,7 @@ mod tests {
let mut cout = CompactSaplingOutput::new();
cout.set_cmu(cmu);
cout.set_epk(epk);
cout.set_ephemeralKey(epk);
cout.set_ciphertext(enc_ciphertext.as_ref()[..52].to_vec());
cout
});
@ -931,7 +931,7 @@ mod tests {
let mut cout = CompactSaplingOutput::new();
cout.set_cmu(cmu);
cout.set_epk(epk);
cout.set_ephemeralKey(epk);
cout.set_ciphertext(enc_ciphertext.as_ref()[..52].to_vec());
cout
});