LrtcEnvelope class
The LRTC encrypted file format, version 2.
[magic "LRTC" (4B)] [version (1B)] [keyId (2B, BE)] [labelLen (1B)]
[label (labelLen B, UTF-8)] [IV (12B)] [ciphertext ‖ GCM tag (16B)]
AES-256-GCM with the whole header as additional authenticated data, so tampering with the IV, keyId, or label is detected by the tag at the end of the sealed payload.
The label identifies the model and is mixed into key derivation, so two models encrypted with the same master key end up with different working keys — leaking one model's derived key does not unlock the others.
Version 1 (AES-CTR + HMAC-SHA256, written by litert_crypto 0.1.0) is not readable; parsing reports it with a re-encrypt hint. The format changed when decryption moved to BoringSSL, whose one-shot AEAD is the fast path.
Constructors
- LrtcEnvelope({required int version, required int keyId, required String label, required Uint8List header, required Uint8List iv, required Uint8List sealed})
-
const
- LrtcEnvelope.parse(Uint8List bytes)
-
Parses
bytes. Throws InvalidFormatException if they are not a valid LRTC envelope.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- header → Uint8List
-
The raw header bytes, authenticated as the AEAD's additional data.
final
- iv → Uint8List
-
final
- keyId → int
-
Key identifier for key rotation, taken from the envelope header.
final
- label → String
-
Model identifier mixed into key derivation.
final
- plainLength → int
-
Model size in bytes once decrypted.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sealed → Uint8List
-
Ciphertext with the 16-byte GCM tag appended — the AEAD's input shape.
final
- version → int
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
) → Uint8List - Serializes this envelope back into the LRTC byte layout.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
Constants
- currentVersion → const int
- fixedHeaderLength → const int
- magic + version + keyId + labelLen.
- ivLength → const int
- AES-GCM nonce length (the 96-bit fast path every implementation takes).
-
magic
→ const List<
int> - maxLabelLength → const int
- Labels are length-prefixed with a single byte.
- tagLength → const int
- AES-GCM tag length, appended to the ciphertext inside sealed.