schema

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	// INPUT_REGISTER signals a register used for holding the input values of a
	// function.
	INPUT_REGISTER = RegisterType{uint8(0)}
	// OUTPUT_REGISTER signals a register used for holding the output values of
	// a function.
	OUTPUT_REGISTER = RegisterType{uint8(1)}
	// COMPUTED_REGISTER signals a register whose values are computed from one
	// (or more) assignments during trace expansion.
	COMPUTED_REGISTER = RegisterType{uint8(2)}
)
View Source
var BLS12_377 = FieldConfig{"BLS12_377", 252, 160}

BLS12_377 is the defacto default field at this time.

View Source
var FIELD_CONFIGS = []FieldConfig{
	GF_251,
	GF_8209,
	BLS12_377,
}

FIELD_CONFIGS determines the set of supported fields.

View Source
var GF_251 = FieldConfig{"GF_251", 7, 4}

GF_251 is teany tiny prime field used exclusively for testing.

View Source
var GF_8209 = FieldConfig{"GF_8209", 13, 8}

GF_8209 is small prime field used exclusively for testing.

Functions

func RequiredPaddingRows added in v1.0.1

func RequiredPaddingRows(module uint, defensive bool, schema AnySchema) uint

RequiredPaddingRows determines the number of additional (spillage / padding) rows that will be added during trace expansion. The exact value depends on whether defensive padding is enabled or not.

func WidthOfRegisters added in v1.1.14

func WidthOfRegisters(regs []Register, rids []RegisterId) uint

WidthOfRegisters returns the combined bitwidth of the given registers. For example, suppose we have three registers: x:u8, y:u8, z:u11. Then the combined width is 8+8+11=27.

Types

type AnySchema added in v1.1.11

type AnySchema = Schema[Constraint]

AnySchema captures a generic view of a schema, which is useful in situations where exactly details about the schema are not important.

func Any added in v1.1.11

func Any[C Constraint](schema Schema[C]) AnySchema

Any converts a concrete schema into a generic view of the schema.

type Assignment

type Assignment interface {
	// For the given module, determine any well-definedness bounds implied by
	// this assignment in  both the negative (left) or positive (right)
	// directions.  For example, consider an expression such as "(shift X -1)".
	// This is technically undefined for the first row of any trace and, by
	// association, any assignment evaluating this expression on that first row
	// is also undefined.
	Bounds(ModuleId) util.Bounds
	// ComputeColumns computes the values of columns defined by this assignment.
	// In order for this computation to makes sense, all columns on which this
	// assignment depends must exist (e.g. are either inputs or have been
	// computed already).  Computed columns do not exist in the original trace,
	// but are added during trace expansion to form the final trace.
	Compute(tr.Trace[bls12_377.Element], Schema[Constraint]) ([]tr.ArrayColumn, error)
	// Consistent applies a number of internal consistency checks.  Whilst not
	// strictly necessary, these can highlight otherwise hidden problems as an aid
	// to debugging.
	Consistent(Schema[Constraint]) []error
	// Identifier registers which are expanded by this assignment.  A register
	// is expanded when its length maybe changed.  For example, when going from
	// a trace which contains only rows of input/output values to a trace where
	// each function instance can occupy more than one row.  Then the I/O
	// columns are said to be "expanded".
	RegistersExpanded() []RegisterRef
	// Returns the set of columns that this assignment depends upon.  That can
	// include both input columns, as well as other computed columns.
	RegistersRead() []RegisterRef
	// Identifier registers assigned by this assignment.
	RegistersWritten() []RegisterRef
	// Lisp converts this schema element into a simple S-Expression, for example
	// so it can be printed.
	Lisp(AnySchema) sexp.SExp
}

Assignment represents an arbitrary computation which determines the values for one (or more) computed registers. For any computed register, there should only ever be one assignment. Likewise, every computed register should have an associated assignment. A good example of an assignment is computed the multiplicative inverse of a column in order to implement a non-zero check.

type Constraint

type Constraint interface {
	// Accepts determines whether a given constraint accepts a given trace or
	// not.  If not, a failure is produced.  Otherwise, a bitset indicating
	// branch coverage is returned.
	Accepts(trace.Trace[bls12_377.Element], AnySchema) (bit.Set, Failure)
	// Determine the well-definedness bounds for this constraint in both the
	// negative (left) or positive (right) directions.  For example, consider an
	// expression such as "(shift X -1)".  This is technically undefined for the
	// first row of any trace and, by association, any constraint evaluating
	// this expression on that first row is also undefined (and hence must pass)
	Bounds(module uint) util.Bounds
	// Consistent applies a number of internal consistency checks.  Whilst not
	// strictly necessary, these can highlight otherwise hidden problems as an aid
	// to debugging.
	Consistent(Schema[Constraint]) []error
	// Contexts returns the evaluation contexts (i.e. enclosing module + length
	// multiplier) for this constraint.  Most constraints have only a single
	// evaluation context, though some (e.g. lookups) have more.  Note that all
	// constraints have at least one context (which we can call the "primary"
	// context).
	Contexts() []ModuleId
	// Name returns a unique name for a given constraint.  This is useful purely
	// for identifying constraints in reports, etc.
	Name() string
	// Lisp converts this schema element into a simple S-Expression, for example
	// so it can be printed.
	Lisp(AnySchema) sexp.SExp
	// Substitute any matchined labelled constants within this constraint
	Substitute(map[string]fr.Element)
}

Constraint represents an element which can "accept" a trace, or either reject with an error (or eventually perhaps report a warning).

type Expander added in v1.1.11

type Expander[M any, C any] func(Schema[C], trace.Trace[bls12_377.Element]) trace.Trace[bls12_377.Element]

Expander functions are responsible for "filling" traces according to a given schema. More specifically, the determine values for all computed columns.

type Failure

type Failure interface {
	// Provides a suitable error message
	Message() string
}

Failure embodies structured information about a failing constraint. This includes the constraint itself, along with the row

func Accepts

func Accepts[C Constraint](
	parallel bool,
	batchsize uint,
	schema Schema[C],
	trace tr.Trace[bls12_377.Element],
) []Failure

Accepts determines whether this schema will accept a given trace. That is, whether or not the given trace adheres to the schema constraints. A trace can fail to adhere to the schema for a variety of reasons, such as having a constraint which does not hold.

type FieldAgnostic added in v1.1.12

type FieldAgnostic[T any] interface {
	// Subdivide for a given bandwidth and maximum register width. This will
	// split all registers wider than the maximum permitted width into two or
	// more "limbs" (i.e. subregisters which do not exceeded the permitted
	// width).  For example, consider a register "r" of width u32. Subdividing
	// this register into registers of at most 8bits will result in four limbs:
	// r'0, r'1, r'2 and r'3 where (by convention) r'0 is the least significant.
	//
	// As part of the subdivision process, constraints may also need to be
	// divided when they exceed the maximum permitted bandwidth.  For example,
	// consider a simple constraint such as "x = y + 1" using 16bit registers
	// x,y.  Subdividing for a bandwidth of 10bits and a maximum register width
	// of 8bits means splitting each register into two limbs, and transforming
	// our constraint into:
	//
	// 256*x'1 + x'0 = 256*y'1 + y'0 + 1
	//
	// However, as it stands, this constraint exceeds our bandwidth requirement
	// since it requires at least 17bits of information to safely evaluate each
	// side.  Thus, the constraint itself must be subdivided into two parts:
	//
	// 256*c + x'0 = y'0 + 1  // lower
	//
	//         x'1 = y'1 + c  // upper
	//
	// Here, c is a 1bit register introduced as part of the transformation to
	// act as a "carry" between the two constraints.
	Subdivide(LimbsMap) T
}

FieldAgnostic captures the notion of an entity (e.g. module, constraint or assignment) which is agnostic to the underlying field being used. More specificially, any registers used within (and constraints, etc) can be subdivided as necessary to ensure a maximum bandwidth requirement is met. Here, bandwidth refers to the maximum number of data bits which can be stored in the underlying field. As a simple example, the prime field F_7 has a bandwidth of 2bits. To target a specific prime field, two parameters are used: the maximum bandwidth (as determined by the prime); the maximum register width (which should be smaller than the bandwidth). The maximum register width determines the maximum permitted width of any register after subdivision. Since every register value will be stored as a field element, it follows that the maximum width cannot be greater than the bandwidth. However, in practice, we want it to be marginally less than the bandwidth to ensure there is some capacity for calculations involving registers.

type FieldAgnosticModule added in v1.1.11

type FieldAgnosticModule[M Module] interface {
	Module
	FieldAgnostic[M]
}

FieldAgnosticModule captures the notion of a module which is agnostic to the underlying field being used.

type FieldConfig added in v1.1.14

type FieldConfig struct {
	// Name suitable for identifying the config.  This is only really used for
	// improving error reporting, etc.
	Name string
	// Maximum field bandwidth available in the field.
	FieldBandWidth uint
	// Maximum register width to use with this field.
	RegisterWidth uint
}

FieldConfig provides a simple mechanism for configuring the field agnosticity pipeline.

func GetFieldConfig added in v1.1.14

func GetFieldConfig(name string) *FieldConfig

GetFieldConfig returns the field configuration corresponding with the given name, or nil no such config exists.

type Limb added in v1.1.13

type Limb = Register

Limb is just an alias for Register, but it helps to clarify when we are referring to a register after subdivision.

type LimbId added in v1.1.13

type LimbId = RegisterId

LimbId is just an alias for RegisterId, but it helps to clarify when we are referring to a register after subdivision.

type LimbsMap added in v1.1.14

type LimbsMap = ModuleMap[RegisterLimbsMap]

LimbsMap provides a high-level mapping of all registers across all modules before and after subdivision occurs.

type MixedSchema added in v1.1.11

type MixedSchema[M1 Module, M2 Module] struct {
	// contains filtered or unexported fields
}

MixedSchema represents a schema comprised of exactly two kinds of concrete module. This are split into those on the "left" (all of one kind) and those on the "right" (all of the other kind). This can be useful, for example, for packaging together modules from different layers, such as assembly and legacy (i.e. low-level) modules mixed together.

func NewMixedSchema added in v1.1.11

func NewMixedSchema[M1 Module, M2 Module](leftModules []M1, rightModules []M2) MixedSchema[M1, M2]

NewMixedSchema constructs a new schema composed of two distinct sets of modules, referred to as the "left" and the "right". Those on the left are allocated lower module indices, whilst the indices of those on the right begin immediately following the left.

func (MixedSchema[M1, M2]) Assignments added in v1.1.11

func (p MixedSchema[M1, M2]) Assignments() iter.Iterator[Assignment]

Assignments returns an iterator over the assignments of this schema These are the computations used to assign values to all computed columns in this schema.

func (MixedSchema[M1, M2]) Consistent added in v1.1.11

func (p MixedSchema[M1, M2]) Consistent() []error

Consistent applies a number of internal consistency checks. Whilst not strictly necessary, these can highlight otherwise hidden problems as an aid to debugging.

func (MixedSchema[M1, M2]) Constraints added in v1.1.11

func (p MixedSchema[M1, M2]) Constraints() iter.Iterator[Constraint]

Constraints returns an iterator over all constraints defined in this schema.

func (MixedSchema[M1, M2]) Expand added in v1.1.11

Expand a given trace according to this schema by determining appropriate values for all computed columns within the schema.

func (*MixedSchema[M1, M2]) GobDecode added in v1.1.11

func (p *MixedSchema[M1, M2]) GobDecode(data []byte) error

GobDecode a previously encoded option

func (MixedSchema[M1, M2]) GobEncode added in v1.1.11

func (p MixedSchema[M1, M2]) GobEncode() (data []byte, err error)

GobEncode an option. This allows it to be marshalled into a binary form.

func (MixedSchema[M1, M2]) HasModule added in v1.1.11

func (p MixedSchema[M1, M2]) HasModule(name string) (ModuleId, bool)

HasModule checks whether a module with the given name exists and, if so, returns its module identifier. Otherwise, it returns false.

func (MixedSchema[M1, M2]) LeftModules added in v1.1.11

func (p MixedSchema[M1, M2]) LeftModules() []M1

LeftModules returns those modules which form the "left" part of this mixed schema.

