Skip to content
Snippets Groups Projects

#95, #172: BBC: Arguments changes on 'Documents' constructors: Remove 'signature', introduce 'signing_key', make 'currency' and 'version' optionals

Merged #95, #172: BBC: Arguments changes on 'Documents' constructors: Remove 'signature', introduce 'signing_key', make 'currency' and 'version' optionals
Merged Vincent Texier requested to merge document_init_refactor into dev

Files

+ 12
1
@@ -12,7 +12,6 @@
@@ -12,7 +12,6 @@
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import re
import attr
import attr
@@ -26,6 +25,7 @@ from ...constants import (
@@ -26,6 +25,7 @@ from ...constants import (
WS2P_PUBLIC_PREFIX_REGEX,
WS2P_PUBLIC_PREFIX_REGEX,
WS2PID_REGEX,
WS2PID_REGEX,
)
)
 
from ...key import VerifyingKey
from ..block_uid import BlockUID
from ..block_uid import BlockUID
from ..document import MalformedDocumentError
from ..document import MalformedDocumentError
@@ -126,6 +126,17 @@ class HeadV0(Head):
@@ -126,6 +126,17 @@ class HeadV0(Head):
)
)
return "{0}:{1}".format(str(self.api), ":".join(values))
return "{0}:{1}".format(str(self.api), ":".join(values))
 
def check_signature(self, pubkey: str) -> bool:
 
"""
 
Check if Head signature is from head pubkey
 
 
:param pubkey: Pubkey to check signature upon
 
:return:
 
"""
 
verifying_key = VerifyingKey(pubkey)
 
 
return verifying_key.check_signature(self.inline(), self.signature)
 
@attr.s()
@attr.s()
class HeadV1(HeadV0):
class HeadV1(HeadV0):
Loading