pkc%feat(bls): pin Chia and IETF scheme behaviors in unit tests, implement weighted aggregation API, Chia arm of aggregate verification, import aggregate corpus - #26
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR generalizes BLS aggregate operations across Chia and IETF schemes. It adds secure aggregation, secret-share derivation, cross-scheme conversion, and serialized DH output. It also expands subgroup, encoding, threshold, serialization, and benchmark coverage. ChangesBLS operations
Sequence Diagram(s)sequenceDiagram
participant BlsSignature
participant BlsScheme
participant BlsScChia
participant blst_pairing
BlsSignature->>BlsScheme: verify_aggregates(sig, msgs, pks)
BlsScheme->>BlsScChia: validate inputs and hash messages
BlsScChia->>blst_pairing: pairings_equal_with_g1_generator_prod
blst_pairing-->>BlsScChia: pairing result
BlsScChia-->>BlsScheme: verification result
Mergeability Score: ⚪ Minimal · up to The PR adds BLS aggregation and scheme-specific behavior coverage, and no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
|
Note This pull request has no conflicts! 🎊 🎉 🎊 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
pkgs/pkc/src/bls/scheme_ops.rs (1)
402-410: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a wider index encoding in
secure_weights.Line 405 encodes the index as
u32. The index comes fromsorted_pks.len(), which is ausize. The cast is lossless for any realistic signer count, and the encoding is part of the wire format that the corpus vectors pin, so do not change it now. Add a short note that the four-byte index is a fixed protocol constant, so a future reader does not "fix" the cast and silently change every weight.Confirm that the reference implementation also uses a four-byte big-endian index, because a mismatch would only surface against external vectors.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkgs/pkc/src/bls/scheme_ops.rs` around lines 402 - 410, Add a concise comment beside the index encoding in secure_weights explaining that the u32 big-endian representation is a fixed protocol constant and must not be widened, preserving wire-format compatibility. Verify the reference implementation uses the same four-byte big-endian index encoding, but do not alter the hashing logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkgs/pkc/bench/bls.rs`:
- Around line 208-209: Correct the benchmark documentation above the relevant
benchmark in bls.rs to describe only the BlsSecretKey::derive_share operation
that is actually executed; remove claims about deriving a public share or
comparing public evaluations unless the benchmark is updated to perform those
operations.
In `@pkgs/pkc/src/bls/scheme_chia.rs`:
- Around line 266-281: Add rustdoc to the Chia implementation’s
verify_aggregates method documenting that repeated messages are accepted
intentionally for consensus compatibility and that DuplicateMessage is not
returned. Keep the verification behavior unchanged and make the policy explicit
at this implementation site.
In `@pkgs/pkc/src/bls/sig_aggregate.rs`:
- Around line 305-325: Add a non-empty assertion for the
secure_verify_aggregates vectors in assert_secure_aggregate_matches_vectors,
matching the guard used by assert_aggregate_verify_matches_vectors, before
iterating over vecs.
---
Nitpick comments:
In `@pkgs/pkc/src/bls/scheme_ops.rs`:
- Around line 402-410: Add a concise comment beside the index encoding in
secure_weights explaining that the u32 big-endian representation is a fixed
protocol constant and must not be widened, preserving wire-format compatibility.
Verify the reference implementation uses the same four-byte big-endian index
encoding, but do not alter the hashing logic.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: acde3527-75db-4542-bcd3-5912e1a64b86
⛔ Files ignored due to path filters (2)
pkgs/pkc/corpus/bls_chia_aggregate.json5is excluded by!**/*.json5pkgs/pkc/corpus/bls_ietf_aggregate.json5is excluded by!**/*.json5
📒 Files selected for processing (13)
pkgs/pkc/bench/bls.rspkgs/pkc/src/bls/blst_ffi.rspkgs/pkc/src/bls/error.rspkgs/pkc/src/bls/public_ops.rspkgs/pkc/src/bls/scheme_chia.rspkgs/pkc/src/bls/scheme_ietf.rspkgs/pkc/src/bls/scheme_ops.rspkgs/pkc/src/bls/secret_ops.rspkgs/pkc/src/bls/share_ops.rspkgs/pkc/src/bls/sig_aggregate.rspkgs/pkc/src/bls/sig_basic.rspkgs/pkc/src/bls/sig_threshold.rspkgs/pkc/src/bls/tests.rs
Additional Information
Related to pkc%fix(bls): implement
Fr,Fp{,2},G{1,2}{,Affine}wrappers, usedraft-03keygen, improve conformance withbls-signatures#20Depends on pkc%feat(bls): migrate operational types to
Bls{PublicKey,SecretKey,BlsSignature}<S>, reapbls_{chia,ietf}modules for unifiedblsmodule #25 and resolves some review comments (here, here and here)bls.h:102), the check gated on the scheme (elements.cpp:24)off_subgroup_public_key_policyelements.cpp:245off_subgroup_signature_policybls.cpp:206), there is no separate consensus rule (providertx.cpp:83), and the multiply is a bareg1_mul(privatekey.cpp:184)off_subgroup_peer_policyelements.cpp:24off_subgroup_peer_policyxat or above the field prime, from the prime itself to an all-ones coordinateelements.cpp:85), but the residue re-serializes to zeros, so the malleability check refuses it (bls.h:212) beforeProRegTxever sees a key (bls.h:492,providertx.cpp:83)out_of_range_coordinate_rejectedbls.cpp:333), where it has no guard (schemes.cpp:695) whilestd::setis used in basic scheme (schemes.cpp:428)verify_policy_duplicate_messages,aggregate_verify_matches_vectorsbls.h:114) thatFromBytesUncheckedhands back (elements.cpp:46)identity_public_key_rejected,identity_signature_rejected0xc0over zeros, which no decoder acceptselements.cpp:406)chia_identity_encodes_canonicallyschemes.cpp:670), and the IETF arm does check (schemes.cpp:140) butIsValidadmits infinity (elements.cpp:358)identity_cancellation_follows_schemeelements.cpp:41)chia_masks_stray_public_key_bits,chia_masks_stray_bit_sixelements.cpp:262), where the IETF path erases the top three (:266) and only the sign bit is taken back out (:285)chia_rejects_stray_signature_bitsbls.cpp:155,:341) rather than in the library (schemes.cpp:61)aggregate_empty_fails,verify_aggregate_distinct_messagesstd::sorton the key encodings (schemes.cpp:203)secure_aggregate_duplicate_key_pairingbls.cpp:100, public at:196, one call for both (threshold.cpp:270)sk_share_matches_pk_sharethreshold.cpp:166derive_share_rejects_short_verification_vector,split_rejects_zero_reducing_ids,split_rejects_congruent_idsBreaking Changes
See above.
How Has This Been Tested?
Checklist