-
Notifications
You must be signed in to change notification settings - Fork 162
Description
Problem
Currently, the bls-signatures crate mixes mathematical types with storage types. For example, PubkeyProjective wraps a curve point (blstrs::G1Projective), but Pubkey (affine) wraps a raw byte array ([u8; 96]).
This causes performance inefficiencies due to redundant validation. Every time we use a Pubkey for verification, we must deserialize and subgroup-check the bytes into a G1Affine. Because we don't have a wrapper for G1Affine, we throw this work away after the operation, forcing us to pay the validation cost again next time.
Proposal
We should split the types into mathematical points (Projective/Affine) and serialize bytes (uncompressed/compressed).
Using public keys as an example, we would transition to four types:
Points (math & arithmetic):
PubkeyProjective: WrapsG1Projective. Best for aggregation and signing.PubkeyAffine: WrapsG1Affine. Best for verification (pairing inputs)
Bytes (storage & I/O):
PubkeyUncompressed: Wraps[u8; 96]PubkeyCompressed: Wraps[u8; 48]
This allows us to validate bytes once into a PubkeyAffine and reuse the efficient representation for multiple verifications.