Add reproducibility to solve #8
This commit is contained in:
@@ -45,4 +45,4 @@ def otherIndex(n):
|
|||||||
def doesHashMatchDifficulty(hashed):
|
def doesHashMatchDifficulty(hashed):
|
||||||
hashedInteger = int(hashed, 16)
|
hashedInteger = int(hashed, 16)
|
||||||
hashedDifficulty = hashedInteger / LEAST_DIFFICULT_HASH
|
hashedDifficulty = hashedInteger / LEAST_DIFFICULT_HASH
|
||||||
return hashedDifficulty <= MAXIMUM_HASH_DIFFICULTY
|
return hashedDifficulty <= MAXIMUM_HASH_DIFFICULTY
|
||||||
|
3
meta.py
3
meta.py
@@ -34,6 +34,9 @@ while True:
|
|||||||
write(prover, 'indexesRequest.txt')
|
write(prover, 'indexesRequest.txt')
|
||||||
getProgramLine(prover)
|
getProgramLine(prover)
|
||||||
|
|
||||||
|
with open('indexesRequest.txt') as f:
|
||||||
|
print(f.read())
|
||||||
|
|
||||||
write(verifier, 'entries.txt')
|
write(verifier, 'entries.txt')
|
||||||
result = ' '.join(getProgramLine(verifier).split()[1:])
|
result = ' '.join(getProgramLine(verifier).split()[1:])
|
||||||
print(result)
|
print(result)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Proof of Space-Time prover
|
## Proof of Space-Time prover
|
||||||
|
|
||||||
import math, common, ast
|
import math, common, ast, sys
|
||||||
|
|
||||||
# For the ratio between storing and power:
|
# 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.
|
# 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
|
deltaCounter = counter - lastCounter
|
||||||
STORED_NONCES += [deltaCounter]
|
STORED_NONCES += [deltaCounter]
|
||||||
lastCounter = counter
|
lastCounter = counter
|
||||||
print(len(STORED_NONCES), common.ENTRIES_NUMBER)
|
print(len(STORED_NONCES), common.ENTRIES_NUMBER, file=sys.stderr)
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
## Execution phase: 1. Receive a random bitstring from the verifier.
|
## Execution phase: 1. Receive a random bitstring from the verifier.
|
||||||
|
15
verifier.py
15
verifier.py
@@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
## Proof of Space-Time verifier
|
## 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.
|
## 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.
|
# 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=}')
|
print(f'{protocolInitializationPhaseId=}')
|
||||||
|
|
||||||
## Execution phase: 1. Generate a random bitstring to send to the prover.
|
## 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
|
# 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.
|
# 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=}')
|
print(f'{protocolExecutionPhaseId=}')
|
||||||
|
|
||||||
## Execution phase: 2. Receive the prover commitment to the table contents given this random challenge.
|
## 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.
|
# 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:
|
if indexesRequest == set():
|
||||||
index = secrets.randbelow(common.ENTRIES_NUMBER)
|
while len(indexesRequest) < common.NUMBER_OF_ENTRIES_TO_VERIFY:
|
||||||
indexesRequest.add(index)
|
index = secrets.randbelow(common.ENTRIES_NUMBER)
|
||||||
|
indexesRequest.add(index)
|
||||||
|
|
||||||
indexesRequestFilePath = 'indexesRequest.txt'
|
indexesRequestFilePath = 'indexesRequest.txt'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user