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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 10.12+ x86-64

ferrite-0.1.9-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.9-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: ferrite-0.1.9-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.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9c178c9e3744eaf04b4baccf38e62e968cc04777fa1525a48bcf2f17ca92cffa
MD5 feda5dc2077b958c27ccf543f24c80ce
BLAKE2b-256 b5b1384e1c1499472cfdb870413445ea481b6ce674beb52746128e1a534f49c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferrite-0.1.9-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3d47011ef859368a5fbaec4048afb01b87dd111861b033dac561a264c3d81502
MD5 c1a98b8da9578caaed7351839e44d26b
BLAKE2b-256 e6afcf751839d5b04f8b32a03cc4ab1a5df98e826ef2ea8dd0c9702a47445587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ferrite-0.1.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7f6e8e1a924de05d75fec1c1f59524862e7265cb2e9fa1c931474c7f769087b8
MD5 3ad15d7ced66ac0b7a33cf08957e0c21
BLAKE2b-256 ae67e64c0bba68ba9fd03eff5199b9f1c4e226a4aafd7fb9541ae2df3e921c63

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