Skip to content

Instantly share code, notes, and snippets.

@DrPeterVanNostrand
DrPeterVanNostrand / lib.rs
Created February 13, 2023 16:57
Testudo benchmark circuit written in bellperson
// File: `bellperson/src/lib.rs`
// Run: `$ cargo test --release [--features=<cuda, opencl>] testudo`
#[cfg(test)]
mod tests {
use super::*;
use blstrs::{Bls12, Scalar as Fr};
use ff::Field;
use rand::thread_rng;
@DrPeterVanNostrand
DrPeterVanNostrand / nova.rs
Created January 30, 2023 19:26
First Attempt at Nova Recursive Proving API
// Cargo.toml
// nova-snark = { version = "0.10.0", default-features = false }
use ff::{Field, PrimeField};
use halo2_proofs::pasta::{Ep, Eq, Fp, Fq};
use nova_snark::{
errors::NovaError,
traits::{
circuit::{StepCircuit, TrivialTestCircuit},
Group,
@DrPeterVanNostrand
DrPeterVanNostrand / seal.rs
Last active December 15, 2022 16:23
Filecoin PoRep Groth16 Constraints
/// Add the following test to the bottom of: rust-fil-proofs/filecoin-proofs/src/api/seal.rs
///
/// Run using:
/// $ cd rust-fil-proofs/filecoin-proofs
/// $ cargo test --release --no-default-features get_groth16_constraints -- --nocapture
///
/// PoRep Partition Constraint Counts:
/// - 32GiB: 130278541
/// - 64GiB: 131185849
@DrPeterVanNostrand
DrPeterVanNostrand / domain.rs
Last active September 13, 2022 18:58
Halo2 verification key serialization without constraint system
// halo2_proofs/src/poly/domain.rs
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EvaluationDomain<G: Group> {
pub(crate) n: u64,
pub(crate) k: u32,
pub(crate) extended_k: u32,
pub(crate) omega: G::Scalar,
pub(crate) omega_inv: G::Scalar,
pub(crate) extended_omega: G::Scalar,
@DrPeterVanNostrand
DrPeterVanNostrand / pubkey.asc
Created December 13, 2021 20:24
Filecoin trusted-setup #2
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEYbJHkhYJKwYBBAHaRw8BAQdAxwCXKXAA8xJQLcY3Po6ikB66NXRXqG4Lx7P5
KBMy8ha0HkZpbGVjb2luIHRydXN0ZWQtc2V0dXAgIzIgamFrZYiQBBMWCAA4FiEE
cpr+MPiiJS+xYRFs0jRho/ZeypoFAmGyR5ICGwMFCwkIBwIGFQoJCAsCBBYCAwEC
HgECF4AACgkQ0jRho/ZeyppsVwEA5FcnA++5IpL1uG0oQfaAynjZd76fkOAUdc23
6IPtjEoBAOc2saMfPFnzwUD7xwyepPU96BhoHW10w9a9Sa7oay4N
=Oc/a
-----END PGP PUBLIC KEY BLOCK-----
use blstrs::Scalar as Fr;
use halo::pasta::{Fp, Fq as Fv};
// more imports...
lazy_static! {
pub static ref BLS_P_MINUS_1: [u8; 32] = (-Fr::one()).to_repr();
pub static ref PALLAS_P_MINUS_1: [u8; 32] = (-Fp::one()).to_repr();
pub static ref VESTA_P_MINUS_1: [u8; 32] = (-Fv::one()).to_repr();
pub static ref POSEIDON_CONSTANTS_PALLAS_2: PoseidonConstants::<Fp, U2> = PoseidonConstants::new();
/// An error that may occur when trying to decode an `EncodedPoint`.
#[derive(thiserror::Error, Debug)]
pub enum GroupDecodingError {
/// The coordinate(s) do not lie on the curve.
#[error("coordinate(s) do not lie on the curve")]
NotOnCurve,
/// The element is not part of the r-order subgroup.
#[error("the element is not part of an r-order subgroup")]
NotInSubgroup,
@DrPeterVanNostrand
DrPeterVanNostrand / pub_key.asc
Created July 8, 2020 14:50
Filecoin Mainnet Phase2 Contribution Signing Public-Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Filecoin phase2 signing public-key
mDMEXwXZgRYJKwYBBAHaRw8BAQdANphceXD34MmW48RYUb5RtxKRhJqP98ARq/vX
9/+3gMy0H0ZpbGVjb2luIG1haW5uZXQgcGhhc2UyIHNpZ25pbmeIkAQTFggAOBYh
BOo8TCYUQZ3uskzf9c50doIRIRbMBQJfBdmBAhsDBQsJCAcCBhUKCQgLAgQWAgMB
Ah4BAheAAAoJEM50doIRIRbMp8wA/1MGxChNn4+xInyAsLUb8UxgY8wPZVAivRZA
1ZcpGsXuAQCzRZQA4az3PH/7WUa2hZmkZtJOdqev2zpiXBFcVrYyDg==
=yno4
-----END PGP PUBLIC KEY BLOCK-----