diff --git a/prover.py b/prover.py index d12a8a5..21ac83d 100755 --- a/prover.py +++ b/prover.py @@ -48,7 +48,6 @@ counter = 0 for deltaCounter in STORED_NONCES: counter += deltaCounter hashed = common.hash(protocolInitializationPhaseId + protocolExecutionPhaseId + str(counter)) - #print('nonce', len(merkleTreeLevel), str(counter), hashed) merkleTreeLevel += [hashed] merkleTreeLevels = [merkleTreeLevel] @@ -84,22 +83,14 @@ with open(input('indexesRequest: ')) as f: verificationMerkleTreeLevels = [{} for _ in range(common.LEVELS)] for indexRequest in indexesRequest: - #print('interest', indexRequest) otherIndex = common.otherIndex(indexRequest) for index in [indexRequest, otherIndex]: - #print(index) verificationMerkleTreeLevels[0][index] = merkleTreeLevels[0][index] -import json -#print(json.dumps(verificationMerkleTreeLevels[0], indent = 4, sort_keys = True)) -#exit(1) - # Should rename `entries`, as they aren't *entries* for higher levels. entries = [] for verificationMerkleTreeLevelsIndex, verificationMerkleTreeLevel in enumerate(verificationMerkleTreeLevels[:-1]): - #for index in (verificationMerkleTreeLevel if verificationMerkleTreeLevelsIndex > 1 else indexesRequest): for index in verificationMerkleTreeLevel: - #print(index) otherIndex = common.otherIndex(index) leftIndex, rightIndex = sorted([index, otherIndex]) leftHash, rightHash = [merkleTreeLevels[verificationMerkleTreeLevelsIndex][i] for i in [leftIndex, rightIndex]] @@ -109,14 +100,10 @@ for verificationMerkleTreeLevelsIndex, verificationMerkleTreeLevel in enumerate( if verificationMerkleTreeLevelsIndex == 0: leftNonce = sum(STORED_NONCES[:leftIndex + 1]) rightNonce = leftNonce + STORED_NONCES[rightIndex] - #print(leftNonce, rightNonce) entries += [leftNonce, rightNonce] else: entries += [otherHash] -#import json -#print(json.dumps(verificationMerkleTreeLevels, indent = 4, sort_keys = True)) - entriesFilePath = 'entries.txt' with open(entriesFilePath, 'w') as f: diff --git a/verifier.py b/verifier.py index e5b782d..7555b5e 100755 --- a/verifier.py +++ b/verifier.py @@ -56,7 +56,6 @@ with open(input('entries: ')) as f: merkleTreeLevels = [{} for _ in range(common.LEVELS)] for index in indexesRequest: - #print('interest', index) otherIndex = common.otherIndex(index) leftIndex, rightIndex = sorted([index, otherIndex]) for i, nonce in zip([leftIndex, rightIndex], [entries.pop(0) for _ in range(2)]): @@ -65,13 +64,8 @@ for index in indexesRequest: print("The received difficulty doesn't match the claimed one!") exit(1) hashed = common.hash(protocolInitializationPhaseId + protocolExecutionPhaseId + str(nonce)) - #print('nonce', i, str(nonce), hashed) merkleTreeLevels[0][i] = hashed -import json -#print(json.dumps(merkleTreeLevels[0], indent = 4, sort_keys = True)) -#exit(1) - for merkleTreeLevelsIndex, merkleTreeLevel in enumerate(merkleTreeLevels[:-1]): for index in merkleTreeLevel.copy(): otherIndex = common.otherIndex(index) @@ -85,9 +79,6 @@ for merkleTreeLevelsIndex, merkleTreeLevel in enumerate(merkleTreeLevels[:-1]): # If any entry corresponding to requested indexes is incorrect, the Merkle tree won't match or the verification of the claimed difficulty of the provided hash will fail. actualStorage = common.ENTRIES_NUMBER * common.NUMBER_OF_BITS_IN_AVERAGE_FOR_SOLVING_PUZZLE -#import json -#print(json.dumps(merkleTreeLevels, indent = 4, sort_keys = True)) - if merkleTreeRoot == merkleTreeLevels[-1][0] and actualStorage >= common.SPACE_TO_PROVE_IN_BITS: print(f'Verified with probability {common.PROBABILITY_TO_CATCH_MALICIOUS} that the prover is storing in average {common.INITIAL_SPACE_TO_PROVE_IN_BITS} (actually the prover is storing in average {actualStorage} bits)') else: