Compare commits

...

2 Commits

3 changed files with 3 additions and 18 deletions

View File

@@ -40,5 +40,5 @@ while True:
write(verifier, 'entries.txt')
result = ' '.join(getProgramLine(verifier).split()[1:])
print(result)
if not result.startswith('Verified'):
if result.startswith('The received difficulty'):#not result.startswith('Verified'):
break

View File

@@ -82,19 +82,14 @@ with open(input('indexesRequest: ')) as f:
verificationMerkleTreeLevels = [{} for _ in range(common.LEVELS)]
print(len(indexesRequest))
for indexRequest in indexesRequest:
otherIndex = common.otherIndex(indexRequest)
print(indexRequest, otherIndex)
for index in [indexRequest, otherIndex]:
verificationMerkleTreeLevels[0][index] = merkleTreeLevels[0][index]
print(len(verificationMerkleTreeLevels[0]), verificationMerkleTreeLevels[0])
# Should rename `entries`, as they aren't *entries* for higher levels.
entries = []
for verificationMerkleTreeLevelsIndex, verificationMerkleTreeLevel in enumerate(verificationMerkleTreeLevels[:-1]):
#print('len', len(verificationMerkleTreeLevel))
for index in verificationMerkleTreeLevel:
otherIndex = common.otherIndex(index)
leftIndex, rightIndex = sorted([index, otherIndex])
@@ -105,16 +100,9 @@ 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:
print('once', otherHash)
entries += [otherHash]
elif verificationMerkleTreeLevelsIndex == 0:
leftNonce = sum(STORED_NONCES[:leftIndex + 1])
rightNonce = leftNonce + STORED_NONCES[rightIndex]
print('nope', leftNonce, rightNonce)
entriesFilePath = 'entries.txt'

View File

@@ -33,7 +33,8 @@ indexesRequest = set() if len(sys.argv) <= 3 else ast.literal_eval(sys.argv[3])
if indexesRequest == set():
while len(indexesRequest) < common.NUMBER_OF_ENTRIES_TO_VERIFY:
index = secrets.randbelow(common.ENTRIES_NUMBER)
indexesRequest.add(index)
if not common.otherIndex(index) in indexesRequest:
indexesRequest.add(index)
indexesRequestFilePath = 'indexesRequest.txt'
@@ -54,16 +55,12 @@ with open(input('entries: ')) as f:
merkleTreeLevels = [{} for _ in range(common.LEVELS)]
print(entries[:len(indexesRequest) * 2])
print(len(indexesRequest)) # 18
for index in indexesRequest:
otherIndex = common.otherIndex(index)
leftIndex, rightIndex = sorted([index, otherIndex])
for i, nonce in zip([leftIndex, rightIndex], [entries.pop(0) for _ in range(2)]):
print(protocolInitializationPhaseId, str(nonce))
hashed = common.hash(protocolInitializationPhaseId + str(nonce))
if not common.doesHashMatchDifficulty(hashed):
print(hashed)
print("The received difficulty doesn't match the claimed one!")
exit(1)
merkleTreeLevels[0][i] = common.hash(protocolInitializationPhaseId + protocolExecutionPhaseId + str(nonce))