Skip to content

feat: better bytesMatch algorithm#153

Closed
Uzlopak wants to merge 1 commit into
w3c:mainfrom
Uzlopak:better-bytes-match
Closed

feat: better bytesMatch algorithm#153
Uzlopak wants to merge 1 commit into
w3c:mainfrom
Uzlopak:better-bytes-match

Conversation

@Uzlopak
Copy link
Copy Markdown
Contributor

@Uzlopak Uzlopak commented Aug 12, 2025

The algorithm for matching the hashes is only performant if you have one hash provided.

Lets say for some reason you provide five sha512 hashes for the resource. Than algorithm of the spec suggests, that we should hash 5 times the bytes to get five times the same actualValue, just to compare the actualValue with the expectedValue. This is obviously imperformant and repetetive.

We just need to hash the bytes only once to get the actualValue and then only compare with the expectedValue.

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
  • MDN issue is filed: …

(See our contributing guidelines for more details.)


Preview | Diff

@mozfreddyb
Copy link
Copy Markdown
Collaborator

As mentioned previously, we don't concern ourselves with implementation details like performance.

Implementations are free to rewire internal algorithms to improve on performance, as long as these improvements are changes that will be exposed to the web.

On another note, let's discuss potential improvements in an issue before you write a pull request.

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

Successfully merging this pull request may close these issues.

2 participants