Poly1305
Bernstein's fast one-time authenticator, paired with ChaCha20 in RFC 8439
About Poly1305
Poly1305 is a message authentication code. It uses a 32-byte (256-bit) key and a 16-byte (128-bit) authentication tag. Its registry entry cites RFC 8439. NextSSL lists it in the standard tier and exposes it through the safe API.
Overview
Poly1305 is a one-time message authentication code designed by Daniel J. Bernstein. Combined with ChaCha20 in the ChaCha20-Poly1305 AEAD, it is one of the two dominant authenticated-encryption constructions on the internet alongside AES-GCM.
Poly1305 evaluates a polynomial over the prime field modulo 2^130 − 5. The message is split into 16-byte chunks, each extended with a 1 bit, and the polynomial with these chunks as coefficients is evaluated at a secret point r, with certain bits of r clamped to zero for efficient implementation. A second secret s is added to the result modulo 2^128 to produce a 16-byte tag.
The pair (r, s) must be used for only one message. In ChaCha20-Poly1305 a fresh key pair is derived for each message from the first ChaCha20 keystream block. Poly1305 was originally published in 2005 with AES generating s; RFC 8439 standardises it with ChaCha20. It is constant-time when implemented carefully.
History
2005–2018Poly1305-AES published by Daniel J. Bernstein
ChaCha20-Poly1305 specified in RFC 7539
Updated in RFC 8439
Security notes
Poly1305 is secure only if each key is used once. Reusing a key for two messages allows forgeries. Within AEAD constructions with unique nonces this holds automatically.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| key | 32 | Secret key |
| tag | 16 | Authentication tag |
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
key = ns.random(32)
tag = ns.call("mac", "poly1305", None, key, b"message", 0)[0]
ok = ns.check("mac_verify", "poly1305", None, key, b"message", tag)
nextssl_mac("poly1305", NULL, key, data, 0, tag);
nextssl_mac_verify("poly1305", NULL, key, data, tag);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_mac_in(reg::all(), Policy::Safe, "poly1305", &Params::new())?;
let tag = alg.tag(&key, b"message")?;
let ok = alg.verify(&key, b"message", &tag)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Similar names
Looking for something else?More message authentication codes
All 30Frequently asked questions
What is Poly1305?
Poly1305 is a MAC in the Poly1305 family. Poly1305 is a one-time message authentication code designed by Daniel J. Bernstein.
What are the Poly1305 sizes?
In NextSSL, Poly1305 uses: key 32 bytes, tag 16 bytes.
Who designed Poly1305 and when?
Poly1305 belongs to the Poly1305 family, first published in 2005 by Daniel J. Bernstein. Its origin: RFC 8439.
Which standards define Poly1305?
Poly1305 is referenced by RFC 8439.
Is Poly1305 safe to use?
Poly1305 is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.
Related families
ARX stream cipher with a one-time Poly1305 MAC; fast and constant-time in software
AES-GMACThe authentication-only mode of AES-GCM: a nonce-based MAC from GHASH and AES
GHASHThe GF(2^128) polynomial hash at the core of AES-GCM and GMAC
ChaChaBernstein's ARX stream cipher; ChaCha20 secures much of today's TLS, SSH and VPN traffic
Salsa20Bernstein's eSTREAM-portfolio ARX stream cipher and the core of scrypt and NaCl