Skip to content

Instantly share code, notes, and snippets.

BabyBear = 2^27 * 15 + 1
M31 = 2^31 - 1
BN254 = 21888242871839275222246405745257275088548364400416034343698204186575808495617
GL = 0xffffffff00000001
fields = [BabyBear, M31, BN254, GL]
def check_irreducibility(field):
F = GF(field)
R.<x> = PolynomialRing(F)
use std::prover::Query;
use std::convert::fe;
use std::protocols::lookup_via_bus::lookup;
use std::math::fp2::from_base;
use std::prover::challenge;
machine Main with degree: 8 {
let alpha = from_base(challenge(0, 1));
let beta = from_base(challenge(0, 2));
use std::prover::Query;
use std::convert::fe;
use std::protocols::lookup_via_bus::lookup;
use std::math::fp2::from_base;
use std::prover::challenge;
machine Main with degree: 8 {
let alpha = from_base(challenge(0, 1));
let beta = from_base(challenge(0, 2));
use std::array::fold;
use std::math::fp2::Fp2;
use std::math::fp2::add_ext;
use std::math::fp2::mul_ext;
use std::math::fp2::from_base;
/// Maps [x_1, x_2, ..., x_n] to its Read-Solomon fingerprint, using a challenge alpha: $\sum_{i=1}^n alpha**{(n - i)} * x_i$
let<T: Add + Mul + FromLiteral> fingerprint: T[], Fp2<T> -> Fp2<T> = |expr_array, alpha| fold(
expr_array,
from_base(0),
use std::array::len;
use std::check::assert;
use std::protocols::bus::bus_send;
use std::protocols::bus::bus_receive;
use std::protocols::bus::compute_next_z_send;
use std::protocols::bus::compute_next_z_receive;
use std::protocols::permutation::unpack_permutation_constraint;
use std::math::fp2::Fp2;
// Example usage: Implement a permutation constraint
use std::prover::Query;
use std::convert::fe;
use std::protocols::permutation_via_bus::permutation;
use std::protocols::permutation_via_bus::compute_next_z_send_permutation;
use std::protocols::permutation_via_bus::compute_next_z_receive_permutation;
use std::math::fp2::Fp2;
use std::prover::challenge;
machine Main with degree: 8 {
use std::prover::Query;
use std::convert::fe;
use std::protocols::permutation_via_bus::permutation;
use std::math::fp2::from_base;
use std::prover::challenge;
machine Main with degree: 8 {
let alpha = from_base(challenge(0, 1));
let beta = from_base(challenge(0, 2));
use std::check::assert;
use std::check::panic;
use std::math::fp2::Fp2;
use std::math::fp2::add_ext;
use std::math::fp2::sub_ext;
use std::math::fp2::mul_ext;
use std::math::fp2::inv_ext;
use std::math::fp2::eval_ext;
use std::math::fp2::unpack_ext;
use std::math::fp2::next_ext;
use std::prover::Query;
use std::convert::fe;
use std::protocols::permutation_via_bus::permutation;
use std::math::fp2::from_base;
use std::prover::challenge;
machine Main with degree: 8 {
let alpha = from_base(challenge(0, 1));
let beta = from_base(challenge(0, 2));
use std::prover::challenge;
use std::array::fold;
use std::utils::unwrap_or_else;
use std::array::len;
use std::check::assert;
use std::check::panic;
use std::field::known_field;
use std::field::KnownField;
use std::math::fp2::Fp2;
use std::math::fp2::add_ext;