perf(bls): add cache-aware signature verifier - #562
Conversation
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
This is good example of why something like #557 may be helpful
Summary
Uint32Arrayindices directly from the native public-key cache.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