Skip to main content
ed521rs: fast Ed521 signature verification in Rust and Python

CI PyPI Python crates.io MSRV docs.rs OpenSSF Scorecard OpenSSF Best Practices License: MIT

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 without precompute) returns the same verdict for the same input.
  • Automatic speedups. verify_many and 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, memoryview or 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__ and ed521rs.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.

Neither mode validates the public key. Under a small-order key ([4]A = O, orders 1, 2 and 4) one fixed signature verifies for every message, so callers whose keys are not otherwise vouched for should check the key's order: VerifyingKey.is_small_order() (Rust: VerifyingKey::is_small_order) reports it, and VerifyingKey(key, reject_small_order=True) (Rust: reject_small_order()) refuses such a key with small_order_public_key. Both are opt-in; the modes themselves are unchanged.

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.py rebuilds the file from TSE's originals:
      • just tse-fetch downloads 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-vectors decodes 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.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ed521rs 0.2.0
File Size Uploaded Provenance Actions
ed521rs-0.2.0.tar.gz 150.0 kB With provenance Details for ed521rs-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ed521rs 0.2.0
File Actions
ed521rs-0.2.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for ed521rs-0.2.0-cp311-abi3-win_arm64.whl
ed521rs-0.2.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for ed521rs-0.2.0-cp311-abi3-win_amd64.whl
ed521rs-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for ed521rs-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl
ed521rs-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details for ed521rs-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl
ed521rs-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for ed521rs-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ed521rs-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for ed521rs-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ed521rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for ed521rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
ed521rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for ed521rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 3.9 MB

Release files / ed521rs-0.2.0.tar.gz

Download URL ed521rs-0.2.0.tar.gz
Size 150.0 kB
Tags Source
SHA-256 checksum
How to use checksums
714f0c3ec15fe7c32ad7efce9602c6f8140da42e5ebdd3fd93f53ce5f211713f
BLAKE2b-256 checksum
How to use checksums
3ac197fbc356e0a7a65030c03cc3dbc92f4356b515f92f3569468b6c85df4ec9
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-win_arm64.whl

Download URL ed521rs-0.2.0-cp311-abi3-win_arm64.whl
Size 356.0 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
1cbeb8792e83635d0603834e45b517e18fc065f954040aa3688dae2c9b12de58
BLAKE2b-256 checksum
How to use checksums
d3e40af982c342b3463d8821cdae33dda7340dead0718fdfa96fa2ebeb73d51b
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-win_amd64.whl

Download URL ed521rs-0.2.0-cp311-abi3-win_amd64.whl
Size 348.2 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
95d97b6cb0fd56040aaaa8f8922960321f50144cde91fcfc68077e15d23be258
BLAKE2b-256 checksum
How to use checksums
a6f62d4de5d8f6dc65765039dce007c47fe4efd9316a3936cf52b55e1c4dc98f
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL ed521rs-0.2.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 666.2 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
43ff9e2d5b8587c1fd23d6201da178b8ae07058078a9d682e1ffb81954b07167
BLAKE2b-256 checksum
How to use checksums
3bcd45ee92b118ff3f272a6613747af40f5df321f047258b15373419b63e52f9
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL ed521rs-0.2.0-cp311-abi3-musllinux_1_2_aarch64.whl
Size 647.7 kB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
635fc730bf4573fff2514c022283718166ef51846989db4a9b25c3dbf52cae24
BLAKE2b-256 checksum
How to use checksums
dabce77c97dc768b05ab2418ae5be6301774a979ab2dc3e39c4c680e11fc8cb7
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ed521rs-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 455.0 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5208698b27db45b8bd3bb16bf071ebbf9265f3a19cb80e5902c6988a402e6a89
BLAKE2b-256 checksum
How to use checksums
53ca3efc3250d64b56798948853a845ee3323ac8c22b7e0c29637d3740f3f928
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ed521rs-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 469.6 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
1641b1e29a78b8af9fa2e74272bbbcfa5e798e18a6df925b3af16530572b7485
BLAKE2b-256 checksum
How to use checksums
46f816775810bab5910aee875ef4a7ffdc3c12b058745759878997ae1fc2d14c
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL ed521rs-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Size 420.5 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
96f3d0d1446b298b8901cdc39fca6bb7719f3ae38cd67fa73ee4f1a52d5be8ba
BLAKE2b-256 checksum
How to use checksums
ee1c3425689678ad94129971dd27be846ba88e8cdeed4c3b879da05c34c8493e
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 10, 2026.

Transparency log

Release files / ed521rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL ed521rs-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 435.6 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b4f3336d3a30a733de82365dead56c5ab40466f57f397ea3f2d5fe368a5aa8ed
BLAKE2b-256 checksum
How to use checksums
63cfc29cd909ed71d4845b1231b5063ee315b10aea9566aa66e67ec1996cb845
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 10, 2026.

Transparency log

Security for ed521rs 0.2.0

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.

Select from 9 files

Attestation for ed521rs-0.2.0.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 10, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page