Skip to content

Commit 82ea15a

Browse files
committed
fix: add docs on performance tests of buffers
1 parent 85049b4 commit 82ea15a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

protocol/src/fschacha20poly1305.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
//! Wrap ciphers with automatic re-keying in order to provide [forward secrecy](https://eprint.iacr.org/2001/035.pdf) within a session.
44
//! Logic is covered by the BIP324 test vectors.
5+
//!
6+
//! ## Performance Considerations
7+
//!
8+
//! This module uses small stack-allocated arrays (12-byte nonces, 32-byte keys) for temporary
9+
//! cryptographic operations. These allocations are intentionally kept as local variables rather
10+
//! than pre-allocated struct fields for optimal performance.
11+
//!
12+
//! Tests comparing the current implementation against a version with
13+
//! pre-allocated buffers to reduce stack allocations showed decreased performance.
14+
//!
15+
//! * **FSChaCha20 operations** +3.7% overhead with pre-allocated buffers.
16+
//! * **FSChaCha20Poly1305 operations** +1.0% overhead with pre-allocated buffers.
517
618
use chacha20_poly1305::{chacha20::ChaCha20, ChaCha20Poly1305, Key, Nonce};
719
use core::fmt;

0 commit comments

Comments
 (0)