Class ChaChaHeaderCodec

java.lang.Object
zeroecho.core.alg.chacha.ChaChaHeaderCodec
All Implemented Interfaces:
SymmetricHeaderCodec

public final class ChaChaHeaderCodec extends Object implements SymmetricHeaderCodec

ChaCha20 streaming header codec

Implements SymmetricHeaderCodec for the ChaCha20 stream cipher. Encodes a compact header containing:
  • a 12-byte nonce (IV), and
  • the stream counter as a 7-bit packed integer.

The nonce and counter are exchanged through the bound CtxInterface using ConfluxKeys.iv(String) and ConfluxKeys.tagBits(String) keys, namespaced by the algorithm id (e.g., "CHACHA20").

Header layout

 [0..11]   : 12-byte nonce (IV)
 [12..N]   : counter encoded via 7-bit packed integer

Behavior

  • writeHeader: requires iv(id) in context (12 bytes). Writes the nonce, then the counter from tagBits(id) if present, otherwise uses 1.
  • readHeader: reads nonce and counter and stores them into the context under the same keys.
Since:
1.0
  • Constructor Details

    • ChaChaHeaderCodec

      public ChaChaHeaderCodec()
      Creates a stateless ChaCha20 stream-header codec.
  • Method Details