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.10-cp310-cp310-win_amd64.whl (162.9 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 10.12+ x86-64

ferrite-0.1.10-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.10-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ferrite-0.1.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a6ca69d03eb3dcb9af1be99342608d1a90f2c4614db7b775536000018f14f0a8
MD5 6c30ef5ae93af065785cf74bc08d8e0d
BLAKE2b-256 6a904659e640a30e0e2cedbaffdf2289aaff8e989360e62c789d6604c6488d21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferrite-0.1.10-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0eff21a10003c1da6b24a898d6f8744362bac6e9ffe79e4184fbca0849eba9e0
MD5 84455647b862d2c9becb7e66c0d2c58f
BLAKE2b-256 880b4ba69fc29a496f4363bf4a6c826c125cd879e66471189229155c9e6bacfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferrite-0.1.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 184d3577c8653a4b9d6da8b474f1c008eda4c307044e1efb3a5bab1af2d38fa6
MD5 4d166f063f62194ad8b4f709fe747e7c
BLAKE2b-256 8f3c4a81911c32d45b39e9ce5f32cbeb7f2f8aa611427fe8fc04aae04d1a82bb

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