Skip to content

zorch.testkit.koalabear16

koalabear-16 reference fixture — TEST ONLY (never re-exported from the package).

A single golden parameterization pinned to one Plonky3 revision, generated from p3_commit=4318eba062fd1cbca3dbe98904ad18ad950f3b49. Named instances are a consumer concern rather than zorch API, so this exists only to give zorch's own tests one real permutation to run the agnostic engine against.

It lives here rather than in hash_frx because the hash-frx wheel ships no test tree; its copy of these constants backs hash-frx's byte-match against Plonky3, which is the assertion that keeps this instance honest. Zorch needs only the instance, so the expected permute output stays there.

koalabear16_perm

koalabear16_perm() -> Poseidon2

The golden koalabear-16 Poseidon2 permutation instance (width 16).

Source code in zorch/testkit/koalabear16.py
255
256
257
def koalabear16_perm() -> Poseidon2:
    """The golden koalabear-16 Poseidon2 permutation instance (width 16)."""
    return Poseidon2(koalabear16_params())

koalabear16_scaled_perm

koalabear16_scaled_perm() -> Poseidon2

The golden instance with a non-identity internal_j_scale.

The default instance's identity scale hides an entire bug class: a lowering that silently substitutes identity for the J term's scale (or re-encodes its Montgomery storage) is byte-invisible when the true scale is already one. The value here is R⁻¹ mod p — its Montgomery STORAGE is exactly 1, the trap a raw-bits/canonical mixup lands on — and it mirrors a consumer folding R⁻¹ out of an R⁻¹·M·state internal layer.

Source code in zorch/testkit/koalabear16.py
260
261
262
263
264
265
266
267
268
269
270
271
272
273
def koalabear16_scaled_perm() -> Poseidon2:
    """The golden instance with a non-identity `internal_j_scale`.

    The default instance's identity scale hides an entire bug class: a
    lowering that silently substitutes identity for the J term's scale (or
    re-encodes its Montgomery storage) is byte-invisible when the true scale
    is already one. The value here is R⁻¹ mod p — its Montgomery STORAGE is
    exactly 1, the trap a raw-bits/canonical mixup lands on — and it mirrors a
    consumer folding
    R⁻¹ out of an `R⁻¹·M·state` internal layer.
    """
    return Poseidon2(
        replace(koalabear16_params(), internal_j_scale=fnp.array(1057030144, F))
    )