Fast verification of Ed521 signatures (EdDSA over the Edwards curve E-521, specified by ICP-Brasil in DOC-ICP-01.01) in Rust, with Python bindings. Ed521 is the signature scheme of the UE2020 and UE2022 voting machines of Brazil's Superior Electoral Court (TSE): every file an urn publishes is signed with it.
Before this project, every available Ed521 verifier was a generic big-integer implementation. A national audit needs about nine million verifications per election; ed521rs takes them from about 25 CPU-hours in pure Python to about 18 CPU-minutes.
⚠ This code has not been independently audited. It is checked against TSE's own reference verifier, real signatures published by TSE, 34 crafted edge cases and differential fuzzing, but no third party has reviewed it. Read SECURITY.md before relying on it.
| Install | Docs | |
|---|---|---|
| Python | pip install ed521rs (CPython 3.11+, wheels for Linux, macOS and Windows) |
this page |
| Rust | cargo add ed521 (no_std, MSRV 1.87) |
docs.rs/ed521 |
Python
import hashlib
import ed521rs
# TSE's urns sign SHA-512(h), where h is the SHA-512 hash of the file.
ok = ed521rs.verify(public_key, signature, hashlib.sha512(listed_hash).digest())
ed521rs.reason(public_key, signature, message) # "ok" or a reason code
key = ed521rs.VerifyingKey(public_key) # decode once per key
results = key.verify_many(signatures, messages) # exact, one bool per signature
reasons = key.reason_many(signatures, messages) # exact, one reason code each
ca = ed521rs.VerifyingKey(ca_key, precompute=True) # about 2x faster per call, for busy keys
# Pre-filter only: one bool for the whole batch (cofactored, probabilistic).
if not key.verify_batch(signatures, messages):
reasons = key.reason_many(signatures, messages)
- Same verdicts everywhere. Every exact entry point (
verify,reason,verify_many,reason_many,verify_packed, with or withoutprecompute) returns the same verdict for the same input. - Automatic speedups.
verify_manyand friends precompute on their own from four signatures and share field inversions. - Threads and the GIL.
- Every call releases the GIL.
threads(default 1) caps the threads one call may use.
- Hashable keys. Keys compare and hash by their bytes and mode (precomputed or not), so a dict can cache one precomputed key per distinct key.
- Input types. Arguments accept
bytes,bytearray,memoryviewor any other buffer. - Reason codes. They are stable strings (
non_canonical_r,s_out_of_range,invalid_signature, ...), suitable for audit status columns. - Audit metadata.
ed521rs.__version__anded521rs.backend()("avx2"or"serial") identify the build for audit manifests.
docs/election-audit.md has notes on adopting ed521rs in election-audit, including a parity gate before switching.
Rust
use ed521::{Mode, Signature, VerifyingKey};
let key = VerifyingKey::from_bytes_with_mode(&public_key, Mode::Strict)?;
key.verify(message, &Signature::from_bytes(&signature))?;
See the crate documentation and its README.
Semantics
Verification checks the cofactorless equation [S]B = R + [k]A with
k = SHAKE256("SigEd521" 00 00 || R || A || M, 132) mod L. Two modes decide which encodings are
accepted; they differ only on inputs an honest signer never produces.
mode="strict" (default) |
mode="ecpy" |
|
|---|---|---|
| matches | RFC 8032 decoding; the pure-Python verifier of election-audit | ECPy at commit 8143d9ac, pinned by TSE's reference verifier |
| y of R and A | below p | any 527-bit value, taken mod p |
| x = 0 with the sign bit | rejected | accepted |
| S | below L | any 528-bit value, taken mod L, except S = 0 mod L |
| small-order A ([4]A = O) | the equation, as for any key | [S]B = R, R canonical |
The last two ecpy rules reproduce ECPy's arithmetic rather than the equation. ECPy maps
S = 0 mod L to its point at infinity, which never equals a curve point. Its ladder uses the
dedicated (non-unified) addition, which collapses [k]A to that point whenever A has order 1, 2
or 4. The edge-case vectors pin every rule against both ECPy and the pure-Python reference.
Running both modes and flagging any signature where they differ is a cheap audit check: on real data they should never differ.
verify_batch checks [4](Σ z_i (R_i + [k_i]A_i − [S_i]B)) = O, for 128-bit coefficients drawn
from SHAKE256 over all the inputs.
- It is cofactored, so it also accepts signatures off by a point of order 2 or 4. Exact verification rejects those, and an honest signer never makes one.
- A batch containing a forgery passes with probability about 2^-127.
- It is a pre-filter, never a verdict.
Performance
One thread of an Intel i7-9750H (Coffee Lake, AVX2), in µs per signature:
| Rust | Python | |
|---|---|---|
| pure-Python reference (election-audit) | 9 818 | |
verify |
269 | 314 |
verify with a precomputed key |
136 | 153 |
urn section (decode the key, then verify_many on 12 signatures) |
112 | 123 |
verify_many on 64 signatures, precomputed key, AVX2 |
92 | |
verify_batch on 12 signatures (pre-filter) |
59 | 67 |
BENCHMARKS.md has the full tables and the measurements behind each design choice.
Backends
On CPUs with AVX2 (detected at run time), verify_many and its variants run four signatures'
scalar multiplications at once, one in each 64-bit lane.
- Single and batch verification use the portable serial backend everywhere: the vector code measured no real gain there.
- Results never depend on the backend.
RUSTFLAGS='--cfg ed521_backend="serial"'forces the serial backend at build time.
Test vectors and their provenance
The vectors live in crates/ed521/tests/vectors/, so the published crate carries its
own tests. Each one records where it came from.
tse-2026.json: 18 real signatures from TSE's 2026 election (round 2, Acre).- Urn signatures on one section's files and on its vote-hash chain.
- The AC UE2020 and AC UE2022 signatures on urn certificates and on their revocation lists.
- Each source file is pinned by its official TSE URL and SHA-256.
scripts/tse_vectors.pyrebuilds the file from TSE's originals:just tse-fetchdownloads the urn files from TSE's results site. TSE's other servers turn away scripts, so it prints the browser links for the format package and the revocation lists, then checks their hashes.just tse-vectorsdecodes the sources with TSE's own ASN.1 specifications and requires the result to equal the committed file.
ecpy.json: the two Ed521 vectors published in ECPy.- ECPy is the library TSE's reference verifier uses.
- One of them pins the key expansion that the test-only signer reproduces.
edge-cases.json: 34 crafted cases with each mode's verdict, taken from running the oracles themselves.- The cases cover non-canonical encodings, S at and above L, and small-order points.
- The oracles are ECPy at TSE's pinned commit and the pure-Python reference.
tests/python/reference_ed521.py is a verbatim, hash-checked copy of
election_audit/ed521.py from election-audit. The Python suite checks ed521rs against it, and
against ECPy, on random signatures and mutations of them. just fuzz runs three cargo-fuzz
targets against an independent big-integer model.
Development
Development needs just, uv and a Rust toolchain; MSRV checks also need Rust 1.87, and fuzzing needs nightly.
just setup # .venv with maturin, ruff, ty, asn1tools and the ECPy oracle
just check # format, clippy, Rust tests (both backends, no_std, MSRV), vectors, Python tests
just bench # criterion; `python scripts/bench.py` times the Python entry points
just fuzz 600 # differential fuzzing, 10 minutes per target
Bug reports and feature requests go to the issue tracker; report security problems, including any wrong verdict, privately as described in SECURITY.md. CONTRIBUTING.md explains the development setup and what a change needs before it can be merged.
CHANGELOG.md lists the changes in each release, and RELEASING.md describes how releases are published.
License
MIT.
Metadata
Release files for ed521rs 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ed521rs-0.1.1.tar.gz | 148.8 kB | With provenance | Details for ed521rs-0.1.1.tar.gz |
Built distributions (wheels)
Total release size: 3.9 MB
Release files / ed521rs-0.1.1.tar.gz
| Download URL | ed521rs-0.1.1.tar.gz |
|---|---|
| Size | 148.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ccb333d0d4a689fb78d78f544a4cfaa9b1ea299584bcc8e0c2e249e91813a0f4
|
|
BLAKE2b-256 checksum How to use checksums |
884e20cfa2a4f5a1e086b3dcf2fdab6de8204cfb01649c0abd1963393357371c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-win_arm64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-win_arm64.whl |
|---|---|
| Size | 342.4 kB |
| Tags | CPython 3.11 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
83bab2b0c0222d9cc2170e5b40312db1da74d034591dcac6baf8cd761487669f
|
|
BLAKE2b-256 checksum How to use checksums |
d759f8d59aac21063a0e321a23e64edb84d7827220cbf9038b9f78143c00dc10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-win_amd64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 338.3 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d04ae4535c72c3ba164dc015cf9c8d88911b510359555c4df63bccf7dbc9ae8a
|
|
BLAKE2b-256 checksum How to use checksums |
bce0a1f233dafd4575c743cc2beab67c6ea83c31b8eeaf3d3d2de524016691e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 656.3 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f460498636998ec569dbd67e09a0affed20f5f78d108fc0760a8e8db98f6d3dd
|
|
BLAKE2b-256 checksum How to use checksums |
fca8f6c4b2d39886c62e29e596ec3d16a34cffcae96e5e17d8a592cb5014514a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 633.6 kB |
| Tags | CPython 3.11 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
9951c18124130da6089b6b7151192d6c543d612e54c4c2e1d32051df56d24761
|
|
BLAKE2b-256 checksum How to use checksums |
03b52b5c1265c7c0e18e722c2ff114d38b85f75e89ed2dda8d55356fa72ed87e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 445.0 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0e8e279d1b76236f36829a9f8200771c40fadefd2b2966efc89845be15f14da4
|
|
BLAKE2b-256 checksum How to use checksums |
b28634a1eb29b6b708f77a78e5fbfb9e4537981afe37316d0c48c33b73a5e51f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 455.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a343ebda921cc50c85850f878f3560533a0c5a647f0f52e664835c1a6712134a
|
|
BLAKE2b-256 checksum How to use checksums |
2ca5b240d366db7258b00f0767757850cdca7d068343455fd64a974b0b07ef72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 410.0 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
92692bff93e530ff03cf9bef9ad8ee560c175b7fe965d3d16e8c810f58ce4bf3
|
|
BLAKE2b-256 checksum How to use checksums |
3ceaf1accd547ab502d15be8c4f35c30da37e885489f742da9d5556b43c4d09e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ed521rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | ed521rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 424.9 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
5051ff63b5acb684e33acafeefffda374b773c638816dc5528983d0013a2b732
|
|
BLAKE2b-256 checksum How to use checksums |
df5fce71de6c33bbedf0eaea751f88290a84694f12d331f8e43726728114efbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logSecurity for ed521rs 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for ed521rs-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.