Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 340: Content hash is out of spec in announcements #343

Merged
merged 10 commits into from
Aug 7, 2024

Conversation

saraswatpuneet
Copy link
Contributor

@saraswatpuneet saraswatpuneet commented Aug 6, 2024

Problem

Content watcher bug #340 in calculating contentHash,

Details

  • Updated content-watcher to calculate correct contentHash
  • Updated content-watcher
  • Update app template (if needed): Note: social app template simply uses contentHash as key and do not really do any hash validation so no updates necessary

Closes: #340

Solution

What I/we did to solve this problem

Fixed by following DSNP spec and hashing the bytes of content in line with DSNP

@saraswatpuneet saraswatpuneet changed the title use text encoder for content and reutrn bytes of hash itself encoded Bug 340: Content hash is out of spec in announcements Aug 6, 2024
@saraswatpuneet saraswatpuneet marked this pull request as ready for review August 6, 2024 20:14
@saraswatpuneet saraswatpuneet changed the title Bug 340: Content hash is out of spec in announcements [WIP] Bug 340: Content hash is out of spec in announcements Aug 6, 2024
const mb = await service.ipfsHashBuffer(Buffer.from("abc"));
expect(mb).toMatch("z2DrjgbH33g3bTa7dPaMq1XbVmKH11m2SwxAF6aNzSd5F3j63p4");
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saraswatpuneet saraswatpuneet changed the title [WIP] Bug 340: Content hash is out of spec in announcements Bug 340: Content hash is out of spec in announcements Aug 6, 2024
Co-authored-by: Joe Caputo <joseph.caputo@amplica.io>
Copy link
Contributor

@JoeCap08055 JoeCap08055 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

const hash = create(hasher.code, hashed.bytes);
return base58btc.encode(hash.bytes);
const hash = await sha256.digest(fileBuffer);
return base32.encode(hash.bytes);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to dsnp spec (to be updated) base32(multihash)

Copy link
Contributor

@wilwade wilwade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for working through all that.

@saraswatpuneet saraswatpuneet merged commit 933f46d into main Aug 7, 2024
7 checks passed
@saraswatpuneet saraswatpuneet deleted the bug_340_hashes branch August 7, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants