Hello, def SignVer(m, s, h, q, p, g, beta): v = pow(g, s, p) * pow(beta, h, p) % p v_bytes = v.to_bytes((v.bit_length() + 7) // 8, byteorder='big') concatenated = m + v_bytes u = int.from_bytes(sha3_256(concatenated).digest(), byteorder='big') % q if u == h: return 0 else: return -1 when this function is called in def CheckBlockofTransactions(): f = open("transactions.txt", "r") tx_block = f.readlines() f.close() if len(tx_block) % 7 != 0: print("Incorrect file format") else: tx_block_count = len(tx_block) // 7 result = [0] * tx_block_count for i in range(0, tx_block_count): pk = int(tx_block[i * 7 + 6][25:]) s = int(tx_block[i * 7 + 1][15:]) h = int(tx_block[i * 7 + 2][15:]) tx = "".join(tx_block[i * 7 + 3: i * 7 + 7]) result[i] = DS.SignVer(tx.encode('UTF-8'), s, h, q, p, g, pk) return result this function it always returns -1 what might be the issue? Thanks.
submitted by /u/saltinbokka
[link] [comments]
r/learnpython Hello, def SignVer(m, s, h, q, p, g, beta): v = pow(g, s, p) * pow(beta, h, p) % p v_bytes = v.to_bytes((v.bit_length() + 7) // 8, byteorder=’big’) concatenated = m + v_bytes u = int.from_bytes(sha3_256(concatenated).digest(), byteorder=’big’) % q if u == h: return 0 else: return -1 when this function is called in def CheckBlockofTransactions(): f = open(“transactions.txt”, “r”) tx_block = f.readlines() f.close() if len(tx_block) % 7 != 0: print(“Incorrect file format”) else: tx_block_count = len(tx_block) // 7 result = [0] * tx_block_count for i in range(0, tx_block_count): pk = int(tx_block[i * 7 + 6][25:]) s = int(tx_block[i * 7 + 1][15:]) h = int(tx_block[i * 7 + 2][15:]) tx = “”.join(tx_block[i * 7 + 3: i * 7 + 7]) result[i] = DS.SignVer(tx.encode(‘UTF-8’), s, h, q, p, g, pk) return result this function it always returns -1 what might be the issue? Thanks. submitted by /u/saltinbokka [link] [comments]
Hello, def SignVer(m, s, h, q, p, g, beta): v = pow(g, s, p) * pow(beta, h, p) % p v_bytes = v.to_bytes((v.bit_length() + 7) // 8, byteorder='big') concatenated = m + v_bytes u = int.from_bytes(sha3_256(concatenated).digest(), byteorder='big') % q if u == h: return 0 else: return -1 when this function is called in def CheckBlockofTransactions(): f = open("transactions.txt", "r") tx_block = f.readlines() f.close() if len(tx_block) % 7 != 0: print("Incorrect file format") else: tx_block_count = len(tx_block) // 7 result = [0] * tx_block_count for i in range(0, tx_block_count): pk = int(tx_block[i * 7 + 6][25:]) s = int(tx_block[i * 7 + 1][15:]) h = int(tx_block[i * 7 + 2][15:]) tx = "".join(tx_block[i * 7 + 3: i * 7 + 7]) result[i] = DS.SignVer(tx.encode('UTF-8'), s, h, q, p, g, pk) return result this function it always returns -1 what might be the issue? Thanks.
submitted by /u/saltinbokka
[link] [comments]