Skip to content

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

Open
@edent

Description

@edent

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions