Skip to main content

High-performance Rust-based signer for web3.py.

Project description

Ferrite: High-performance eth-account signer

PyPI version License: MIT Python Versions Build Status

High-performance Rust-based signer for eth-account

Ferrite is a Python module that dramatically accelerates Ethereum cryptographic operations by replacing the core signing logic in eth-account with a highly optimized Rust implementation.

Simply import the module, and your existing eth-account code will run significantly faster with zero code changes required.


Key Features

  • Blazing Fast: Up to 50x faster than the standard eth-account implementation.
  • Drop-in Replacement: Just import ferrite at the start of your application. No code refactoring is needed.
  • Zero-Overhead: The patch is applied once on import, with no performance penalty during runtime.
  • Reliable & Secure: Built on top of the same production-grade cryptographic libraries used in the wider Rust-Ethereum ecosystem.

Installation

pip install ferrite

Quickstart

Import ferrite at the top of your application's entrypoint. The module will automatically "monkey patch" the eth-account library.

Before Ferrite

# your_app.py
from eth_account import Account
from eth_account.messages import encode_defunct

private_key = "0x..." # Your private key
account = Account.from_key(private_key)
message = encode_defunct(text="hello world")

signed_message = account.sign_message(message)

print(f"Signature: {signed_message.signature.hex()}")

After Ferrite

# your_app.py
import ferrite  # <-- Just add this one line at the top!

from eth_account import Account
from eth_account.messages import encode_defunct

private_key = "0x..." # Your private key
account = Account.from_key(private_key)
message = encode_defunct(text="hello world")

signed_message = account.sign_message(message)

print(f"Signature: {signed_message.signature.hex()}")

Development & Contribution

This project is built using maturin.

Prerequisites

  • Rust: Install via rustup
  • Python: Version 3.8 or higher
  • maturin: pip install maturin

Development Setup

  1. Clone the repository:

    git clone https://github.com/satoshiburger/ferrite.git
    cd ferrite
    
  2. Development Installation:

    maturin develop
    pip install pytest black mypy
    
  3. Run Tests:

    python -m pytest
    cargo test
    

Project Structure

ferrite/
├── __init__.py # Main module interface and monkey patching
├── account.py  # Core patching logic for eth-account
└── lib.rs      # Rust implementation

Dependencies

  • eth-account>=0.8.0,<0.9.0

Performance

Operation Standard (Python) Ferrite (Rust) Improvement
Sign Message ~2.1ms ~0.04ms 50x faster
Sign Hash ~1.8ms ~0.03ms 60x faster

Performance measured on Intel i7-9750H, single-threaded. Results may vary.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ferrite-0.1.1-cp310-cp310-win_amd64.whl (162.9 kB view details)

Uploaded CPython 3.10Windows x86-64

ferrite-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl (276.7 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

ferrite-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (364.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file ferrite-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: ferrite-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 162.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for ferrite-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 dbec89a6b337aaa23945f9cff85cceaf7a3594de216fc51030fccbafdedb84d2
MD5 2e6e790669879b93c1cd63df6943791f
BLAKE2b-256 c356a1a3af41da9163e41cf46233b0f8f7d6f15831cfe33afdcc082747dd4387

See more details on using hashes here.

File details

Details for the file ferrite-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ferrite-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e3f9e20cb42e331dbefd680095deee9cc6ccefc311643dceb3c1d40aae85eb7f
MD5 3ca53de1cb04702e030f76af09df8665
BLAKE2b-256 9c3802bf25a9e026cecd240cdfe5936ad6339ad8d5fcf32e87f82915f942a367

See more details on using hashes here.

File details

Details for the file ferrite-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferrite-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf48f9a26d4c7aebd16a57269b5916b4dbdb7aba020973347d072206c9d07476
MD5 31b158da78df3887073281e7b310f4ba
BLAKE2b-256 39d1c86435412767e5054503a3f6f8e0ce529536f5bc537118450f3f4dda1fc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page