Skip to content

refactor(crypto): use slices.Sort for public keys - #4642

Open
vividvisit wants to merge 1 commit into
zeta-chain:mainfrom
vividvisit:refactor/crypto-pubkey-sort
Open

vividvisit wants to merge 1 commit into
zeta-chain:mainfrom
vividvisit:refactor/crypto-pubkey-sort

Conversation

@vividvisit

@vividvisit vividvisit commented Sep 11, 2026

Copy link
Copy Markdown

Description

Replace two natural-order sort.Slice callbacks in PubKeys.Equals with slices.Sort.

This preserves order-independent public-key equality while removing custom comparator boilerplate.

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Note

Low Risk
Mechanical sorting refactor in one helper with existing unit tests; no auth or data-path changes.

Overview
Refactors order-independent PubKeys.Equals to sort copies of both key lists with slices.Sort instead of sort.Slice and custom String() comparators.

The import switches from sort to slices; equality behavior stays the same (sorted bech32 key strings compared pairwise).

Reviewed by Cursor Bugbot for commit 9503dc1. Configure here.

Greptile Summary

This PR simplifies order-independent public-key equality without changing its behavior.

  • Replaces two sort.Slice calls and custom comparators with slices.Sort.
  • Preserves sorting by the underlying public-key string value.
  • Removes the now-unused sort import in favor of slices.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, compatibility, security, or repository-rule issues identified.

PubKey has an underlying string type and its String method returns that same value, making the new natural ordering equivalent to the removed comparators; the repository’s supported Go version includes slices.

Important Files Changed

Filename Overview
pkg/crypto/pubkey.go Replaces equivalent custom string sorting in PubKeys.Equals with type-safe standard-library sorting.

Reviews (1): Last reviewed commit: "refactor(crypto): use slices.Sort for pu..." | Re-trigger Greptile

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vividvisit
vividvisit requested a review from a team as a code owner September 11, 2026 06:50
@vividvisit

Copy link
Copy Markdown
Author

@skosito Could you please take a look when you have a chance? Thanks!

This branch has not been deployed

No deployments
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.

1 participant