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
- Add KoalaBear support in
ff_ext, providing a KoalaBearExt4 type analogous to the
existing BabyBearExt4.
- Expose KoalaBear as a
FieldType option in the CLI (--field koalabear), alongside
babybear and goldilocks.
- Benchmark KoalaBear vs BabyBear within Ceno to quantify the speedup and guide users toward
the faster option.
- Consider making KoalaBear the default field, or optionally deprecating BabyBear while
retaining it for backwards compatibility.
References
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 + 1that offers significant performance advantages over BabyBear(
p = 2^31 - 2^27 + 1).Why KoalaBear is faster
2^31 - 2^24 + 1enables more efficientMontgomery/Barrett reduction on modern CPUs compared to BabyBear.
field multiplication is measurably faster than BabyBear on x86-64 and ARM architectures.
field properties (a degree-4 extension exists), so it is largely a drop-in replacement.
replacement for BabyBear (Plonky3, SP1, etc.).
Proposal
ff_ext, providing aKoalaBearExt4type analogous to theexisting
BabyBearExt4.FieldTypeoption in the CLI (--field koalabear), alongsidebabybearandgoldilocks.the faster option.
retaining it for backwards compatibility.
References