diff --git a/common.py b/common.py index 8af946c..9f9d694 100644 --- a/common.py +++ b/common.py @@ -45,4 +45,4 @@ def otherIndex(n): def doesHashMatchDifficulty(hashed): hashedInteger = int(hashed, 16) hashedDifficulty = hashedInteger / LEAST_DIFFICULT_HASH - return hashedDifficulty <= MAXIMUM_HASH_DIFFICULTY \ No newline at end of file + return hashedDifficulty <= MAXIMUM_HASH_DIFFICULTY diff --git a/meta.py b/meta.py index 30c31ef..a60cbb1 100755 --- a/meta.py +++ b/meta.py @@ -34,6 +34,9 @@ while True: write(prover, 'indexesRequest.txt') getProgramLine(prover) + with open('indexesRequest.txt') as f: + print(f.read()) + write(verifier, 'entries.txt') result = ' '.join(getProgramLine(verifier).split()[1:]) print(result) diff --git a/prover.py b/prover.py index 0ef4b43..21ac83d 100755 --- a/prover.py +++ b/prover.py @@ -2,7 +2,7 @@ ## Proof of Space-Time prover -import math, common, ast +import math, common, ast, sys # For the ratio between storing and power: # Note that for a production ready system hashing speedup (as designed for Bitcoin in [AsicBoost - A Speedup for Bitcoin Mining, Dr. Timo Hanke, March 31, 2016 (rev. 5)](https://arxiv.org/pdf/1604.00575.pdf)) should be considered. @@ -26,7 +26,7 @@ while len(STORED_NONCES) < common.ENTRIES_NUMBER: deltaCounter = counter - lastCounter STORED_NONCES += [deltaCounter] lastCounter = counter - print(len(STORED_NONCES), common.ENTRIES_NUMBER) + print(len(STORED_NONCES), common.ENTRIES_NUMBER, file=sys.stderr) counter += 1 ## Execution phase: 1. Receive a random bitstring from the verifier. diff --git a/verifier.py b/verifier.py index 7f6e9b9..e392792 100755 --- a/verifier.py +++ b/verifier.py @@ -2,19 +2,19 @@ ## Proof of Space-Time verifier -import secrets, common, ast +import secrets, common, ast, sys ## Initialization phase: Generate a random bitstring to send to the prover. # To make sure that the following protocol execution can't be used partially or totally by the prover to reduce the cost of another protocol execution. -protocolInitializationPhaseId = secrets.token_hex(common.SECURITY_PARAMETER // 8) +protocolInitializationPhaseId = secrets.token_hex(common.SECURITY_PARAMETER // 8) if len(sys.argv) == 1 else sys.argv[1] print(f'{protocolInitializationPhaseId=}') ## Execution phase: 1. Generate a random bitstring to send to the prover. # TODO: improve step numbering, as it's a bit unclear what step of each to run after which one # Wait the initialization phase termination from the prover side before starting the execution phase. -protocolExecutionPhaseId = secrets.token_hex(common.SECURITY_PARAMETER // 8) +protocolExecutionPhaseId = secrets.token_hex(common.SECURITY_PARAMETER // 8) if len(sys.argv) <= 2 else sys.argv[2] print(f'{protocolExecutionPhaseId=}') ## Execution phase: 2. Receive the prover commitment to the table contents given this random challenge. @@ -28,11 +28,12 @@ merkleTreeRoot = input('merkleTreeRoot: ') # Note that there's no advantage to request the last table entry by hoping that the prover is storing the nonces with delta in such order, for instance he can have stored the delta the other way around which screw up this additional request aim. -indexesRequest = set() +indexesRequest = set() if len(sys.argv) <= 3 else ast.literal_eval(sys.argv[3]) -while len(indexesRequest) < common.NUMBER_OF_ENTRIES_TO_VERIFY: - index = secrets.randbelow(common.ENTRIES_NUMBER) - indexesRequest.add(index) +if indexesRequest == set(): + while len(indexesRequest) < common.NUMBER_OF_ENTRIES_TO_VERIFY: + index = secrets.randbelow(common.ENTRIES_NUMBER) + indexesRequest.add(index) indexesRequestFilePath = 'indexesRequest.txt'