PqForgeSecureSession class final

Encrypts and decrypts application payloads into self-describing AEAD wire packets, with an explicit choice of cipher suite and backend engine.

final session = PqForgeSecureSession(
  secretKey: derivedHybridKey,                       // 32 bytes
  cipherSuite: PqForgeCipherSuite.chaCha20Poly1305,
  engineProvider: PqForgeEngineProvider.pureDart,    // or .nativeCryptography
);

final packet = await session.encrypt(payload, associatedData: header);
final clear  = await session.decrypt(packet, associatedData: header);
session.dispose(); // wipe the key when finished

Wire format

Every packet is a single contiguous byte array:

+-----------------------------+------------------------------------+
|      Nonce / IV (12 B)      |      Ciphertext + Tag (variable)   |
+-----------------------------+------------------------------------+

encrypt generates a fresh cryptographically secure nonce, prepends it, and appends the AEAD ciphertext-and-tag. decrypt slices the leading PqForgeCipherSuite.nonceLength bytes back off as the nonce before authenticating the remainder. Because both engines emit the identical ciphertext || tag layout, a packet produced by one PqForgeEngineProvider decrypts cleanly under the other.

Constructors

PqForgeSecureSession({required Uint8List secretKey, required PqForgeCipherSuite cipherSuite, PqForgeEngineProvider engineProvider = PqForgeEngineProvider.pureDart})
Creates a session bound to secretKey, a cipherSuite, and an engineProvider (defaults to PqForgeEngineProvider.pureDart).

Properties

cipherSuite → PqForgeCipherSuite
The negotiated AEAD cipher suite.
final
engineProvider → PqForgeEngineProvider
The backend performing the AEAD computation.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

decrypt(Uint8List packet, {Uint8List? associatedData}) → Future<Uint8List>
Decrypts a wire packet produced by encrypt (from either backend).
dispose() → void
Zeroizes the session's internal copy of the secret key.
encrypt(Uint8List payload, {Uint8List? associatedData}) → Future<Uint8List>
Encrypts payload into a nonce || ciphertext || tag wire packet.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited