Formats and errors
Formats
Section titled “Formats”pk1.<kid>.<key> public keypq1.<kid>.<enc>.<ct> sealed messageAll parts in Base64URL without padding, kid is 8 bytes long. The prefixes carry the format version. A public key has about 1.6 KiB, a message at least about 1.9 KiB.
- HPKE info:
pq-seal v1 - Additional data:
pq1|<kid>|<context> - Plaintext before encrypting: 4 bytes of length (big endian), the data, then zeros up to the next multiple of 256 bytes
testdata/vectors.json pins the format.
Formats of signing
Section titled “Formats of signing”sp1.<key> public key, 2,607 characterssg1.<signature> signature, 4,416 characterswk1.<memory>.<passes>.<salt>.<box> private key under a passphrase, 131 characterswk1.<memory>.<passes>.<salt> its header, 34 characterswa1.<value> proof of the passphrase (auth), 47 charactersmemory (in KiB) and passes are decimal numbers in their only spelling, everything else is Base64URL without padding.
- Signature: ML-DSA-65 (FIPS 204), the context is the context of ML-DSA, 1 to 255 bytes
- Derivation: Argon2id with a 16-byte salt, at least 64 MiB and 3 passes, one lane. From it with HKDF-SHA256 the wrapping key (
pqsign wrap v1) andauth(pqsign auth v1) - Box: a 24-byte nonce, then the 32-byte seed under XChaCha20-Poly1305, bound to the header
The Go test TestKnownAnswer and the browser test e2e/sign.spec.js pin the format with the same key.
Errors
Section titled “Errors”Errors when opening do not say what is wrong with the content and never quote it. In Go they are the values in the table, in the browser a SealError with code. The status is a suggestion by pqhttp.ErrorStatus.
| Go | code | HTTP | Meaning |
|---|---|---|---|
ErrUnknownKey | unknown_key | 409 | Key rotated or restart, seal again |
ErrReplay | replay | 409 | Message was already opened |
ErrVersion | bad_version | 400 | Unknown format version |
ErrOpenFailed | open_failed | 400 | Damaged, altered, wrong context or invalid JSON |
ErrBadKey | bad_key | 400 | Public key invalid |
ErrContext | bad_context | 400 | Context is empty |
ErrTooLarge | too_large | 413 | Larger than MaxBytes |
ErrClosed | closed | 503 | Sealer or client is closed |
load_failed | Browser only: files or key cannot be loaded | ||
worker_failed | Browser only: worker crashed or does not answer, connect again | ||
internal | 500 | Unexpected error |
Errors of signing
Section titled “Errors of signing”In Go they come from pqsign, in the browser it is the same SealError.
| Go | code | Meaning |
|---|---|---|
ErrBadSignature | bad_signature | Signature malformed, or it does not belong to key, message and context |
ErrUnlockFailed | unlock_failed | Wrong passphrase, or the wrapped key is malformed or was altered |
ErrParams | bad_params | Cost below the floor or above the limit |
ErrPassphrase | bad_passphrase | Passphrase is empty |
ErrBadKey | bad_key | Public key invalid |
ErrContext | bad_context | Context empty or longer than 255 bytes |
ErrVersion | bad_version | Unknown format version |
no_key | Browser only: the key was forgotten or the unlock is already used |