Skip to main content

ed521rs

CI PyPI crates.io docs.rs 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.
  • 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.

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, 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

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.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.1.0
File Size Uploaded Provenance Actions
ed521rs-0.1.0.tar.gz 146.8 kB With provenance Details for ed521rs-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ed521rs 0.1.0
File Actions
ed521rs-0.1.0-cp311-abi3-win_arm64.whl CPython 3.11 abi3 Windows ARM64 Details for ed521rs-0.1.0-cp311-abi3-win_arm64.whl
ed521rs-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for ed521rs-0.1.0-cp311-abi3-win_amd64.whl
ed521rs-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for ed521rs-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
ed521rs-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details for ed521rs-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
ed521rs-0.1.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.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ed521rs-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for ed521rs-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ed521rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for ed521rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
ed521rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for ed521rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 3.8 MB

Release files / ed521rs-0.1.0.tar.gz

Download URL ed521rs-0.1.0.tar.gz
Size 146.8 kB
Tags Source
SHA-256 checksum
How to use checksums
48fefd97d3d6e6c39caf2ff5999a689ebf4425f37be2ed112bcde0dcf1caeadf
BLAKE2b-256 checksum
How to use checksums
aa3ce0961fb7e09ce17c4dbdf66aeec4d6a4b65b39a9105f14681a06abc67301
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-win_arm64.whl
Size 339.5 kB
Tags CPython 3.11 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
b012bc0c3c38a4123ebe051eac6c1adf873c7292e6872919d071d428de5b84cc
BLAKE2b-256 checksum
How to use checksums
67c5dd1c115d85de8bfa0d45514c4d66e7ccf44bfa2634ee06bc719f855a4a1b
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-win_amd64.whl
Size 335.6 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f86ea28cb828e52a10e30e09a42bfd3c08ab0bba5841e0aadd103352abdc2d4f
BLAKE2b-256 checksum
How to use checksums
4f4034799ff31556896e44fcd8440a42aa635d018b6f1ed43ff71e067e49510a
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
Size 653.5 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
87bf432600665b94c9f2bfd5cb48c905e9f753c70e58d469db0f726d03210960
BLAKE2b-256 checksum
How to use checksums
4088b73a93f208fd1be666704eecf3467ca79cdb9568580dd810408b2f07a689
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
Size 630.6 kB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
3990f5dbd0ac6d29dd02028027fea7001496c1b801e3cb874ee56d9650a3438f
BLAKE2b-256 checksum
How to use checksums
243247c1808380e5891e0e148d8bd0f9bcfd623ca24adf2cad062f6a787b113c
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 442.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f6264bd49ad1c1f6525ffef489c85521d241158a0039b04c03380a8904b5db4f
BLAKE2b-256 checksum
How to use checksums
e5fa9129ee71cfb0b4cf706ad6a76580bc0b9b871c662d46b72cebc2a7385316
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 453.1 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
810abc928a5cb6322e2c176e660392054e185db32d45ef1dbecc15e5de280fe4
BLAKE2b-256 checksum
How to use checksums
2e88321c678f3fc7e2b467a8a5e4c1b8895e7d13780c79a09b5ca1c9fd4e63cb
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 407.1 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
75c5bd2fc60d1723d79ce8bae35257890e071b94d84ce988578118126985d8f4
BLAKE2b-256 checksum
How to use checksums
b7af1bfb6858c4861869f84235c87d3b2017bfd1d3a8ac1bdbbf0f7af203ebd3
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 7, 2026.

Transparency log

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

Download URL ed521rs-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 422.3 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e2889a02252970ebee63ea5726a830e49edc64f233ea26e5a5d343cf42564976
BLAKE2b-256 checksum
How to use checksums
ce5cdb630cb5b9b71c2cdd7e38e9454417ab9d0ff81b47d29c1d2246016f259d
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 7, 2026.

Transparency log

Security for ed521rs 0.1.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.1.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 7, 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