Skip to content

Commit f331a7a

Browse files
authored
chore: improve naming and comments (#780)
1 parent adb407d commit f331a7a

File tree

9 files changed

+21
-14
lines changed

9 files changed

+21
-14
lines changed

crates/common/src/encoding.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct Encodings {
1919
}
2020

2121
/// Transfers the encodings using the provided seed and keys.
22+
///
23+
/// The keys must be consistent with the global delta used in the encodings.
2224
pub async fn transfer(
2325
ctx: &mut Context,
2426
secret: &EncoderSecret,
@@ -70,6 +72,8 @@ pub async fn transfer(
7072
}
7173

7274
/// Receives the encodings using the provided MACs.
75+
///
76+
/// The MACs must be consistent with the global delta used in the encodings.
7377
pub async fn receive(
7478
ctx: &mut Context,
7579
sent_macs: impl IntoIterator<Item = &'_ Block>,
@@ -132,7 +136,7 @@ impl EncodingProvider for Provider {
132136
Direction::Received => &self.recv,
133137
};
134138

135-
let mut encoding = Vec::with_capacity(idx.len());
139+
let mut encoding = Vec::with_capacity(idx.len() * ENCODING_SIZE);
136140
for range in idx.iter_ranges() {
137141
let start = range.start * ENCODING_SIZE;
138142
let end = range.end * ENCODING_SIZE;

crates/core/src/transcript.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ pub use proof::{
5252
TranscriptProof, TranscriptProofBuilder, TranscriptProofBuilderError, TranscriptProofError,
5353
};
5454

55-
/// A transcript contains all the data communicated over a TLS connection.
55+
/// A transcript contains the plaintext of all application data communicated
56+
/// between the Prover and the Server.
5657
#[derive(Clone, Serialize, Deserialize)]
5758
pub struct Transcript {
5859
/// Data sent from the Prover to the Server.

crates/core/src/transcript/encoding/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub trait Encoder {
8484

8585
impl Encoder for ChaChaEncoder {
8686
fn encode_idx(&self, direction: Direction, idx: &Idx) -> Vec<u8> {
87-
// ChaCha20 encoder works with 32-bit words. Each encoded bit is 128 bits long.
87+
// ChaCha encoder works with 32-bit words. Each encoded bit is 128 bits long.
8888
const WORDS_PER_BYTE: u128 = 8 * 128 / 32;
8989

9090
let stream_id: u64 = match direction {

crates/notary/server/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ pub async fn run_server(config: &NotaryServerProperties) -> Result<(), NotarySer
211211
.with_upgrades()
212212
.await;
213213
}
214+
214215
Err(err) => {
215216
error!("{}", NotaryServerError::Connection(err.to_string()));
216217
}

crates/prover/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl Prover<state::Setup> {
275275
}),
276276
};
277277

278-
// Pull out ZK VM
278+
// Pull out ZK VM.
279279
let (_, vm) = Arc::into_inner(vm)
280280
.expect("vm should have only 1 reference")
281281
.into_inner()

crates/prover/src/notarize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Prover<Notarize> {
9191

9292
let attestation = mux_fut
9393
.poll_with(async {
94-
debug!("starting finalization");
94+
debug!("sending attestation request");
9595

9696
ctx.io_mut().send(request.clone()).await?;
9797

crates/verifier/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ impl Verifier<state::Setup> {
223223
{
224224
let mut vm = vm.try_lock().expect("VM should not be locked");
225225

226-
// Prove received plaintext. Prover drops the proof output, as they trust
227-
// themselves.
226+
// Prepare for the prover to prove received plaintext.
228227
let proof = commit_records(
229228
&mut (*vm.zk()),
230229
&mut zk_aes,
@@ -272,7 +271,7 @@ impl Verifier<state::Setup> {
272271
transcript_length: TranscriptLength { sent, received },
273272
};
274273

275-
// Pull out ZK VM
274+
// Pull out ZK VM.
276275
let (_, vm) = Arc::into_inner(vm)
277276
.expect("vm should have only 1 reference")
278277
.into_inner()

crates/verifier/src/notarize.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ impl Verifier<Notarize> {
4343
.sent()
4444
.iter()
4545
.flat_map(|plaintext| vm.get_keys(*plaintext).expect("reference is valid"))
46-
.map(|mac| mac.as_block());
46+
.map(|key| key.as_block());
4747
let recv_keys = transcript_refs
4848
.recv()
4949
.iter()
5050
.flat_map(|plaintext| vm.get_keys(*plaintext).expect("reference is valid"))
51-
.map(|mac| mac.as_block());
51+
.map(|key| key.as_block());
5252

53+
// Convert encodings into a structured format.
5354
encoding::transfer(&mut ctx, &encoder_secret, sent_keys, recv_keys).await?;
5455

5556
// Receive attestation request, which also contains commitments required before

crates/verifier/src/verify.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,18 @@ impl Verifier<VerifyState> {
6262

6363
self.state.vm.flush(&mut self.state.ctx).await.unwrap();
6464

65-
let mut purported_data = Vec::new();
65+
let mut authenticated_data = Vec::new();
6666
for mut fut in plaintext_futs {
6767
let plaintext = fut
6868
.try_recv()
6969
.map_err(VerifierError::zk)?
7070
.expect("plaintext should be decoded");
71-
purported_data.extend_from_slice(&plaintext);
71+
authenticated_data.extend_from_slice(&plaintext);
7272
}
7373

74-
// Check that purported values are correct.
75-
if purported_data
74+
// Check that the purported data in the partial transcript is
75+
// correct.
76+
if authenticated_data
7677
.into_iter()
7778
.zip(
7879
partial_transcript

0 commit comments

Comments
 (0)