Documentation ¶
Index ¶
- Constants
- func FillMemory(mem *memory.Memory, addModInputAddress memory.MemoryAddress, nAddMods uint64, ...) error
- func GetBuiltinAllocatedInstances(ratio uint64, cellsPerInstance uint64, segmentUsedSize uint64, ...) (uint64, error)
- func KeccakF1600(a *[25]uint64)
- func PoseidonPerm(x, y, z *fp.Element) []fp.Element
- func Runner(name BuiltinType) memory.BuiltinRunner
- type AirPrivateBuiltinBitwise
- type AirPrivateBuiltinECDSA
- type AirPrivateBuiltinECDSASignatureInput
- type AirPrivateBuiltinEcOp
- type AirPrivateBuiltinKeccak
- type AirPrivateBuiltinPedersen
- type AirPrivateBuiltinPoseidon
- type AirPrivateBuiltinRangeCheck
- type Bitwise
- func (b *Bitwise) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
- func (b *Bitwise) GetAirPrivateInput(bitwiseSegment *memory.Segment) []AirPrivateBuiltinBitwise
- func (b *Bitwise) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (b *Bitwise) InferValue(segment *memory.Segment, offset uint64) error
- func (b *Bitwise) String() string
- type BuiltinType
- type ECDSA
- func (e *ECDSA) AddSignature(pubOffset uint64, r, s *fp.Element) error
- func (e *ECDSA) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
- func (e *ECDSA) GetAirPrivateInput(ecdsaSegment *memory.Segment) ([]AirPrivateBuiltinECDSA, error)
- func (e *ECDSA) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (e *ECDSA) InferValue(segment *memory.Segment, offset uint64) error
- func (e *ECDSA) String() string
- type EcOp
- func (e *EcOp) CheckWrite(segment *mem.Segment, offset uint64, value *mem.MemoryValue) error
- func (e *EcOp) GetAirPrivateInput(ecOpSegment *mem.Segment) []AirPrivateBuiltinEcOp
- func (e *EcOp) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (e *EcOp) InferValue(segment *mem.Segment, offset uint64) error
- func (e *EcOp) String() string
- type Keccak
- func (k *Keccak) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
- func (k *Keccak) GetAirPrivateInput(keccakSegment *memory.Segment) []AirPrivateBuiltinKeccak
- func (k *Keccak) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (k *Keccak) InferValue(segment *memory.Segment, offset uint64) error
- func (k *Keccak) String() string
- type Layout
- type LayoutBuiltin
- type ModBuiltin
- func (m *ModBuiltin) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
- func (m *ModBuiltin) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (m *ModBuiltin) InferValue(segment *memory.Segment, offset uint64) error
- func (m *ModBuiltin) String() string
- type ModBuiltinInputs
- type ModBuiltinType
- type Output
- func (o *Output) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
- func (o *Output) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (o *Output) InferValue(segment *memory.Segment, offset uint64) error
- func (o *Output) String() string
- type Pedersen
- func (p *Pedersen) CheckWrite(segment *mem.Segment, offset uint64, value *mem.MemoryValue) error
- func (p *Pedersen) GetAirPrivateInput(pedersenSegment *mem.Segment) []AirPrivateBuiltinPedersen
- func (p *Pedersen) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (p *Pedersen) InferValue(segment *mem.Segment, offset uint64) error
- func (p *Pedersen) String() string
- type Poseidon
- func (p *Poseidon) CheckWrite(segment *mem.Segment, offset uint64, value *mem.MemoryValue) error
- func (p *Poseidon) GetAirPrivateInput(poseidonSegment *mem.Segment) []AirPrivateBuiltinPoseidon
- func (p *Poseidon) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (p *Poseidon) InferValue(segment *mem.Segment, offset uint64) error
- func (p *Poseidon) String() string
- type RangeCheck
- func (r *RangeCheck) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
- func (r *RangeCheck) GetAirPrivateInput(rangeCheckSegment *memory.Segment) []AirPrivateBuiltinRangeCheck
- func (r *RangeCheck) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
- func (r *RangeCheck) GetRangeCheckUsage(rangeCheckSegment *memory.Segment) (uint16, uint16)
- func (r *RangeCheck) InferValue(segment *memory.Segment, offset uint64) error
- func (r *RangeCheck) String() string
Constants ¶
const ( Base16 = 16 Base10 = 10 )
const ( RangeCheckName = "range_check" RangeCheck96Name = "range_check96" // Each range check instance consists of RangeCheckNParts 16-bit parts. INNER_RC_BOUND_SHIFT and INNER_RC_BOUND_MASK are used to extract 16-bit parts from the field elements stored in the range check segment. INNER_RC_BOUND_SHIFT = 16 INNER_RC_BOUND_MASK = (1 << 16) - 1 )
const (
BitwiseName = "bitwise"
)
const CELLS_PER_MOD = 7
number of memory cells per modulo builtin 4(felts) + 1(values_ptr) + 1(offsets_ptr) + 1(n) = 7
const (
ECDSAName = "ecdsa"
)
const (
EcOpName = "ec_op"
)
const (
KeccakName = "keccak"
)
const MAX_N = 100000
The maximum n value that the function fill_memory accepts
const ModuloName = "Mod"
const N_OFFSET = 6
const N_WORDS = 4
This is the number of felts in a UInt384 struct
const OFFSETS_PTR_OFFSET = 5
const OutputName = "output"
const (
PedersenName = "pedersen"
)
const PoseidonName = "poseidon"
const (
SegmentArenaName string = "segment_arena"
)
const VALUES_PTR_OFFSET = 4
These are the offsets in the array, which is used here as ModBuiltinInputs : INPUT_NAMES = [
"p0", "p1", "p2", "p3", "values_ptr", "offsets_ptr", "n",
]
Variables ¶
This section is empty.
Functions ¶
func FillMemory ¶
func FillMemory(mem *memory.Memory, addModInputAddress memory.MemoryAddress, nAddMods uint64, mulModInputAddress memory.MemoryAddress, nMulMods uint64) error
Fills the memory with inputs to the builtin instances based on the inputs to the first instance, pads the offsets table to fit the number of operations written in the input to the first instance, and calculates missing values in the values table.
The number of operations written to the input of the first instance n should be at least n and a multiple of batch_size. Previous offsets are copied to the end of the offsets table to make its length 3n'.
func GetBuiltinAllocatedInstances ¶
func GetBuiltinAllocatedInstances(ratio uint64, cellsPerInstance uint64, segmentUsedSize uint64, instancesPerComponent uint64, vmCurrentStep uint64) (uint64, error)
GetBuiltinAllocatedInstances calculates the number of instances of given builtin for current step and builtin ratio. Ratio parameter defines the ratio between the number of steps to the number of builtin instances. It means that this builtin is expected to be used once every 'ratio' steps of the execution. cellsPerInstance defines the number of cells that one instance of the builtin occupies. segmentUsedSize defines the real number of cells used in the segment. instancesPerComponent defines the number of instances per component (segment or a part of the Cairo program that makes use of builtins).
func KeccakF1600 ¶
func KeccakF1600(a *[25]uint64)
keccakF1600 applies the Keccak permutation to a 1600b-wide state represented as a slice of 25 uint64s.
func Runner ¶
func Runner(name BuiltinType) memory.BuiltinRunner
Types ¶
type AirPrivateBuiltinECDSA ¶
type AirPrivateBuiltinECDSA struct { Index int `json:"index"` PubKey string `json:"pubkey"` Msg string `json:"msg"` SignatureInput AirPrivateBuiltinECDSASignatureInput `json:"signature_input"` }
type AirPrivateBuiltinEcOp ¶
type AirPrivateBuiltinKeccak ¶
type AirPrivateBuiltinKeccak struct { Index int `json:"index"` InputS0 string `json:"input_s0"` InputS1 string `json:"input_s1"` InputS2 string `json:"input_s2"` InputS3 string `json:"input_s3"` InputS4 string `json:"input_s4"` InputS5 string `json:"input_s5"` InputS6 string `json:"input_s6"` InputS7 string `json:"input_s7"` }
type Bitwise ¶
type Bitwise struct {
// contains filtered or unexported fields
}
func (*Bitwise) CheckWrite ¶
func (*Bitwise) GetAirPrivateInput ¶
func (b *Bitwise) GetAirPrivateInput(bitwiseSegment *memory.Segment) []AirPrivateBuiltinBitwise
func (*Bitwise) GetAllocatedSize ¶
func (*Bitwise) InferValue ¶
type BuiltinType ¶
type BuiltinType uint8
const ( OutputType BuiltinType = iota + 1 RangeCheckType PedersenType ECDSAType KeccakType BitwiseType ECOPType PoseidonType SegmentArenaType RangeCheck96Type AddModeType MulModType )
func (BuiltinType) MarshalJSON ¶
func (b BuiltinType) MarshalJSON() ([]byte, error)
func (*BuiltinType) UnmarshalJSON ¶
func (b *BuiltinType) UnmarshalJSON(data []byte) error
type ECDSA ¶
type ECDSA struct { Signatures map[uint64]ecdsa.Signature // contains filtered or unexported fields }
func (*ECDSA) AddSignature ¶
Hint that will call this function looks like this:
"hints": { "6": [ { "accessible_scopes": [ "starkware.cairo.common.signature", "starkware.cairo.common.signature.verify_ecdsa_signature" ], "code": "ecdsa_builtin.add_signature(ids.ecdsa_ptr.address_, (ids.signature_r, ids.signature_s))", "flow_tracking_data": { "ap_tracking": { "group": 2, "offset": 0 }, "reference_ids": { "starkware.cairo.common.signature.verify_ecdsa_signature.ecdsa_ptr": 4, "starkware.cairo.common.signature.verify_ecdsa_signature.message": 0, "starkware.cairo.common.signature.verify_ecdsa_signature.public_key": 1, "starkware.cairo.common.signature.verify_ecdsa_signature.signature_r": 2, "starkware.cairo.common.signature.verify_ecdsa_signature.signature_s": 3 } } } ] },
func (*ECDSA) CheckWrite ¶
verify_ecdsa_signature(message_hash, public_key, sig_r, sig_s)
func (*ECDSA) GetAirPrivateInput ¶
func (e *ECDSA) GetAirPrivateInput(ecdsaSegment *memory.Segment) ([]AirPrivateBuiltinECDSA, error)
func (*ECDSA) GetAllocatedSize ¶
type EcOp ¶
type EcOp struct {
// contains filtered or unexported fields
}
func (*EcOp) CheckWrite ¶
func (*EcOp) GetAirPrivateInput ¶
func (e *EcOp) GetAirPrivateInput(ecOpSegment *mem.Segment) []AirPrivateBuiltinEcOp
func (*EcOp) GetAllocatedSize ¶
type Keccak ¶
type Keccak struct {
// contains filtered or unexported fields
}
func (*Keccak) CheckWrite ¶
func (*Keccak) GetAirPrivateInput ¶
func (k *Keccak) GetAirPrivateInput(keccakSegment *memory.Segment) []AirPrivateBuiltinKeccak
func (*Keccak) GetAllocatedSize ¶
func (*Keccak) InferValue ¶
type Layout ¶
type Layout struct { // Name of the layout Name string // Number of range check units allowed per step RcUnits uint64 // List of builtins to be included in given layout Builtins []LayoutBuiltin }
type LayoutBuiltin ¶
type LayoutBuiltin struct { // Runner for the builtin Runner memory.BuiltinRunner // Builtin id from starknet parser Builtin BuiltinType }
type ModBuiltin ¶
type ModBuiltin struct {
// contains filtered or unexported fields
}
func NewModBuiltin ¶
func NewModBuiltin(ratio uint64, wordBitLen uint64, batchSize uint64, modBuiltinType ModBuiltinType) *ModBuiltin
func (*ModBuiltin) CheckWrite ¶
func (m *ModBuiltin) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
func (*ModBuiltin) GetAllocatedSize ¶
func (m *ModBuiltin) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
func (*ModBuiltin) InferValue ¶
func (m *ModBuiltin) InferValue(segment *memory.Segment, offset uint64) error
func (*ModBuiltin) String ¶
func (m *ModBuiltin) String() string
type ModBuiltinInputs ¶
type ModBuiltinInputs struct {
// contains filtered or unexported fields
}
type ModBuiltinType ¶
type ModBuiltinType string
const ( Add ModBuiltinType = "Add" Mul ModBuiltinType = "Mul" )
type Output ¶
type Output struct{}
func (*Output) CheckWrite ¶
func (*Output) GetAllocatedSize ¶
func (*Output) InferValue ¶
type Pedersen ¶
type Pedersen struct {
// contains filtered or unexported fields
}
func (*Pedersen) CheckWrite ¶
func (*Pedersen) GetAirPrivateInput ¶
func (p *Pedersen) GetAirPrivateInput(pedersenSegment *mem.Segment) []AirPrivateBuiltinPedersen
func (*Pedersen) GetAllocatedSize ¶
func (*Pedersen) InferValue ¶
type Poseidon ¶
type Poseidon struct {
// contains filtered or unexported fields
}
func (*Poseidon) CheckWrite ¶
func (*Poseidon) GetAirPrivateInput ¶
func (p *Poseidon) GetAirPrivateInput(poseidonSegment *mem.Segment) []AirPrivateBuiltinPoseidon
func (*Poseidon) GetAllocatedSize ¶
func (*Poseidon) InferValue ¶
type RangeCheck ¶
type RangeCheck struct { RangeCheckNParts uint64 // contains filtered or unexported fields }
func (*RangeCheck) CheckWrite ¶
func (r *RangeCheck) CheckWrite(segment *memory.Segment, offset uint64, value *memory.MemoryValue) error
func (*RangeCheck) GetAirPrivateInput ¶
func (r *RangeCheck) GetAirPrivateInput(rangeCheckSegment *memory.Segment) []AirPrivateBuiltinRangeCheck
func (*RangeCheck) GetAllocatedSize ¶
func (r *RangeCheck) GetAllocatedSize(segmentUsedSize uint64, vmCurrentStep uint64) (uint64, error)
func (*RangeCheck) GetRangeCheckUsage ¶
func (r *RangeCheck) GetRangeCheckUsage(rangeCheckSegment *memory.Segment) (uint16, uint16)
GetRangeCheckUsage returns the min and max values used in the range check segment. Since each range check instance consists of 16-bit parts, the min and max values are calculated by iterating over the segment data and extracting the 16-bit parts from each field element.
func (*RangeCheck) InferValue ¶
func (r *RangeCheck) InferValue(segment *memory.Segment, offset uint64) error
func (*RangeCheck) String ¶
func (r *RangeCheck) String() string