Skip to content

Commit

Permalink
Fix ecdsa error
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchocholaty committed Nov 5, 2024
1 parent 94b4ecd commit 4ebef60
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ecdsa==0.19.0
pycryptodome==3.20.0
#sha3==0.2.1
6 changes: 5 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
#venv/bin/pip install --upgrade pip
#venv/bin/pip install -r requirements.txt
#source /venv/bin/activate
python3 src/main.py --mempool=mempool > output.txt
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements.txt
source venv/bin/activate
python3 src/main.py --mempool=mempool > output.txt
6 changes: 4 additions & 2 deletions src/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import hashlib
import ecdsa
from src.op_codes import OP_CODES
from Crypto.Hash import RIPEMD160

class InvalidScriptException(Exception):
"""Custom exception for Script execution errors"""
Expand Down Expand Up @@ -301,8 +302,9 @@ def op_hash160(self) -> None:
raise InvalidScriptException("Cannot HASH160 empty stack")
value = self.stack.pop()
sha256 = hashlib.sha256(value).digest()
ripemd160 = hashlib.new('ripemd160', sha256).digest()
self.stack.push(ripemd160)
ripemd160 = RIPEMD160.new()
ripemd160.update(sha256)
self.stack.push(ripemd160.digest())

def op_equalverify(self) -> None:
"""Verify top two stack items are equal"""
Expand Down
4 changes: 2 additions & 2 deletions src/transaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib
import json

from ecdsa import VerifyingKey, SECP256k1, BadSignatureError
#from ecdsa import VerifyingKey, SECP256k1, BadSignatureError

from src.script import Script, InvalidScriptException
from src.serialize import serialize_transaction
Expand Down Expand Up @@ -307,4 +307,4 @@ def validate_p2sh_p2wpkh(self, vin_idx, vin):
except BadSignatureError:
return False
return True """
return True """

0 comments on commit 4ebef60

Please sign in to comment.