Transaction Sealing

Algorithms are demonstrated in Python. Source formatting it a bit crap for now. If you have no interest in reading the code, you can skip this post.

import hashlib
def transaction_sealer():
'''Return the default digest function for sealing transactions.'''
#return hashlib.sha384()
return hashlib.sha1()

def transaction_seal(xid,data):
'''Compute the digest of a transaction and double-hash it.'''
s1 = transaction_sealer()
s1.update("%010d\t%s" % (xid,data) )
d1 = s1.hexdigest()
s2 = transaction_sealer()
s2.update("%010d\t%s\t%s" % (xid,d1,data) )
seal = s2.hexdigest()
return seal

def transaction_format(xid,seal,data):
'''Format transaction line record.'''
return "%010d\t%s\t%s" % (xid,seal,data)


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s