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

What does "XORed SHA256 digests of each of the identifiers" mean here? #1562

Open
edent opened this issue Nov 17, 2024 · 0 comments
Open

What does "XORed SHA256 digests of each of the identifiers" mean here? #1562

edent opened this issue Nov 17, 2024 · 0 comments

Comments

@edent
Copy link
Contributor

edent commented Nov 17, 2024

I'm trying to understand how my AP accounts can share a list of who follows them.

The documentation for Follower synchronization mechanism says:

digest = hexadecimal representation of the XORed SHA256 digests of each of the identifiers in the partial collection

The following code produces the correct output based on the documentation:

>>> import hashlib
>>> sha256_hash = hashlib.sha256("https://mastodon.social/users/Gargron".encode()).digest()
>>> sha256_hash.hex()
'b08ab6951c7d6cc2b91e17ebd9557da7fae02489728e9332fcb3a97748244d50

But there's no explanation or example of what it looks like for multiple followers.

I assume it should it be:

>>> import hashlib
>>> sha_1 = hashlib.sha256("https://mastodon.social/users/Gargron".encode()).digest()
>>> sha_2 = hashlib.sha256("https://mastodon.social/users/Edent".encode()).digest()
>>> xor_result = bytes(a ^ b for a, b in zip(sha_1, sha_2))
>>> xor_result.hex()
'f11cad446acb5adc7b125c686741840c177d3947308201e13e66671f841a1a2e

I think it could be helpful to have a bit more detail here. Perhaps giving an example that people can test against?

Also, should social.sitedethib.com be replaced with an example domain?

Re: mastodon/mastodon#14510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant