Skip to content
You are reading gnark development version documentation and some displayed features may not be available in the stable release. You can switch to stable version using the version box at screen bottom.

Updated on March 30, 2022

gnark standard library

We provide the following functions in gnark/std:

func (circuit *mimcCircuit) Define(api frontend.API) error {
    // ...
    hFunc, _ := mimc.NewMiMC(api.Curve())
    computedHash := hFunc.Hash(cs, circuit.Data)
    // ...
}
type eddsaCircuit struct {
    PublicKey eddsa.PublicKey           `gnark:",public"`
    Signature eddsa.Signature           `gnark:",public"`
    Message   frontend.Variable         `gnark:",public"`
}

func (circuit *eddsaCircuit) Define(api frontend.API) error {
    edCurve, _ := twistededwards.NewEdCurve(api.Curve())
    circuit.PublicKey.Curve = edCurve

    eddsa.Verify(cs, circuit.Signature, circuit.Message, circuit.PublicKey)
    return nil
}
type merkleCircuit struct {
    RootHash     frontend.Variable `gnark:",public"`
    Path, Helper []frontend.Variable
}

func (circuit *merkleCircuit) Define(api frontend.API) error {
    hFunc, _ := mimc.NewMiMC(api.Curve())
    merkle.VerifyProof(cs, hFunc, circuit.RootHash, circuit.Path, circuit.Helper)
    return nil
}

Enables verifying a BLS12_377 Groth16 Proof inside a BW6_761 circuit

type verifierCircuit struct {
    InnerProof Proof
    InnerVk    VerifyingKey
    Hash       frontend.Variable
}

func (circuit *verifierCircuit) Define(api frontend.API) error {

    groth16.Verify(api, circuit.InnerVk, circuit.InnerProof, []frontend.Variable{circuit.Hash})

    return nil
}
Questions or feedback? You can discuss issues and obtain free support on gnark discussions channel.
For paid professional support by Consensys, contact us at [email protected].