Skip to content

Re-organize types for solana-bls-signatures #474

@samkim-crypto

Description

@samkim-crypto

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: Wraps G1Projective. Best for aggregation and signing.
  • PubkeyAffine: Wraps G1Affine. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions