#8: Debugging

This commit is contained in:
Benjamin Loison 2023-06-03 16:32:19 +02:00
parent 9fd6d63734
commit a5b18ef24b
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8
2 changed files with 16 additions and 0 deletions

View File

@ -82,14 +82,19 @@ 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])
@ -100,9 +105,16 @@ 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

@ -54,12 +54,16 @@ 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))