mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-11 03:01:36 -04:00
<!-- Thanks for sending a PR! Before submitting: 1. If this is your first PR, check out our contribution guide here https://docs.prylabs.network/docs/contribute/contribution-guidelines You will then need to sign our Contributor License Agreement (CLA), which will show up as a comment from a bot in this pull request after you open it. We cannot review code without a signed CLA. 2. Please file an associated tracking issue if this pull request is non-trivial and requires context for our team to understand. All features and most bug fixes should have an associated issue with a design discussed and decided upon. Small bug fixes and documentation improvements don't need issues. 3. New features and bug fixes must have tests. Documentation may need to be updated. If you're unsure what to update, send the PR, and we'll discuss in review. 4. Note that PRs updating dependencies and new Go versions are not accepted. Please file an issue instead. 5. A changelog entry is required for user facing issues. --> **What type of PR is this?** > Other **What does this PR do? Why is it needed?** This PR applies micro-optimizations to the auth token handling code. It improves efficiency and readability by reducing unnecessary allocations and adding an early length check before performing constant-time comparison. [PR#15763](https://github.com/OffchainLabs/prysm/pull/15763) **Changes Included** - Use `strings.HasPrefix` + slicing instead of `strings.Split` to avoid allocations - Add early length check before `subtle.ConstantTimeCompare` **Which issues(s) does this PR fix?** No functional changes or security fixes; this PR improves performance and code clarity in the auth token handling logic. **Acknowledgements** - [x] I have read [CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md). - [x] I have included a uniquely named [changelog fragment file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd). - [x] I have added a description to this PR with sufficient context for reviewers to understand this PR. --------- Co-authored-by: maradini77 <140460067+maradini77@users.noreply.github.com> Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>