diff --git a/apps/python/zcash_fpga.py b/apps/python/zcash_fpga.py index 5f69ea9..735cf71 100644 --- a/apps/python/zcash_fpga.py +++ b/apps/python/zcash_fpga.py @@ -1,5 +1,5 @@ - + class zcash_fpga: import serial import codecs @@ -19,13 +19,13 @@ 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':[]}} - - def __init__(self, COM='COM4'): + + def __init__(self, COM='COM4'): self.s = self.serial.Serial(COM, 921600, timeout=1) #Test getting FPGA status self.get_status() @@ -42,9 +42,9 @@ class zcash_fpga: # Parse reply - should be reset res = self.get_reply() if (self.struct.unpack(' 0: self.print_reply(res) @@ -52,9 +52,9 @@ class zcash_fpga: else: print ("INFO: No reply received") return None - + def secp256k1_verify_sig(self, index, hsh, r, s, Qx, Qy): - cmd = '00000101000000B0' + cmd = '00000101000000B0' cmd = format(index, 'x').ljust(16, '0') + cmd cmd = format(s, 'x').ljust(64, '0') + cmd cmd = format(r, 'x').ljust(64, '0') + cmd @@ -68,7 +68,16 @@ class zcash_fpga: res = self.get_reply() if res is not None and (self.struct.unpack('