Skip to main content

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

Use .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:
Scalar field:

Cycle Curve Property

Grumpkin forms a cycle with BN254:
  • Grumpkin base field = BN254 scalar field
  • Grumpkin scalar field = BN254 base field
This enables efficient recursive proof composition.

Custom Instructions

The Grumpkin inline provides two advice-only instructions:
  1. GRUMPKIN_DIVQ_ADV (funct3=0x00): Base field division (pure advice, verified)
  2. GRUMPKIN_DIVR_ADV (funct3=0x01): Scalar field division (pure advice, verified)
Both instructions are “advice-only” meaning they provide non-deterministic hints that are then 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

The double_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 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