Signature r+s concatenation serialization.

pull/157/head
jMyles 2018-02-10 19:05:36 -08:00
parent 24bbac9ae1
commit 440e3e13b6
1 changed files with 11 additions and 5 deletions

View File

@ -43,8 +43,14 @@ class Signature(object):
return encode_dss_signature(self.r, self.s)
def __bytes__(self):
"""
Implements the __bytes__ call for Signature to transform into a
transportable mode.
"""
return self.sig_as_bytes
# A couple quick assertions to be sure this is OK. Remove these at some point.
assert self.r.to_bytes(33, "big")[0] == 0, "Is 32 bytes enough?"
assert self.s.to_bytes(33, "big")[0] == 0, "Is 32 bytes enough?"
return self.r.to_bytes(32, "big") + self.s.to_bytes(32, "big")
def __len__(self):
return len(bytes(self))
def __add__(self, other):
return bytes(self) + other
__radd__ = __add__