Skip to main content

safe-eth-native

Native (Rust) versions of the hot paths of safe-eth-py:

Function Replaces Backed by
ecrecover(message_hash, v, r, s) -> bytes | None eth-keys ecdsa_recover libsecp256k1
p256_verify(message_hash, r, s, public_key_x, public_key_y) -> bool safe_eth.safe.p256.verify RustCrypto p256
keccak256(data) -> bytes pysha3 keccak_256 tiny-keccak
to_checksum_address(value) -> str fast_to_checksum_address
is_checksum_address(value) -> bool fast_is_checksum_address

ecrecover and p256_verify follow the input rules of the EVM ecrecover and P256VERIFY precompiles: v must be 27 or 28, r and s in [1, n - 1], and high s values are accepted. Values out of those ranges return None / False instead of raising; only a wrong type, or a hash that is not 32 bytes for ecrecover, raises. Both release the GIL while they run, and so does keccak256 for inputs of 2048 bytes or more. keccak256 hashes the raw bytes of bytes or of any C-contiguous buffer, like hashlib.

The package is not meant to be used directly. Install it with the native extra of safe-eth-py, which uses it when it is installed and falls back to the Python code when it is not:

pip install "safe-eth-py[native]"

Wheels

Platforms: Linux (glibc 2.28+ and musl) x86_64 and aarch64, macOS x86_64 and arm64, and Windows x86_64. For each one:

  • One abi3 wheel for CPython 3.11 and newer, 3.15 included
  • One wheel per free-threaded CPython version, 3.14t and 3.15t, as abi3 wheels do not load on free-threaded builds. The module runs without the GIL: importing it does not enable the GIL again

Other platforms and Python versions build from the sdist, which needs a Rust toolchain and a C compiler.

Development

From the root of the safe-eth-py repository, uv sync --group dev --all-extras --frozen builds the extension and installs it in the safe-eth-py environment, and pytest native/tests runs its tests. uv rebuilds it when a file in src/ changes.

The tests compare every function with reference implementations (eth-keys, eth-utils, pycryptodome, and pysha3 in the safe-eth-py tests) and run the vectors of the Keccak team, Wycheproof, EIP-55, and the test suites of go-ethereum, eth-keys, eth-utils, coincurve and libsecp256k1. See tests/vectors for their sources. CI runs them on every wheel except the musl ones, which are built but not tested.

Releasing

Bump version in Cargo.toml, then push a native-v<version> tag on a commit of main. Push only the tag: a GitHub release would also run the safe-eth-py release workflow, for nothing. The Native extension workflow builds the wheels and the sdist and publishes them to PyPI with trusted publishing. Before the first release, add a trusted publisher (a pending one while the project does not exist) on PyPI for safe-global/safe-eth-py and the native.yml workflow.

Metadata

Release files for safe-eth-native 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 safe-eth-native 0.2.0
File Size Uploaded Provenance Actions
safe_eth_native-0.2.0.tar.gz 11.3 kB Without provenance Details for safe_eth_native-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for safe-eth-native 0.2.0
File Interpreter ABI Platform Actions
safe_eth_native-0.2.0-cp315-cp315t-manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.28+ x86-64 Details for safe_eth_native-0.2.0-cp315-cp315t-manylinux_2_28_x86_64.whl
safe_eth_native-0.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 Details for safe_eth_native-0.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl
safe_eth_native-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for safe_eth_native-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl

Total release size: 4.3 MB

Release files / safe_eth_native-0.2.0.tar.gz

Download URL safe_eth_native-0.2.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6d4af3e70a3a00a498a1542fd0500ab539f634b4b895bdefbfdc1d4bd333a613
BLAKE2b-256 checksum
How to use checksums
81241def89ddce33eaf14f794ff3be99108ff83ed95f00c0c4850b31a835e35f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / safe_eth_native-0.2.0-cp315-cp315t-manylinux_2_28_x86_64.whl

Download URL safe_eth_native-0.2.0-cp315-cp315t-manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
16e246eeab772039d8aa9615fa2d5e7abcf3a412c171e5052641e76f280795c1
BLAKE2b-256 checksum
How to use checksums
e5955f8b19723fe17e0095faabee4a4f7edbeb00ca49e98b325de3281d999f12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / safe_eth_native-0.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl

Download URL safe_eth_native-0.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
483cd3b1f8252578499ca65b472735ac8e9259fe0fd41ce7957566b8ff58cbc1
BLAKE2b-256 checksum
How to use checksums
6b3e22f1e8bf6e832e48fe332e5aab3310f084fe382a83f1ce8890003b89d0d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / safe_eth_native-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL safe_eth_native-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 1.4 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
0e37fe01443401c218046e3256b28f322f97571f3b6cabe5b3dc3eb10374950d
BLAKE2b-256 checksum
How to use checksums
0dfad2c4d05977de3e18bf116fcfb2a9ad182d134b8121eb103e986447fbef3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for safe-eth-native 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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