Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Patch pedersen hash with cpp native implementation #110

Merged
merged 1 commit into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cairo-lang = "0.8.2.1"
dill = "~0.3.4"
meinheld = "~1.0.2"
Werkzeug = "~2.0.3"
crypto-cpp-py = "^1.0.3"

[tool.poetry.dev-dependencies]
pylint = "~2.12.2"
Expand Down
21 changes: 21 additions & 0 deletions starknet_devnet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
"""
Contains the server implementation and its utility classes and functions.
"""
import sys
from starkware.crypto.signature.fast_pedersen_hash import pedersen_hash
from crypto_cpp_py.cpp_bindings import cpp_hash


__version__ = "0.2.2"


def patched_pedersen_hash(left: int, right: int) -> int:
"""
Pedersen hash function written in c++
"""
return cpp_hash(left, right)


# This is a monkey-patch to improve the performance of the devnet
# We are using c++ code for calculating the pedersen hashes
# instead of python implementation from cairo-lang package
setattr(
sys.modules["starkware.crypto.signature.fast_pedersen_hash"],
"pedersen_hash",
patched_pedersen_hash,
)
2 changes: 1 addition & 1 deletion starknet_devnet/blueprints/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from starknet_devnet.state import state
from .shared import validate_transaction

gateway = Blueprint("gateay", __name__, url_prefix="/gateway")
gateway = Blueprint("gateway", __name__, url_prefix="/gateway")

@gateway.route("/is_alive", methods=["GET"])
def is_alive():
Expand Down