Skip to content

Uses proof_system crate and implements type serialization for net comms #1

Open
gpestana wants to merge 6 commits intoimeckler:masterfrom
gpestana:use_proof_system
Open

Uses proof_system crate and implements type serialization for net comms #1
gpestana wants to merge 6 commits intoimeckler:masterfrom
gpestana:use_proof_system

Conversation

@gpestana
Copy link
Copy Markdown

The goal of this PR is to refactor current PoC from using marlin to proof_system, which implements serde serialization out of the box.

The steps taken so far have been (split by commits):

Note: Currently using 1.56.0-x8664-apple-darwin

Commit 1 -- Update Cargo.toml to use proof_system and latest zexe

  • Remove all dependencies from marlin (submodule) and replace them with impls on proof_system crate.

  • Remove 5_wires naming from plonk dlog and circuit dependencies and use proof_system implementation

Result: 80 compilation errors due to different APIs between marlin and proof_system and latest zexe.

Commit 2 -- Fix dependencies names

Result: About 70 compilation errors due to most of proof_system dependencies relying on a different algebra implementation.

Commit 3 -- Replace algebra dependencies for ark and mina curves dependencies

Due to PR refactor zexe -> arkworks renaming imports, replace all algebra instances in bba implementation for ark_* when using crates circuits/plonk, curves, dlog/commitment, dlog/plonk, groupmap, oracle. In addition, use mina::curves instead of algebra curves.

Result: trait CommitmentField is not implemented for ark_ec::AffineCurve, as required by plonk_protocol_dlog::index::Index

Commit 4 -- Add trait bounds to high level types

Commit 5 -- Use algebra_core::FftField instead of ark_ff in fft.rs

Result:

  • Multiple trait bounds not implemented;
  • ProverCommitments structure changed from :
// plonk_5_wires_protocol_dlog::prover::ProverCommitments
pub struct ProverCommitments<G: AffineCurve>
{
    pub w_comm: [PolyComm<G>; COLUMNS],
    pub z_comm: PolyComm<G>,
    pub t_comm: PolyComm<G>,
}

// plonk_protocol_dlog::prover::ProverCommitments
pub struct ProverCommitments<G: AffineCurve> {
    pub l_comm: PolyComm<G>,
    pub r_comm: PolyComm<G>,
    pub o_comm: PolyComm<G>,
    pub z_comm: PolyComm<G>,
    pub t_comm: PolyComm<G>,
}

However, kimchi prover is similar to used plonk_5_wires

pub struct ProverCommitments<G: AffineCurve> {
    pub w_comm: [PolyComm<G>; COLUMNS],
    pub z_comm: PolyComm<G>,
    pub t_comm: PolyComm<G>,
    pub lookup: Option<LookupCommitments<G>>,
}
  • GateType enum changed;
// circuits::plom-5-wires::gate::GateType
pub enum GateType
{
    Zero,       // zero gate
    Generic,    // generic arithmetic gate
    Poseidon,   // Poseidon permutation gate
    Add,        // Gate constraining EC addition in Affine form
    Double,     // Gate constraining EC point doubling in Affine form
    Vbmul1,     // Gate constraining EC variable base scalar multiplication 
    Vbmul2,     // Gate constraining unpacking EC variable base scalar multiplication 
    Endomul,    // Gate constraining EC variable base scalar multiplication with group endomorphim optimization
    Pack,       // Gate constraining packing
}

// plonk_circuits::gate::GateType
pub enum GateType {
    Zero,    // zero gate
    Generic, // generic arithmetic gate

    Poseidon, // Poseidon permutation gate

    Add1, // Gate constraining EC addition in Affine form
    Add2, // Gate constraining EC point abscissa distinctness

    Vbmul1, // Gate constraining EC variable base scalar multiplication
    Vbmul2, // Gate constraining EC variable base scalar multiplication
    Vbmul3, // Gate constraining EC variable base scalar multiplication

    Endomul1, // Gate constraining EC variable base scalar multiplication with group endomorphim optimization
    Endomul2, // Gate constraining EC variable base scalar multiplication with group endomorphim optimization
    Endomul3, // Gate constraining EC variable base scalar multiplication with group endomorphim optimization
    Endomul4, // Gate constraining EC variable base scalar multiplication with group endomorphim optimization
}

However, kimchi circuit gate enum is similar to used plonk_5_wires

CompleteAdd instead of Add, etc

pub enum GateType {
    /// zero gate
    Zero = 0,
    /// generic arithmetic gate
    Generic,
    /// Poseidon permutation gate
    Poseidon,
    /// Complete EC addition in Affine form
    CompleteAdd,
    /// EC variable base scalar multiplication
    Vbmul,
    /// EC variable base scalar multiplication with group endomorphim optimization
    Endomul,
    /// Gate for computing the scalar corresponding to an endoscaling
    EndomulScalar,
    /// ChaCha
    ChaCha0,
    ChaCha1,
    ChaCha2,
    ChaChaFinal,
}

Commit 6 -- Use kimchi PLONK

Current state:

  • A bunch of trait bounds are not implemented/respected
  • GateType interface still does not match

@imeckler, since you have a much deeper understanding of the crates used, do you have tips/guidance on how to proceed from here? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant