Skip to content

perf(bls): add cache-aware signature verifier - #562

Open
wemeetagain wants to merge 1 commit into
mainfrom
cayman/bls-indexed-verifier
Open

perf(bls): add cache-aware signature verifier#562
wemeetagain wants to merge 1 commit into
mainfrom
cayman/bls-indexed-verifier

Conversation

@wemeetagain

Copy link
Copy Markdown
Member

Summary

  • Add a bounded NAPI verifier for indexed, aggregate, and raw-public-key signature sets.
  • Resolve validator-indexed public keys and aggregate Uint32Array indices directly from the native public-key cache.
  • Add randomized same-message aggregation with native per-signature fallback results.
  • Expose the verifier API, set types, and batch limits through the JavaScript bindings.

Why

Lodestar currently materializes or aggregates public keys in TypeScript before crossing the native boundary. Failed same-message aggregate checks also require another worker-queue pass to identify invalid signatures. This interface keeps validator indices through the native boundary, reuses the native public-key cache, and returns final per-signature results.

Impact

This reduces JavaScript/native serialization and repeated public-key work while providing bounded validation for every new input shape.

Paired with ChainSafe/lodestar#9820.

Written with codex assistance

@wemeetagain
wemeetagain marked this pull request as ready for review August 13, 2026 14:32
@wemeetagain
wemeetagain requested a review from a team as a code owner August 13, 2026 14:32

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f53b807f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (!pubkeys.state.initialized) return error.PubkeyIndexNotInitialized;
const indices = try uint32Slice(try set.getNamedProperty("indices"));
if (indices.len == 0) return error.EmptyIndices;
if (indices.len > max_indices_per_set) return error.TooManyIndices;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Cap aggregate indices across the whole batch

When a caller supplies 256 aggregate sets, each set may reuse a 131,072-entry Uint32Array, so this per-set check still permits over 33 million sequential elliptic-curve additions in PubkeyCache.aggregateIndices() before verification. Because the exported NAPI function is synchronous, malformed or adversarial input can stall the calling Node.js thread for a prolonged period. Track and reject a bounded cumulative index count for the batch, rather than limiting each set independently.

AGENTS.md reference: AGENTS.md:L8-L9

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is good example of why something like #557 may be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant