python script updates
This commit is contained in:
parent
f496533acc
commit
28363d8ae3
|
@ -19,7 +19,7 @@ class zcash_fpga:
|
|||
'RESET_FPGA_RPL':int('80000000', 16),
|
||||
'VERIFY_SECP256K1_SIG_RPL':int('80000101', 16)}
|
||||
|
||||
fpga_msg_dict = {fpga_msg_type_dict['VERIFY_SECP256K1_SIG_RPL']:{'name':'FPGA_IGNORE_RPL', 'feilds':[(8, 'index', byt_to_hex), (1, 'bm', byt_to_hex)]},
|
||||
fpga_msg_dict = {fpga_msg_type_dict['VERIFY_SECP256K1_SIG_RPL']:{'name':'VERIFY_SECP256K1_SIG_RPL', 'feilds':[(8, 'index', byt_to_hex), (1, 'bm', byt_to_hex)]},
|
||||
fpga_msg_type_dict['FPGA_IGNORE_RPL']:{'name':'FPGA_IGNORE_RPL', 'feilds':[(8, 'ignored_header', byt_to_hex)]},
|
||||
fpga_msg_type_dict['FPGA_STATUS_RPL']:{'name':'FPGA_STATUS_RPL', 'feilds':[(4, 'version', byt_to_ver), (8, 'build_date', byt_to_str), (8, 'buid_host', byt_to_str), (8, 'cmd_cap', byt_to_hex)]},
|
||||
fpga_msg_type_dict['RESET_FPGA_RPL']:{'name':'RESET_FPGA_RPL', 'feilds':[]}}
|
||||
|
@ -68,6 +68,15 @@ class zcash_fpga:
|
|||
res = self.get_reply()
|
||||
if res is not None and (self.struct.unpack('<I', res[4:8])[0] != self.fpga_msg_type_dict['VERIFY_SECP256K1_SIG_RPL']):
|
||||
print("ERROR: Reply type was not VERIFY_SECP256K1_SIG_RPL")
|
||||
return False
|
||||
if (self.struct.unpack('<I', res[8:16])[0] != index):
|
||||
print("ERROR: Index did not match")
|
||||
return False
|
||||
if (self.struct.unpack('<I', res[16:17])[0] != 0):
|
||||
print("ERROR: Result bitmask was non-zero")
|
||||
return False
|
||||
print("INFO: Secp256k1 signature verified correctly")
|
||||
return True
|
||||
|
||||
def close(self):
|
||||
self.s.close()
|
||||
|
@ -94,6 +103,7 @@ class zcash_fpga:
|
|||
#Example usages:
|
||||
def example_secp256k1_sig():
|
||||
zf = zcash_fpga()
|
||||
zf.reset_fpga() # Reset incase somethign went wrong last run
|
||||
|
||||
index = 1234
|
||||
hsh = 34597931798561447004034205848155169322219865803759328163562698792725658370004
|
||||
|
|
Loading…
Reference in New Issue