func (MixedSchema[M1, M2]) Module added in v1.1.11

func (p MixedSchema[M1, M2]) Module(module uint) Module

Module returns a given module in this schema.

func (MixedSchema[M1, M2]) Modules added in v1.1.11

func (p MixedSchema[M1, M2]) Modules() iter.Iterator[Module]

Modules returns an iterator over the declared set of modules within this schema.

func (MixedSchema[M1, M2]) Register added in v1.1.11

func (p MixedSchema[M1, M2]) Register(ref RegisterRef) Register

Register returns the given register in this schema.

func (MixedSchema[M1, M2]) RightModules added in v1.1.11

func (p MixedSchema[M1, M2]) RightModules() []M2

RightModules returns those modules which form the "right" part of this mixed schema.

func (MixedSchema[M1, M2]) Width added in v1.1.11

func (p MixedSchema[M1, M2]) Width() uint

Width returns the number of modules in this schema.

type Module

type Module interface {
	RegisterMap
	// Assignments returns an iterator over the assignments of this module.
	// These are the computations used to assign values to all computed columns
	// in this module.
	Assignments() iter.Iterator[Assignment]
	// Constraints provides access to those constraints associated with this
	// module.
	Constraints() iter.Iterator[Constraint]
	// Consistent applies a number of internal consistency checks.  Whilst not
	// strictly necessary, these can highlight otherwise hidden problems as an aid
	// to debugging.
	Consistent(Schema[Constraint]) []error
	// Identifies the length multiplier for this module.  For every trace, the
	// height of the corresponding module must be a multiple of this.  This is
	// used specifically to support interleaving constraints.
	LengthMultiplier() uint
	// AllowPadding determines the amount of initial padding a module expects.
	AllowPadding() bool
	// Module name
	Name() string
	// Returns the number of registers in this module.
	Width() uint
}

Module represents a "table" within a schema which contains zero or more rows for a given set of registers.

type ModuleId added in v1.1.11

type ModuleId = uint

ModuleId abstracts the notion of a "module identifier"

type ModuleMap added in v1.1.14

type ModuleMap[T RegisterMap] interface {
	// Field returns the underlying field configuration used for this mapping.
	// This includes the field bandwidth (i.e. number of bits available in
	// underlying field) and the maximum register width (i.e. width at which
	// registers are capped).
	Field() FieldConfig
	// Module returns register mapping information for the given module.
	Module(ModuleId) T
	// ModuleOf returns register mapping information for the given module.
	ModuleOf(string) T
}

ModuleMap provides a mapping from module identifiers (or names) to register maps.

type Register added in v1.1.11

type Register struct {
	// Kind of register (input / output)
	Kind RegisterType
	// Given name of this register.
	Name string
	// Width (in bits) of this register
	Width uint
}

Register represents a specific register in the schema that, eventually, will be mapped to one (or more) columns in the trace. Observe that multiple registers can end up being mapped to the same column via "register allocation". Likewise, a single register can end up being mapped across multiple columns as a result of subdivision to ensure field agnosticity. Hence, why they are referred to as registers rather than columns --- they are similar, but not identical, concepts.

func NewComputedRegister added in v1.1.11

func NewComputedRegister(name string, bitwidth uint) Register

NewComputedRegister constructs a new computed register with the given name and bitwidth.

func NewInputRegister added in v1.1.11

func NewInputRegister(name string, bitwidth uint) Register

NewInputRegister constructs a new input register with the given name and bitwidth.

func NewOutputRegister added in v1.1.11

func NewOutputRegister(name string, bitwidth uint) Register

NewOutputRegister constructs a new output register with the given name and bitwidth.

func NewRegister added in v1.1.11

func NewRegister(kind RegisterType, name string, bitwidth uint) Register

NewRegister constructs a new register of a given kind (i.e. input, output or computed) with the given name and bitwidth.

func (*Register) Bound added in v1.1.11

func (p *Register) Bound() *big.Int

Bound returns the first value which cannot be represented by the given bitwidth. For example, the bound of an 8bit register is 256.

func (*Register) IsComputed added in v1.1.11

func (p *Register) IsComputed() bool

IsComputed determines whether or not this is a computed register

func (*Register) IsInput added in v1.1.11

func (p *Register) IsInput() bool

IsInput determines whether or not this is an input register

func (*Register) IsInputOutput added in v1.1.11

func (p *Register) IsInputOutput() bool

IsInputOutput determines whether or not this is an input or output register

func (*Register) IsOutput added in v1.1.11

func (p *Register) IsOutput() bool

IsOutput determines whether or not this is an output register

func (*Register) MaxValue added in v1.1.11

func (p *Register) MaxValue() *big.Int

MaxValue returns the largest value expressible in this register (i.e. Bound() - 1). For example, the max value of an 8bit register is 255.

func (Register) QualifiedName added in v1.1.11

func (p Register) QualifiedName(mod RegisterMap) string

QualifiedName returns the fully qualified name of this register

func (Register) String added in v1.1.11

func (p Register) String() string

type RegisterAllocator added in v1.1.14

type RegisterAllocator interface {
	RegisterLimbsMap
	// AllocateCarry a fresh register of the given width within the target module.
	// This is presumed to be a computed register, and automatically assigned a
	// unique name.
	AllocateCarry(prefix string, width uint) RegisterId
}

RegisterAllocator extends a register mapping with the ability to allocate new registers as necessary. This is useful, for example, in the context of register splitting for introducing new carry registers.

func NewAllocator added in v1.1.14

func NewAllocator(mapping RegisterLimbsMap) RegisterAllocator

NewAllocator converts a mapping into a full allocator simply by wrapping the two fields.

type RegisterId added in v1.1.11

type RegisterId = trace.ColumnId

RegisterId captures the notion of a register index. That is, for each module, every register is allocated a given index starting from 0. The purpose of the wrapper is avoid confusion between uint values and things which are expected to identify Columns.

func NewRegisterId added in v1.1.11

func NewRegisterId(index uint) RegisterId

NewRegisterId constructs a new register ID from a given raw index.

func NewUnusedRegisterId added in v1.1.11

func NewUnusedRegisterId() RegisterId

NewUnusedRegisterId constructs something akin to a null reference. This is used in some situations where we may (or may not) want to refer to a specific register.

type RegisterLimbsMap added in v1.1.14

type RegisterLimbsMap interface {
	RegisterMap
	// Field returns the underlying field configuration used for this mapping.
	// This includes the field bandwidth (i.e. number of bits available in
	// underlying field) and the maximum register width (i.e. width at which
	// registers are capped).
	Field() FieldConfig
	// Limbs identifies the limbs into which a given register is divided.
	// Observe that limbs are ordered by their position in the original
	// register.  In particular, the first limb (i.e. at index 0) is always
	// least significant limb, and the last always most significant.
	LimbIds(RegisterId) []LimbId
	// Limbs returns information about a given limb (i.e. a register which
	// exists after the split).
	Limb(LimbId) Limb
	// Limbs returns all limbs in the mapping.
	Limbs() []Limb
	// LimbsMap returns a register map for the limbs themselves.  This is useful
	// where we need a register map over the limbs, rather than the original
	// registers.
	LimbsMap() RegisterMap
}

RegisterLimbsMap provides a high-level mapping of all registers before and after subdivision occurs within a given module. That is, it maps a given register to those limbs into which it was subdivided.

type RegisterMap added in v1.1.14

type RegisterMap interface {
	// Name returns the name given to the enclosing entity (i.e. module or
	// function).
	Name() string
	// HasRegister checks whether a register with the given name exists and, if
	// so, returns its register identifier.  Otherwise, it returns false.
	HasRegister(name string) (RegisterId, bool)
	// Access a given register in this module.
	Register(RegisterId) Register
	// Registers providers access to the underlying registers of this map.
	Registers() []Register
}

RegisterMap provides a generic interface for entities which hold information about registers.

type RegisterRef added in v1.1.11

type RegisterRef = trace.ColumnRef

RegisterRef abstracts a complete (i.e. global) register identifier.

func NewRegisterRef added in v1.1.11

func NewRegisterRef(mid ModuleId, rid RegisterId) RegisterRef

NewRegisterRef constructs a new register reference from the given module and register identifiers.

