Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Hotfix/fix hashing #217

Merged
merged 2 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,22 @@ private boolean verifyResponse(SyncResponse syncResponse) {
.map(txn -> txn.getId().asHashCode())
.collect(ImmutableList.toImmutableList());

return this.validatorSetVerifier.verifyValidatorSet(syncResponse)
&& this.signaturesVerifier.verifyResponseSignatures(syncResponse)
&& this.accumulatorVerifier.verify(start, hashes, end);
if (!this.validatorSetVerifier.verifyValidatorSet(syncResponse)) {
log.warn("Invalid validator set");
return false;
}

if (!this.signaturesVerifier.verifyResponseSignatures(syncResponse)) {
log.warn("Invalid signatures");
return false;
}

if (!this.accumulatorVerifier.verify(start, hashes, end)) {
log.warn("Invalid accumulator");
return false;
}

return true;
}

private SyncState processSyncRequestTimeout(SyncingState currentState, SyncRequestTimeout syncRequestTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ public static int compare(HashCode fst, HashCode snd) {
* @return calculated hash
*/
public static HashCode transactionIdHash(byte[] payload) {
return sha256(sha256(payload).asBytes());
return sha256(payload);
}

public static HashCode transactionIdHash(ByteBuffer buf) {
return sha256(sha256(buf.array(), buf.position(), buf.remaining()).asBytes());
return sha256(buf.array(), buf.position(), buf.remaining());
}

private HashUtils() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ private Atoms() {

public static AID atomIdOf(Atom atom) {
var dson = Serialize.getInstance().toDson(atom, DsonOutput.Output.ALL);
var firstHash = HashUtils.sha256(dson);
var secondHash = HashUtils.sha256(firstHash.asBytes());
return AID.from(secondHash.asBytes());
return AID.from(HashUtils.sha256(dson).asBytes());
}
}