This documentation is slowly being reviewed, so you may see some inconsistencies between sections.
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Padmé

Purpose

The length of a ciphertext from a stream cipher is equal to the length of the plaintext. Similarly, block cipher padding only adds a small overhead. This metadata can leak information about what was encrypted and thus is something protocols may want to hide.

Padmé is a popular deterministic padding scheme with overhead capped to at most +12%, which decreases with input length. It tells you how much padding to add but does not define how that padding should be implemented.

The idea is that multiple input lengths result in the same output length (grouping into buckets), and the number of inputs that map to the same bucket grows. This means the output length hides the exact input length within that range of inputs, preventing padded objects from being uniquely identifiable via their size.

Usage

GetPaddedSize

Returns the padded length deterministically calculated from the unpadded length.

ulong paddedSize = Padme.GetPaddedSize(ulong unpaddedSize);

Exceptions

ArgumentOutOfRangeException

unpaddedSize is greater than MaxUnpaddedSize.

OverflowException

The calculation has resulted in an overflow.

GetPaddingSize

Returns the difference between the padded length and unpadded length (the amount of padding). This is not for removing padding.

Exceptions

ArgumentOutOfRangeException

unpaddedSize is greater than MaxUnpaddedSize.

OverflowException

The calculation has resulted in an overflow.

Constants

These are used for validation and/or save you from defining your own constants.

Notes

The main argument for it being deterministic is that adversaries can cancel out randomised padding with repeated observations to reveal the actual length, which is especially problematic in networking-style scenarios. It also leads to a simple design with predictable overhead.

Last updated