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

WIP: Feature/transaction rlp update #2

Open
wants to merge 3 commits into
base: feature/1-ED25519
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Move to using the signature bytes
  • Loading branch information
ConnorMac committed Aug 23, 2018
commit 839a66d1b908a7c95bcb69604aceee72bb080ae4
12 changes: 2 additions & 10 deletions eth_keys/backends/ed25519/ed25519.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
big_endian_to_int,
)


# Verification algorithm
def ecdsa_verify(msg_hash: bytes,
signature: Tuple[int, int, int],
@@ -39,16 +40,7 @@ def ecdsa_raw_sign(msg_hash: bytes,
private_key_bytes: bytes) -> Tuple[int, int, int]:
private_key = SigningKey(bytes(private_key_bytes))
signature_bytes = private_key.sign(msg_hash)
print('THIS IS A TEST')
print(signature_bytes)
print(signature_bytes[:32])
print(signature_bytes[32:64])
R = big_endian_to_int(signature_bytes[:32])
S = big_endian_to_int(signature_bytes[32:])
total_sig = big_endian_to_int(signature_bytes)
print(R)
print(S)
return 1, R, S, signature_bytes, total_sig
return signature_bytes


def private_key_to_public_key(private_key_bytes: bytes) -> bytes:
4 changes: 2 additions & 2 deletions eth_keys/backends/ed25519/main.py
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ class TwistedEdwardsECCBackend(BaseECCBackend):
def ecdsa_sign(self,
msg_hash: bytes,
private_key: PrivateKey) -> Signature:
signature_vrs = ecdsa_raw_sign(msg_hash, private_key.to_bytes())
signature = Signature(vrs=signature_vrs, backend=self)
signature_bytes = ecdsa_raw_sign(msg_hash, private_key.to_bytes())
signature = Signature(signature_bytes=signature_bytes, backend=self)
return signature

def ecdsa_verify(self,
8 changes: 3 additions & 5 deletions eth_keys/datatypes.py
Original file line number Diff line number Diff line change
@@ -256,18 +256,16 @@ def __init__(self,
try:
self.r = big_endian_to_int(signature_bytes[0:32])
self.s = big_endian_to_int(signature_bytes[32:64])
self.v = ord(signature_bytes[64:65])
self.v = 1
self.signature_bytes = signature_bytes
except ValidationError as err:
raise BadSignature(str(err))
elif vrs:
v, r, s, signature_bytes, total_sig = vrs
v, r, s = vrs
try:
self.v = v
self.r = r
self.s = s
self.signature_bytes = signature_bytes
self.total_sig = total_sig
self._signature_bytes = signature_bytes
except ValidationError as err:
raise BadSignature(str(err))
else:
2 changes: 1 addition & 1 deletion eth_keys/validation.py
Original file line number Diff line number Diff line change
@@ -72,5 +72,5 @@ def validate_private_key_bytes(value: Any) -> None:

def validate_signature_bytes(value: Any) -> None:
validate_bytes(value)
if len(value) != 65:
if len(value) != 64:
raise ValidationError("Unexpected signature format. Must be length 65 byte string")