Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose aggregate_verify_gt() in chia-bls #500

Merged
merged 2 commits into from
Apr 30, 2024
Merged

expose aggregate_verify_gt() in chia-bls #500

merged 2 commits into from
Apr 30, 2024

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Apr 30, 2024

to prepare for the BLS cache.

Validating an aggregate signature in BLS can be broken down into the following steps:

  1. for each (public key, message)-pair
    1.1 augment the message by pre-pending the public key. The public key is also known as G1.
    1.2 map the augmented message to G2 (hash_to_g2())
    1.3 pair the G1 and G2 points to get a GT point
  2. multiply all GT points together
  3. pair the generator (a G1 point) with the signature (a G2 point)
  4. if the aggregate GT point equals the signature pair, the signature is valid.

The pairing operation is quite expensive. As you can see from the benchmark, validating a signature against 1000 GT points is 2 orders of magnitude faster than validating 1000 (key, message)-pairs. The BLS cache caches the GT points to avoid having to compute the pairings multiple times.

The benchmark gives an indication on the speed-up of caching the pairings:

benchmark time
aggregate_verify_gt, small msg 2.1471 ms
aggregate_verify, small msg 349.57 ms
verify, small msg 944.59 µs
verify, 4kiB msg 949.05 µs

@arvidn arvidn marked this pull request as ready for review April 30, 2024 06:49
@arvidn arvidn requested a review from matt-o-how April 30, 2024 06:49
Copy link

coveralls-official bot commented Apr 30, 2024

Pull Request Test Coverage Report for Build 8894992465

Details

  • 21 of 30 (70.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 84.799%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/chia-bls/src/signature.rs 20 21 95.24%
crates/chia-bls/src/gtelement.rs 1 9 11.11%
Totals Coverage Status
Change from base Build 8885557317: -0.03%
Covered Lines: 11776
Relevant Lines: 13887

💛 - Coveralls

@matt-o-how
Copy link
Contributor

Looks good.
If you add some extra comments to the public facing functions on signature.rs then this will be perfect.

@arvidn arvidn merged commit 25fd0a5 into main Apr 30, 2024
64 checks passed
@arvidn arvidn deleted the aggregate-verift-gt branch April 30, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants