Overview
The Grumpkin inline provides optimized elliptic curve operations for the Grumpkin curve, which is the cycle curve for BN254. This makes it particularly useful for recursive proof systems and applications built on top of BN254-based SNARKs.API Reference
GrumpkinFq
Base field element (point coordinates).
Methods
GrumpkinFr
Scalar field element (private keys, scalars).
Methods
GrumpkinPoint
Affine point on the Grumpkin curve.
Methods
Error Handling
.unwrap_or_spoil_proof() to make proofs unsatisfiable on error.
Usage Examples
Point Addition
Field Division
Pedersen Hash Commitment
Verify Point on Curve
Implementation Details
Curve Equation
Grumpkin:y² = x³ - 17 over the prime field:
Cycle Curve Property
Grumpkin forms a cycle with BN254:- Grumpkin base field = BN254 scalar field
- Grumpkin scalar field = BN254 base field
Custom Instructions
The Grumpkin inline provides two advice-only instructions:GRUMPKIN_DIVQ_ADV(funct3=0x00): Base field division (pure advice, verified)GRUMPKIN_DIVR_ADV(funct3=0x01): Scalar field division (pure advice, verified)
Montgomery Form
The implementation uses arkworks’ Montgomery form internally:- Conversions happen at boundaries (
from_u64_arr,to_u64_arr) - Addition/subtraction work identically in Montgomery and standard form
- Multiplication/division use arkworks on host, inline on guest
Infinity Representation
Infinity is represented as(0, 0) since this point is not on the curve y² = x³ - 17:
Optimized Double-and-Add
Thedouble_and_add() method computes 2·P + Q more efficiently than separate operations:
Error Types
Constants
Performance Characteristics
- Field division: ~10-20x faster than pure arkworks
- Point operations: Proportionally faster due to division acceleration
- Advice verification: Minimal overhead for correctness checks
Comparison with secp256k1 Inline
| Feature | secp256k1 | Grumpkin |
|---|---|---|
| Field form | Standard (non-Montgomery) | Montgomery |
| Mul inline | Full computation | N/A (uses arkworks) |
| Div inline | Full computation | Advice + verification |
| GLV | Yes | No |
| Use case | Bitcoin/Ethereum signatures | BN254 recursive proofs |
Feature Flags
host: Enables reference implementation for host-side execution- Guest code: Compile WITHOUT this feature
- Prover code: Compile WITH this feature
Source Code Location
See Also
- secp256k1 - Bitcoin/Ethereum curve
- BigInt - Used internally for field operations
- Inlines Overview - General information about cryptographic inlines