asm

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Propagate

func Propagate[T io.Instruction, M sc.Module[word.BigEndian]](p MixedProgram[word.BigEndian, T, M],
	trace lt.TraceFile) (lt.TraceFile, []error)

Propagate secondary (i.e. derivative) function instances throughout a trace. For example, suppose two functions "f(x)" and "g(y)", where f(x) calls g(y). Then, consider a trace which contains exactly one instance "f(a)=b". Since f(x) calls g(y) we may (depending on the exact implementation of f(x) and the parameter given) require a secondary instance, say "g(y)=c", to be added to make the trace complete with respect to the original instance. Trace propagation is about figuring out what secondary instances are required, and adding them to the trace.

NOTES:

Parallelism? Validation? Batch size? Recursion limit (to prevent infinite loops)

func PropagateAll

func PropagateAll[T io.Instruction, M sc.Module[word.BigEndian]](p MixedProgram[word.BigEndian, T, M],
	ts []lt.TraceFile) ([]lt.TraceFile, []error)

PropagateAll propagates secondary (i.e. derivative) function instances throughout one or more traces. NOTES:

Parallelism? Validation? Batch size? Recursion limit (to prevent infinite loops)

Types

type Element

type Element[F any] = field.Element[F]

Element provides a convenient shorthand.

type LoweringConfig

type LoweringConfig struct {
	// Field determines necessary parameters for the underlying field.  This
	// includes: the maximum field bandwidth, which is number of bits the
	// underlying field can hold; and, the maximum register width.
	Field field.Config
}

LoweringConfig provides configuration options for configuring the lowering process.

type MicroComponent

type MicroComponent = io.Component[micro.Instruction]

MicroComponent is a component whose instructions (if applicable) are themselves micro instructions. A micro function represents the lowest representation of a function, where each instruction is made up of microcodes.

type MicroFunction

type MicroFunction = io.Function[micro.Instruction]

MicroFunction is a function whose instructions are themselves micro instructions. A micro function represents the lowest representation of a function, where each instruction is made up of microcodes.

type MicroHirProgram

type MicroHirProgram = MixedProgram[word.BigEndian, micro.Instruction, hir.Module]

MicroHirProgram represents a mixed assembly and legacy program, where assembly functions are composed from micro instructions.

type MicroMirProgram

type MicroMirProgram[F field.Element[F]] = MixedProgram[F, micro.Instruction, mir.Module[F]]

MicroMirProgram represents a mixed assembly and legacy program, where assembly functions are composed from micro instructions.

func Concretize

func Concretize[F Element[F]](cfg field.Config, hp MicroHirProgram,
) (MicroMirProgram[F], module.LimbsMap)

Concretize field agnostic entities (e.g. modules, constraints or assignments) to a specific concrete field. To make this possible, any registers used within (and constraints, etc) will 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. Two parameters are given in the field configuration to specify the target field: the maximum bandwidth (as determined by the modulus); 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.

As part of concretization, registers wider than the maximum permitted width are split 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 this 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.

type MicroModule

type MicroModule[F field.Element[F]] = program.Module[F, micro.Instruction]

MicroModule is an instance of schema.Module which encapsulates a MicroFunction[F].

type MicroProgram

type MicroProgram = io.Program[micro.Instruction]

MicroProgram represents a set of components at the micro level.

type MixedProgram

type MixedProgram[F field.Element[F], T io.Instruction, M schema.Module[F]] struct {
	// contains filtered or unexported fields
}

MixedProgram represents the composition of an assembly program along with zero or more legacy (i.e. external) modules.

func NewMixedProgram

func NewMixedProgram[F field.Element[F], T io.Instruction, M schema.Module[F]](program io.Program[T], externs ...M,
) MixedProgram[F, T, M]

NewMixedProgram constructs a new program using a given level of instruction.

func (*MixedProgram[F, T, M]) Assignments

func (p *MixedProgram[F, T, M]) Assignments() iter.Iterator[schema.Assignment[F]]

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 (*MixedProgram[F, T, M]) Component

func (p *MixedProgram[F, T, M]) Component(id uint) io.Component[T]

Component returns the ith component in this program, where a component is e.g. a function or a form of memory, etc.

func (*MixedProgram[F, T, Map]) Components

func (p *MixedProgram[F, T, Map]) Components() []io.Component[T]

Components returns all functions making up this program, where a component is e.g. a function or a form of memory, etc.

func (*MixedProgram[F, T, M]) Consistent

func (p *MixedProgram[F, T, M]) Consistent(fieldWidth uint) []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 (*MixedProgram[F, T, M]) Constraints

func (p *MixedProgram[F, T, M]) Constraints() iter.Iterator[schema.Constraint[F]]

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

func (*MixedProgram[F, T, M]) Externs

func (p *MixedProgram[F, T, M]) Externs() []M

Externs returns the set of external modules

func (*MixedProgram[F, T, M]) GobDecode

func (p *MixedProgram[F, T, M]) GobDecode(data []byte) error

GobDecode a previously encoded option

func (*MixedProgram[F, T, M]) GobEncode

func (p *MixedProgram[F, T, M]) GobEncode() (data []byte, err error)

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

func (*MixedProgram[F, T, M]) HasModule

func (p *MixedProgram[F, T, M]) HasModule(name module.Name) (schema.ModuleId, bool)

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

func (*MixedProgram[F, T, M]) Module

func (p *MixedProgram[F, T, M]) Module(module uint) schema.Module[F]

Module returns a given module in this schema.

func (*MixedProgram[F, T, M]) Modules

func (p *MixedProgram[F, T, M]) Modules() iter.Iterator[schema.Module[F]]

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

func (*MixedProgram[F, T, M]) Register

func (p *MixedProgram[F, T, M]) Register(ref register.Ref) Register

Register returns the given register in this schema.

func (*MixedProgram[F, T, M]) Width

func (p *MixedProgram[F, T, M]) Width() uint

Width returns the number of modules in this schema.

type RawModule

type RawModule = lt.Module[word.BigEndian]

RawModule provides a convenient alias

type Register

type Register = io.Register

Register describes a single register within a function.

type UniformSchema

type UniformSchema[F field.Element[F]] = sc.UniformSchema[F, mir.Module[F]]

UniformSchema provides a convenient shorthand.

func Compile

func Compile[F Element[F]](p MicroMirProgram[F]) UniformSchema[F]

Compile a mixed micro program into a uniform MIR schema.

Directories

Path Synopsis
io
micro/dfa
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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