Table of Contents

Class EncryptedGguf

Namespace
LMKit.Cryptography
Assembly
LM-Kit.NET.dll

Produces and consumes encrypted GGUF containers whose tensor bytes can be decrypted in-place, on the fly, at any plaintext offset. The on-disk layout is:

[ 0..  4)  Magic "LMKE"
[ 4..  8)  Format version (uint32 LE)              = 1
[ 8.. 12)  Encryption scheme (uint32 LE)           see 
[12.. 28)  PBKDF2 salt (16 bytes, random)
[28.. 44)  AES-CTR nonce (16 bytes, random, used as initial counter block)
[44.. 48)  PBKDF2 iteration count (uint32 LE)
[48.. 56)  Plaintext total size (uint64 LE)        = size of original GGUF file
[56.. 64)  Plaintext metadata size (uint64 LE)     = gguf_get_data_offset of original GGUF
[64..  N)  AES-CTR ciphertext of the full plaintext GGUF, byte-for-byte

The plaintext-to-ciphertext mapping is 1:1 (CTR is a stream cipher), so a plaintext offset P maps to container file offset (P + HeaderSize).

public static class EncryptedGguf
Inheritance
EncryptedGguf
Inherited Members

Methods

Encrypt(string, string, GgufEncryptionScheme, string, int)

Encrypt a plaintext GGUF file into an LM-Kit encrypted container.

Share