Skip to content

Support KoalaBear field as a faster alternative to BabyBear #1305

@spherel

Description

@spherel

Motivation

Ceno currently supports BabyBear as one of its small-prime finite fields (alongside Goldilocks).
KoalaBear is a recently proposed 31-bit prime field with prime
p = 2^31 - 2^24 + 1 that offers significant performance advantages over BabyBear
(p = 2^31 - 2^27 + 1).

Why KoalaBear is faster

  • Better hardware utilization: KoalaBear's prime 2^31 - 2^24 + 1 enables more efficient
    Montgomery/Barrett reduction on modern CPUs compared to BabyBear.
  • Faster multiplication: Benchmarks from Plonky3, SP1, and other ZK frameworks show KoalaBear
    field multiplication is measurably faster than BabyBear on x86-64 and ARM architectures.
  • Same security level: KoalaBear is also a 31-bit field with similar security and extension
    field properties (a degree-4 extension exists), so it is largely a drop-in replacement.
  • Ecosystem adoption: KoalaBear has been adopted by several leading ZK projects as a direct
    replacement for BabyBear (Plonky3, SP1, etc.).

Proposal

  1. Add KoalaBear support in ff_ext, providing a KoalaBearExt4 type analogous to the
    existing BabyBearExt4.
  2. Expose KoalaBear as a FieldType option in the CLI (--field koalabear), alongside
    babybear and goldilocks.
  3. Benchmark KoalaBear vs BabyBear within Ceno to quantify the speedup and guide users toward
    the faster option.
  4. Consider making KoalaBear the default field, or optionally deprecating BabyBear while
    retaining it for backwards compatibility.

References

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