type RegisterType added in v1.1.11

type RegisterType struct {
	// contains filtered or unexported fields
}

RegisterType captures the type of a given register, such as whether it represents an input column, and output column or a computed register, etc.

func (*RegisterType) GobDecode added in v1.1.11

func (p *RegisterType) GobDecode(data []byte) error

GobDecode a previously encoded option

func (RegisterType) GobEncode added in v1.1.11

func (p RegisterType) GobEncode() (data []byte, err error)

GobEncode an option. This allows it to be marshalled into a binary form.

type Schema

type Schema[C any] interface {
	// Assignments returns an iterator over the assignments of this schema.
	// That is, the set of computations used to determine values for all
	// computed columns.
	Assignments() iter.Iterator[Assignment]
	// Consistent applies a number of internal consistency checks.  Whilst not
	// strictly necessary, these can highlight otherwise hidden problems as an aid
	// to debugging.
	Consistent() []error
	// Constraints returns an iterator over all constraints defined in this
	// schema.  Observe that this does include assertions which, strictly
	// speaking, are not constraints in the true sense.  That is, they are never
	// compiled into vanishing polynomials but, instead, are used purely for
	// debugging.
	Constraints() iter.Iterator[C]
	// HasModule checks whether a module with the given name exists and, if so,
	// returns its module identifier.  Otherwise, it returns false.
	HasModule(name string) (ModuleId, bool)
	// Access a given module in this schema.
	Module(module uint) Module
	// Modules returns an iterator over the declared set of modules within this
	// schema.
	Modules() iter.Iterator[Module]
	// Access a given register in this schema.
	Register(RegisterRef) Register
	// Returns the number of modules in this schema.
	Width() uint
}

Schema provides a fundamental interface which attempts to capture the essence of an arithmetisation. For simplicity, a schema consists entirely of one or more modules, where each module comprises some number of registers, constraints and assignments. Registers can be loosely thought of as columns in the final trace, whilst constraints are properties which should hold for any acceptable trace. Finally, assignments represent arbitrary computations which "assign" values to registers during "trace expansion".

type Table added in v1.1.11

type Table[C Constraint] struct {
	// contains filtered or unexported fields
}

Table provides a straightforward, reusable module implementation. There is nothing fancy here: we simply have a set of registers, constraints and assignments. A table is a field agnostic module with a simple strategy of subdividing registers "in place". For example, suppose we have registers X and Y (in that order) where both are to be halfed. Then, the result is X'0, X'1, Y'0. Y'1 (in that order). Hence, predicting the new register indices is relatively straightforward.

func NewTable added in v1.1.11

func NewTable[C Constraint](name string, multiplier uint, padding bool) *Table[C]

NewTable constructs a table module with the given registers and constraints.

func (*Table[C]) AddAssignments added in v1.1.11

func (p *Table[C]) AddAssignments(assignments ...Assignment)

AddAssignments adds a new assignments to this table.

func (*Table[C]) AddConstraints added in v1.1.11

func (p *Table[C]) AddConstraints(constraints ...C)

AddConstraints adds new constraints to this table.

func (*Table[C]) AddRegisters added in v1.1.11

func (p *Table[C]) AddRegisters(registers ...Register)

AddRegisters adds new registers to this table.

func (*Table[C]) AllowPadding added in v1.1.15

func (p *Table[C]) AllowPadding() bool

AllowPadding determines whether the given module supports padding at the beginning of the module. This is necessary because legacy modules expect an initial padding row, and allow defensive padding as well.

func (*Table[C]) Assignments added in v1.1.11

func (p *Table[C]) Assignments() iter.Iterator[Assignment]

Assignments provides access to those assignments defined as part of this table.

func (*Table[C]) Consistent added in v1.1.11

func (p *Table[C]) Consistent(schema Schema[Constraint]) []error

Consistent applies a number of internal consistency checks. Whilst not strictly necessary, these can highlight otherwise hidden problems as an aid to debugging.

func (*Table[C]) Constraints added in v1.1.11

func (p *Table[C]) Constraints() iter.Iterator[Constraint]

Constraints provides access to those constraints associated with this module.

