2222logger = logging .getLogger (__name__ )
2323
2424import binascii
25- import secp256k1
26-
2725
2826# -----------------------------------------------------------------
2927# -----------------------------------------------------------------
@@ -49,51 +47,6 @@ def read_transaction_keys_from_file(key_file, search_path, \
4947
5048 return txn_keys
5149
52- # -----------------------------------------------------------------
53- # -----------------------------------------------------------------
54- class TransactionKeys (object ) :
55- """
56- Wrapper for managing Sawtooth transaction keys
57- """
58-
59- @classmethod
60- def read_from_file (cls , file_name , search_path = ['.' , './keys' ]) :
61- full_file = putils .find_file_in_path (file_name , search_path )
62- with open (full_file , "r" ) as ff :
63- hex_encoded_private_key = ff .read ()
64-
65- priv = binascii .unhexlify (hex_encoded_private_key )
66- return cls (secp256k1 .PrivateKey (priv ))
67-
68- @classmethod
69- def from_hex (cls , hex_encoded_private_key ) :
70- priv = binascii .unhexlify (hex_encoded_private_key )
71- return cls (secp256k1 .PrivateKey (priv ))
72-
73- def __init__ (self , private_key = None ) :
74- if private_key == None :
75- private_key = secp256k1 .PrivateKey ()
76-
77- self .public_key = private_key .pubkey
78- self .private_key = private_key
79-
80- @property
81- def hashed_identity (self ) :
82- key_byte_array = crypto .string_to_byte_array (self .txn_public )
83- hashed_txn_key = crypto .compute_message_hash (key_byte_array )
84- encoded_hashed_key = crypto .byte_array_to_hex (hashed_txn_key )
85- encoded_hashed_key = encoded_hashed_key .lower ()
86- return encoded_hashed_key
87-
88- @property
89- def txn_private (self ) :
90- return self .private_key .serialize ()
91-
92- @property
93- def txn_public (self ) :
94- return self .public_key .serialize ().hex ()
95-
96-
9750# -----------------------------------------------------------------
9851# -----------------------------------------------------------------
9952class EnclaveKeys (object ) :
0 commit comments