Skip to content

Commit

Permalink
remove 0x from hash comparison (#2530)
Browse files Browse the repository at this point in the history
  • Loading branch information
portuu3 authored Sep 19, 2024
1 parent 525eb5b commit 70faf20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ def get_file_url_and_verify_hash(
content = requests.get(url).text
content_hash = Web3.keccak(text=content).hex()

if hash != content_hash:
formatted_hash = hash.replace("0x", "")
formatted_content_hash = content_hash.replace("0x", "")

if formatted_hash != formatted_content_hash:
raise KVStoreClientError(f"Invalid hash")

return url
Expand Down
5 changes: 4 additions & 1 deletion packages/sdk/typescript/human-protocol-sdk/src/kvstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ export class KVStoreUtils {
const content = await fetch(url).then((res) => res.text());
const contentHash = ethers.keccak256(ethers.toUtf8Bytes(content));

if (hash !== contentHash) {
const formattedHash = hash?.replace(/^0x/, '');
const formattedContentHash = contentHash?.replace(/^0x/, '');

if (formattedHash !== formattedContentHash) {
throw ErrorInvalidHash;
}

Expand Down

0 comments on commit 70faf20

Please sign in to comment.