func (*Table[M]) GobDecode added in v1.1.11

func (p *Table[M]) GobDecode(data []byte) error

GobDecode a previously encoded option

func (*Table[M]) GobEncode added in v1.1.11

func (p *Table[M]) GobEncode() (data []byte, err error)

GobEncode an option. This allows it to be marshalled into a binary form.

func (*Table[C]) HasRegister added in v1.1.11

func (p *Table[C]) HasRegister(name string) (RegisterId, bool)

HasRegister checks whether a register with the given name exists and, if so, returns its register identifier. Otherwise, it returns false.

func (*Table[C]) LengthMultiplier added in v1.1.11

func (p *Table[C]) LengthMultiplier() uint

LengthMultiplier identifies the length multiplier for this module. For every trace, the height of the corresponding module must be a multiple of this. This is used specifically to support interleaving constraints.

func (*Table[C]) Name added in v1.1.11

func (p *Table[C]) Name() string

Name returns the module name.

func (*Table[C]) Register added in v1.1.11

func (p *Table[C]) Register(id RegisterId) Register

Register returns the given register in this table.

func (*Table[C]) Registers added in v1.1.11

func (p *Table[C]) Registers() []Register

Registers returns an iterator over the underlying registers of this schema. Specifically, the index of a register in this array is its register index.

func (*Table[C]) Subdivide added in v1.1.12

func (p *Table[C]) Subdivide(mapping LimbsMap) *Table[C]

Subdivide implementation for the FieldAgnosticModule interface.

func (*Table[C]) Width added in v1.1.11

func (p *Table[C]) Width() uint

Width returns the number of registers in this Table.

type UniformSchema added in v1.1.11

type UniformSchema[M Module] struct {
	// contains filtered or unexported fields
}

UniformSchema represents the simplest kind of schema which contains only modules of the same kind (e.g. all MIR modules).

func NewUniformSchema added in v1.1.11

func NewUniformSchema[M Module](modules []M) UniformSchema[M]

NewUniformSchema constructs a new schema comprising the given modules.

func (UniformSchema[M]) Assignments added in v1.1.11

func (p UniformSchema[M]) Assignments() iter.Iterator[Assignment]

Assignments returns an iterator over the assignments of this schema These are the computations used to assign values to all computed columns in this schema.

func (UniformSchema[M]) Consistent added in v1.1.11

func (p UniformSchema[M]) Consistent() []error

Consistent applies a number of internal consistency checks. Whilst not strictly necessary, these can highlight otherwise hidden problems as an aid to debugging.

func (UniformSchema[M]) Constraints added in v1.1.11

func (p UniformSchema[M]) Constraints() iter.Iterator[Constraint]

Constraints returns an iterator over all constraints defined in this schema.

func (*UniformSchema[M]) GobDecode added in v1.1.11

func (p *UniformSchema[M]) GobDecode(data []byte) error

GobDecode a previously encoded option

func (UniformSchema[M]) GobEncode added in v1.1.11

func (p UniformSchema[M]) GobEncode() (data []byte, err error)

GobEncode an option. This allows it to be marshalled into a binary form.

func (UniformSchema[M]) HasModule added in v1.1.11

func (p UniformSchema[M]) HasModule(name string) (ModuleId, bool)

HasModule checks whether a module with the given name exists and, if so, returns its module identifier. Otherwise, it returns false.

func (UniformSchema[M]) Module added in v1.1.11

func (p UniformSchema[M]) Module(module uint) Module

Module provides access to a given module in this schema.

func (UniformSchema[M]) Modules added in v1.1.11

func (p UniformSchema[M]) Modules() iter.Iterator[Module]

Modules returns an iterator over the declared set of modules within this schema.

func (UniformSchema[M]) RawModules added in v1.1.11

func (p UniformSchema[M]) RawModules() []M

RawModules provides access to the underlying modules of this schema.

func (UniformSchema[M]) Register added in v1.1.11

func (p UniformSchema[M]) Register(ref RegisterRef) Register

Register returns the given register in this schema.

func (UniformSchema[M]) Width added in v1.1.11

func (p UniformSchema[M]) Width() uint

Width returns the number of modules in this schema.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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