acir

package
v0.0.0-...-0a9f7d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACIR

type ACIR[T shr.ACIRField, E constraint.Element] struct {
	NoirVersion  string                      `json:"noir_version"`
	Hash         uint64                      `json:"hash"`
	ABI          hdr.ACIRABI                 `json:"abi"`
	Program      Program[T, E]               `json:"program"`
	DebugSymbols string                      `json:"debug_symbols"`
	FileMap      map[string]hdr.ACIRFileData `json:"file_map"`
}

Struct representation of an ACIR programme

func LoadACIR

func LoadACIR[T shr.ACIRField, E constraint.Element](fileName string) (ACIR[T, E], error)

Loads ACIR from disk and creates representation in memory

func (*ACIR[T, E]) Compile

func (a *ACIR[T, E]) Compile() (constraint.ConstraintSystemGeneric[E], error)

func (*ACIR[T, E]) GetWitness

func (acir *ACIR[T, E]) GetWitness(fileName string, field *big.Int) (witness.Witness, error)

Constructs a gnark witness for the constraint system we generate when we call acir.compile() The trick here is that Gnark wants the public variables to be at the beginning of the witness vector, whereas the noir witness stack doesn't care about which variables are public

func (*ACIR[T, E]) PublicWitnesses

func (a *ACIR[T, E]) PublicWitnesses() []PublicWitness

PublicWitnesses returns the main circuit's public witness slots in the order gnark expects.

func (*ACIR[T, E]) String

func (a *ACIR[T, E]) String() string

func (*ACIR[T, E]) UnmarshalJSON

func (a *ACIR[T, E]) UnmarshalJSON(data []byte) error

Construct an ACIR instance from json data

type Circuit

type Circuit[T shr.ACIRField, E constraint.Element] struct {
	CircuitName         string
	CurrentWitnessIndex uint32
	Opcodes             []ops.Opcode[E] `json:"opcodes"`            // Opcodes in the circuit
	PrivateParameters   btree.BTree     `json:"private_parameters"` // Witnesses
	PublicParameters    btree.BTree     `json:"public_parameters"`  // Witnesses
	ReturnValues        btree.BTree     `json:"return_values"`      // Witnesses
	MemoryBlocks        map[uint32]*logderivlookup.Table
}

func (*Circuit[T, E]) Define

func (c *Circuit[T, E]) Define(api frontend.Builder[E], witnesses map[shr.Witness]frontend.Variable, resolve CircuitResolver[T, E], index *uint32) ([]frontend.Variable, []frontend.Variable, error)

Define the constraints for a circuit This returns the input and output variables of the circuit, so that circuits that call the circuit can check that the values they called the circuit with are consistent with the true value.

func (*Circuit[T, E]) UnmarshalReader

func (c *Circuit[T, E]) UnmarshalReader(r *msgpackutil.Reader) error

type CircuitResolver

type CircuitResolver[T shr.ACIRField, E constraint.Element] func(id uint32) (*Circuit[T, E], error)

The Circuit resolver is a function type that takes a circuit id and returns a reference to the circuit at that index and an error if no suh circuit exists

type DummyCircuit

type DummyCircuit struct{}

We need the dummy circuit to feed in our custom builder This makes sure that `callDeferred` is actually called on our custom builder See desired behaviour [here](https://github.com/Consensys/gnark/blob/master/frontend/compile.go#L159) and notice how it is not called by custom constraint system builders [here](https://github.com/Consensys/gnark/blob/55b0e54d2ae15e886ad37300a8d2b00ad00a8023/frontend/cs/r1cs/builder.go#L278)

func (*DummyCircuit) Define

func (a *DummyCircuit) Define(frontend.API) error

type Program

type Program[T shr.ACIRField, E constraint.Element] struct {
	Functions []Circuit[T, E] `json:"functions"`
}

Program struct represents the circuits in an ACIR programme

func (*Program[T, E]) Define

func (p *Program[T, E]) Define(
	api frontend.Builder[E],
	witnesses map[shr.Witness]frontend.Variable,
) error

Define adds constraints to the ACIR programme

func (*Program[T, E]) UnmarshalReader

func (p *Program[T, E]) UnmarshalReader(r *msgpackutil.Reader) error

func (*Program[T, E]) WitnessLayout

func (p *Program[T, E]) WitnessLayout() (totalSlots, mainStart uint32, err error)

WitnessLayout walks the call tree to determine the dense slot count and the global slot at which the main circuit's local witnesses begin. The witness space is laid out in postorder: each circuit reserves CurrentWitnessIndex+1 contiguous slots, with all transitively-called subcircuits placed before the caller.

type PublicWitness

type PublicWitness struct {
	MainIndex shr.Witness
	Name      string
}

PublicWitness names a witness slot of the main circuit that must be allocated as a public gnark variable.

type StackItem

type StackItem[T shr.ACIRField] struct {
	CircuitIndex uint32
	WitnessMap   map[shr.Witness]T
}

StackItem pairs a circuit's witness map with the function it corresponds to.

type WitnessStack

type WitnessStack[T shr.ACIRField] []StackItem[T]

WitnessStack stores witnesses from `nargo execute` in postorder based on circuit calls. For each execution, witnesses of called subcircuits are stored before their caller, so the main circuit’s witnesses appear last.

func LoadWitnessStackFromFile

func LoadWitnessStackFromFile[T shr.ACIRField](filePath string, modulus *big.Int) (WitnessStack[T], error)

LoadWitnessStackFromFile reads and decodes a witness stack file emitted by `nargo execute`. The wire envelope mirrors the bytecode side: gzip → format byte → msgpack-tagged payload. The payload is a `WitnessStack` struct containing a single tagged field 0 = Vec<StackItem>, where each StackItem has 0 = index (u32) and 1 = witness (WitnessMap, a fixmap of witness → FieldElement).

Directories

Path Synopsis
Package msgpackutil implements just enough of MessagePack to decode values emitted by any of noir's three ACIR serialization formats: `Msgpack` (string-keyed fixmap), `MsgpackCompact` (positional fixarray), and `MsgpackTagged` (int-keyed fixmap or positional fixarray per-type).
Package msgpackutil implements just enough of MessagePack to decode values emitted by any of noir's three ACIR serialization formats: `Msgpack` (string-keyed fixmap), `MsgpackCompact` (positional fixarray), and `MsgpackTagged` (int-keyed fixmap or positional fixarray per-type).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址