mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Small modifications to support new cryptoconditions
This commit is contained in:
parent
95cd4037d5
commit
470f2694d7
@ -533,7 +533,14 @@ class Transaction(object):
|
|||||||
def gen_public_key(private_key):
|
def gen_public_key(private_key):
|
||||||
# TODO FOR CC: Adjust interface so that this function becomes
|
# TODO FOR CC: Adjust interface so that this function becomes
|
||||||
# unnecessary
|
# unnecessary
|
||||||
return private_key.get_verifying_key().to_ascii().decode()
|
|
||||||
|
# cc now provides a single method `encode` to return the key
|
||||||
|
# in several different encodings.
|
||||||
|
public_key = private_key.get_verifying_key().encode()
|
||||||
|
# Returned values from cc are always bytestrings so here we need
|
||||||
|
# to decode to convert the bytestring into a python str
|
||||||
|
return public_key.decode()
|
||||||
|
|
||||||
key_pairs = {gen_public_key(SigningKey(private_key)):
|
key_pairs = {gen_public_key(SigningKey(private_key)):
|
||||||
SigningKey(private_key) for private_key in private_keys}
|
SigningKey(private_key) for private_key in private_keys}
|
||||||
|
|
||||||
@ -573,7 +580,9 @@ class Transaction(object):
|
|||||||
fulfillment = deepcopy(fulfillment)
|
fulfillment = deepcopy(fulfillment)
|
||||||
owner_before = fulfillment.owners_before[0]
|
owner_before = fulfillment.owners_before[0]
|
||||||
try:
|
try:
|
||||||
fulfillment.fulfillment.sign(tx_serialized,
|
# cryptoconditions makes no assumptions of the encoding of the
|
||||||
|
# message to sign or verify. It only accepts bytestrings
|
||||||
|
fulfillment.fulfillment.sign(tx_serialized.encode(),
|
||||||
key_pairs[owner_before])
|
key_pairs[owner_before])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise KeypairMismatchException('Public key {} is not a pair to '
|
raise KeypairMismatchException('Public key {} is not a pair to '
|
||||||
@ -608,7 +617,9 @@ class Transaction(object):
|
|||||||
'to any of the private keys'
|
'to any of the private keys'
|
||||||
.format(owner_before))
|
.format(owner_before))
|
||||||
|
|
||||||
subffill.sign(tx_serialized, private_key)
|
# cryptoconditions makes no assumptions of the encoding of the
|
||||||
|
# message to sign or verify. It only accepts bytestrings
|
||||||
|
subffill.sign(tx_serialized.encode(), private_key)
|
||||||
self.fulfillments[index] = fulfillment
|
self.fulfillments[index] = fulfillment
|
||||||
|
|
||||||
def fulfillments_valid(self, input_conditions=None):
|
def fulfillments_valid(self, input_conditions=None):
|
||||||
@ -669,7 +680,10 @@ class Transaction(object):
|
|||||||
|
|
||||||
# NOTE: We pass a timestamp to `.validate`, as in case of a timeout
|
# NOTE: We pass a timestamp to `.validate`, as in case of a timeout
|
||||||
# condition we'll have to validate against it
|
# condition we'll have to validate against it
|
||||||
return parsed_ffill.validate(message=tx_serialized,
|
|
||||||
|
# cryptoconditions makes no assumptions of the encoding of the
|
||||||
|
# message to sign or verify. It only accepts bytestrings
|
||||||
|
return parsed_ffill.validate(message=tx_serialized.encode(),
|
||||||
now=gen_timestamp()) and input_cond_valid
|
now=gen_timestamp()) and input_cond_valid
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user