---
title: "Signature compression"
description: "Compressing CAdES signatures with CadesSignatureCompression in PKI SDK, which reuses repeated CRLs and certificates and reaches over 90% compression."
canonical: "https://docs.lacunasoftware.com/en-us/articles/pki-sdk/signatures/cades/compression"
locale: "en"
product: "PKI SDK"
last_updated: "2026-10-12"
---

# Signature compression

The usual data compression methods, applied to each signature on its own, give poor results when you store a large number
of signatures. That is exactly where the PKI SDK method works best.

Compressing each signature on its own finds little redundancy. Taken as a set, though, stored signatures are highly
redundant: CRLs, certificates and other structures repeat across many signatures made in a similar period.

With the SDK's signature compression, you can reach compression rates above 90%.

## Compressing a signature

The @Lacuna.Pki.Cades.CadesSignatureCompression class compresses signatures. Its compression and decompression methods use
an implementation of @Lacuna.Pki.Stores.ISimpleStore, which stores the data that tends to be shared among signatures. The
code below compresses a signature and detaches its encapsulated content:

```cs
// bytes of a CAdES signature to compress
byte[] sigContent = ...

// Simple store backed by the file system, in the temporary directory
var store = new FileSystemSimpleStore(Path.GetTempPath());

byte[] eContent;

// Compressing the signature, with the eContent detached
byte[] compressed = CadesSignatureCompression.Compress(sigContent, store, out eContent);

// Decompressing the signature
byte[] decompressed = CadesSignatureCompression.Decompress(compressed, store, eContent);

if (sigContent.SequenceEqual(decompressed)) {
    Console.WriteLine("OK!");
} else {
    Console.WriteLine("NOT OK!");
}
```

The @Lacuna.Pki.Stores.ISimpleStore object is central to signature compression. The example above uses a
@Lacuna.Pki.Stores.FileSystemSimpleStore, which stores the compression data in the directory passed to its constructor.
To use other storage, such as a database or cloud servers, implement the @Lacuna.Pki.Stores.ISimpleStore interface.

## See also

* @Lacuna.Pki.Cades.CadesSignatureCompression
* @Lacuna.Pki.Stores.ISimpleStore
* @Lacuna.Pki.Stores.FileSystemSimpleStore
* [Optional Nuget packages](https://docs.lacunasoftware.com/en-us/articles/pki-sdk/optional-packages)
