Add stdlib wrappers for remaining BLS12-381 builtins#133
Merged
KtorZ merged 1 commit intoJun 10, 2026
Conversation
Complete coverage of the BLS12-381 prelude builtins so protocols no longer need to blend raw builtins with stdlib: - g1.neg / g2.neg: additive inverse of a curve point (previously only inlined inside `sub`). `sub` now reuses `neg`/`add`. - pairing.mul: multiply two `MillerLoopResult` together, aggregating pairings before a final verification (wraps bls12_381_mul_miller_loop_result). Adds property tests: P + (-P) = 0, -P = 0 - P, P - P = 0, and pairing bilinearity (e(P,Q)^2 = e(2P,Q); e(P,Q)*e(P,Q') = e(P, Q+Q')). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
KtorZ
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
This fills the last gaps in
aiken/crypto/bls12_381so that every BLS12-381 prelude builtin has a stdlib wrapper. Protocols building on pairings no longer have to blend rawbuiltin.bls12_381_*calls with the stdlib API.Mapping all 17 BLS12-381 builtins to wrappers, three were missing:
bls12_381_g1_negg1.negg1.subbls12_381_g2_negg2.negg2.subbls12_381_mul_miller_loop_resultpairing.mulAll other builtins (
add,scalar_mul→scale,equal,compress,uncompress/decompress,hash_to_group,miller_loop,final_verify→final_exponentiation) were already wrapped.Changes
g1.neg/g2.neg— additive inverse of a curve point, following each module's existing style (g1 untyped params, g2 typed).subnow reusesneg/addinstead of calling the builtins directly.pairing.mul— multiplies twoMillerLoopResult, aggregating pairings into one result before a single final verification (leveraging bilinearitye(q1,p1)·e(q2,p2)).g1/g2:P + (−P) = 0,−P = 0 − P,P − P = 0pairing:e(P,Q)² = e(2P,Q)ande(P,Q)·e(P,Q′) = e(P, Q+Q′)vNEXTentry.Verification
aiken check— green, 0 failures.aiken fmt --check— clean.🤖 Generated with Claude Code