Documentation ¶
Index ¶
- Constants
- func AssignExtractedData(run *wizard.ProverRuntime, lCols LogColumns, sel Selectors, ...)
- func AssignHasher(run *wizard.ProverRuntime, hasher LogHasher, fetched ExtractedData)
- func AssignRollingSelector(run *wizard.ProverRuntime, selector RollingSelector, ...)
- func CheckBridgeAddress(run *wizard.ProverRuntime, lCols LogColumns, sel Selectors, pos int) bool
- func CheckFirstTopic(run *wizard.ProverRuntime, lCols LogColumns, pos int, logType int) bool
- func ComputeSize(logs []LogInfo) int
- func ConvertAddress(address eth.Address) (field.Element, field.Element)
- func DefineExtractedData(comp *wizard.CompiledIOP, logCols LogColumns, sel Selectors, ...)
- func DefineHasher(comp *wizard.CompiledIOP, hasher LogHasher, name string, fetched ExtractedData)
- func DefineRollingSelector(comp *wizard.CompiledIOP, sel RollingSelector, name string, ...)
- func FirstTopicL2l1() (field.Element, field.Element)
- func FirstTopicRolling() (field.Element, field.Element)
- func GenerateTopicsAndAddresses() ([]field.Element, []field.Element, []field.Element, []field.Element)
- func GetFirstTopic(logType int) [32]byte
- func GetName(logType int) string
- func GetOffset(logType, offsetType int) int
- func GetPositionCounter(dataType int) int
- func GetSelectorCounter(sel Selectors, logType int) ifaces.Column
- func GetSelectorFirstTopicHi(sel Selectors, logType int) ifaces.Column
- func GetSelectorFirstTopicLo(sel Selectors, logType int) ifaces.Column
- func IsLogType(columns LogColumns, logType int) ifaces.Column
- func IsPositionTargetMessage(run *wizard.ProverRuntime, lCols LogColumns, sel Selectors, pos, logType int) bool
- func LogColumnsAssign(run *wizard.ProverRuntime, logCols *LogColumns, logs []LogInfo)
- type ExtractedData
- type LogColumns
- type LogColumnsAssignmentBuilder
- type LogHasher
- type LogInfo
- type RollingSelector
- type Selectors
Constants ¶
const ( // types of logs LOG0 int = 0 LOG1 int = 1 LOG2 int = 2 LOG3 int = 3 LOG4 int = 4 MISSING_LOG int = 5 )
const ( L2L1 int = 0 RollingMsgNo int = 1 RollingHash int = 2 FirstTopic int = 0 L2BridgeAddress int = 1 )
constants used to retrieve row offsets for various types of hashes
Variables ¶
This section is empty.
Functions ¶
func AssignExtractedData ¶
func AssignExtractedData(run *wizard.ProverRuntime, lCols LogColumns, sel Selectors, fetched ExtractedData, logType int)
AssignExtractedData fetches data from the LogColumns and uses it to populate the ExtractedData columns
func AssignHasher ¶
func AssignHasher(run *wizard.ProverRuntime, hasher LogHasher, fetched ExtractedData)
AssignHasher assigns the data in the LogHasher using the ExtractedData fetched from the arithmetization
func AssignRollingSelector ¶
func AssignRollingSelector(run *wizard.ProverRuntime, selector RollingSelector, fetchedHash, fetchedMsg ExtractedData)
AssignRollingSelector assigns the data in the RollingSelector using the ExtractedData fetched from the arithmetization
func CheckBridgeAddress ¶
func CheckBridgeAddress(run *wizard.ProverRuntime, lCols LogColumns, sel Selectors, pos int) bool
CheckBridgeAddress checks if a row does indeed contain the data corresponding to a the bridge address
func CheckFirstTopic ¶
func CheckFirstTopic(run *wizard.ProverRuntime, lCols LogColumns, pos int, logType int) bool
CheckFirstTopic checks if a row does indeed contain the data corresponding to a first topic in a L2l1/Rolling hash log
func ComputeSize ¶
ComputeSize computes the size of columns that have the same shape as the ones in the LogInfo module by taking into account the number of topics in each subsegment
func ConvertAddress ¶
ConvertAddress converts a 20 bytes address into the HI and LO parts on the arithmetization side
func DefineExtractedData ¶
func DefineExtractedData(comp *wizard.CompiledIOP, logCols LogColumns, sel Selectors, fetched ExtractedData, logType int)
DefineExtractedData uses LogColumns and helper Selectors to define columns that contain the ExtractedData of L2L1/Rolling Hash logs along with filters to select only L2L1/Rolling Hash logs. DefineExtractedData then uses a projection query to check that the data was fetched appropriately
func DefineHasher ¶
func DefineHasher(comp *wizard.CompiledIOP, hasher LogHasher, name string, fetched ExtractedData)
DefineHasher specifies the constraints of the LogHasher with respect to the ExtractedData fetched from the arithmetization
func DefineRollingSelector ¶
func DefineRollingSelector(comp *wizard.CompiledIOP, sel RollingSelector, name string, fetchedHash, fetchedMsg ExtractedData)
DefineRollingSelector specifies the constraints of the RollingSelector with respect to the ExtractedData fetched from the arithmetization
func FirstTopicL2l1 ¶
FirstTopicL2l1 is a helper function that outputs the Hi/Lo parts of the expected first topic of an L2L1 log
func FirstTopicRolling ¶
FirstTopicRolling is a helper function that outputs the Hi/Lo parts of the expected first topic of a RollingHash log
func GenerateTopicsAndAddresses ¶
func GenerateTopicsAndAddresses() ([]field.Element, []field.Element, []field.Element, []field.Element)
GenerateTopicsAndAddresses is a common test function that outputs sample topics and addresses
func GetFirstTopic ¶
GetFirstTopic returns the first topic of either an L2L1 or RollingHash log
func GetOffset ¶
GetOffset returns relevant offsets depending on the data we want to fetch from the arithmetization Case 1: L2L1 log, we want to extract the keccak-hashed messages. The first topic can be found 3 rows before, and the bridge address 4 rows before. Case 2: Rolling Hash Log: we extract either the message number or the Rolling hash itself the offsets for the first topic/bridgeAddress are -1/-2 and -2/-3
func GetPositionCounter ¶
GetPositionCounter returns the expected counter value for the data type we want to fetch
func GetSelectorCounter ¶
GetSelectorCounter returns the appropriate counter selector column for L2L1 or RollingHash logs
func GetSelectorFirstTopicHi ¶
GetSelectorFirstTopicHi returns the appropriate selector column for L2L1 or RollingHash logs
func GetSelectorFirstTopicLo ¶
GetSelectorFirstTopicLo returns the appropriate selector column for L2L1 or RollingHash logs
func IsLogType ¶
func IsLogType(columns LogColumns, logType int) ifaces.Column
IsLogType is used to select the proper isLogX column, it returns isLog4 for L2L1 logs and isLog3 for RollingHash logs
func IsPositionTargetMessage ¶
func IsPositionTargetMessage(run *wizard.ProverRuntime, lCols LogColumns, sel Selectors, pos, logType int) bool
IsPositionTargetMessage checks if a row does indeed contain the relevant messages corresponding to L2l1/RollingHash logs
func LogColumnsAssign ¶
func LogColumnsAssign(run *wizard.ProverRuntime, logCols *LogColumns, logs []LogInfo)
LogColumnsAssign uses test samples from LogInfo to populate LogColumns uses for testing in the fetching of messages from L2L1/RollingHash logs
Types ¶
type ExtractedData ¶
ExtractedData contains the data extracted from the arithmetization logs: L2L1 case: already Keccak-hashed messages, which will be hashed again using MiMC RollingHash case: either the message number stored in the Lo part or the RollingHash stored in both Hi/Lo
func NewExtractedData ¶
func NewExtractedData(comp *wizard.CompiledIOP, size int, name string) ExtractedData
NewExtractedData initializes a NewExtractedData struct, registering columns that are not yet constrained.
type LogColumns ¶
type LogColumns struct {
IsLog0, IsLog1, IsLog2, IsLog3, IsLog4 ifaces.Column
AbsLogNum ifaces.Column
AbsLogNumMax ifaces.Column // total number of logs in the conflated batch
Ct ifaces.Column // counter column used inside a column segment used for one specific log
DataHi, DataLo ifaces.Column // the Hi and Lo parts of outgoing data
TxEmitsLogs ifaces.Column
}
LogColumns represents the relevant columns for l2l1logs/RollingHash logs from the LogInfo module.
func NewLogColumns ¶
func NewLogColumns(comp *wizard.CompiledIOP, size int, name string) LogColumns
NewLogColumns returns a new LogColumns with initialized columns that are not constrained.
type LogColumnsAssignmentBuilder ¶
type LogColumnsAssignmentBuilder struct {
IsLog0, IsLog1, IsLog2, IsLog3, IsLog4 *common.VectorBuilder
AbsLogNum, AbsLogNumMax *common.VectorBuilder
Ct *common.VectorBuilder
OutgoingHi, OutgoingLo *common.VectorBuilder
TxEmitsLogs *common.VectorBuilder
}
LogColumnsAssignmentBuilder is a convenience structure storing the column builders relating to a LogColumns.
func NewLogColumnsAssignmentBuilder ¶
func NewLogColumnsAssignmentBuilder(lc *LogColumns) LogColumnsAssignmentBuilder
NewLogColumnsAssignmentBuilder initializes a fresh LogColumnsAssignmentBuilder
func (*LogColumnsAssignmentBuilder) PadAndAssign ¶
func (lc *LogColumnsAssignmentBuilder) PadAndAssign(run *wizard.ProverRuntime)
PadAndAssign pads all the column in `as` and assign them into `run`
func (*LogColumnsAssignmentBuilder) PushCounters ¶
func (lc *LogColumnsAssignmentBuilder) PushCounters(absLogNum, absLogNumMax, ct int)
PushCounters populates the counter columns in what will become LogColumns
func (*LogColumnsAssignmentBuilder) PushLogSelectors ¶
func (lc *LogColumnsAssignmentBuilder) PushLogSelectors(logType int)
PushLogSelectors populates the IsLogX and TxEmitsLogs columns in what will become LogColumns
type LogHasher ¶
type LogHasher struct { // the relevant value of the hash (the last value when isActive ends) HashFinal ifaces.Column // contains filtered or unexported fields }
LogHasher is used to MiMC-hash the data in LogMessages. Using a zero initial stata, the data in L2L1 logs must be hashed as follows: msg1HashHi, msg1HashLo, msg2HashHi, msg2HashLo, and so on. The hashing proceeds row by row. For row i, after hashing msgHashHi[i], the result is put into hashFirst[i]. hashFirst[i] is then used as the state to hash msgHashLo[i], and the result is put into hashSecond[i] Finally, hashSecond[i] is used as the initial state for hashing msgHashHi[i+1] Here is a diagram of how the values are computed state: 0 x1 x1' x2 block: msg1Hi msg1Lo msg2Hi msg2Lo .... MimcOutput x1 x1' x2 x2' x1, x2 will correspond to the values stored in hashFirst x1', x2' will correspond to values stored in hashSecond The final value of the chained hash can be retrieved as ---> hashSecond[ctMax[any index]]
func NewLogHasher ¶
func NewLogHasher(comp *wizard.CompiledIOP, size int, name string) LogHasher
NewLogHasher returns a new LogHasher with initialized columns that are not constrained.
type LogInfo ¶
type LogInfo struct { LogType int DataSize field.Element AddressHi, AddressLo field.Element TopicsHi, TopicsLo []field.Element // contains filtered or unexported fields }
LogInfo will be a mock data structure containing the minimal amount of information needed to generate test logs
func GenerateLargeTest ¶
func GenerateLargeTest() ([]LogInfo, types.EthAddress, string)
GenerateTestData generates test log info for testing the fetcher of message data from L2L1/RollingHash logs
func GenerateSimpleL2L1Test ¶
func GenerateSimpleL2L1Test() ([]LogInfo, types.EthAddress, string)
GenerateSimpleL2L1Test generates test log info for testing the fetcher of message data from L2L1 logs
func GenerateSimpleRollingTest ¶
func GenerateSimpleRollingTest() ([]LogInfo, types.EthAddress, string)
GenerateSimpleRollingTest generates test log info for testing the fetcher of message data from RollingHash logs
func GenerateTestWithoutRelevantLogs ¶
func GenerateTestWithoutRelevantLogs() ([]LogInfo, types.EthAddress, string)
GenerateTestWithoutRelevantLogs generates tests that contain no relevant L2L1/RollingHash logs
func (LogInfo) ConvertToL2L1Log ¶
ConvertToL2L1Log converts LogInfo structs into Log ones by adding dummy information for fees, value, salt, offset and calldata
type RollingSelector ¶
type RollingSelector struct { // Exists contains a 1 if there exists at least one rolling hash log Exists ifaces.Column // the Hi/Lo part of the first Rolling Hash found in the logs FirstHi, FirstLo ifaces.Column // the Hi/Lo part of the last Rolling Hash found in the logs LastHi, LastLo ifaces.Column // the first/last message number of the last Rolling hash log FirstMessageNo, LastMessageNo ifaces.Column }
RollingSelector is used to fetch the last rolling hash and its associated message number
func NewRollingSelector ¶
func NewRollingSelector(comp *wizard.CompiledIOP, name string) RollingSelector
NewRollingSelector returns a new RollingSelector with initialized columns that are not constrained.
type Selectors ¶
type Selectors struct { // size of selector columns Size int // SelectorCounterX is 1 when the counter Ct column in the logs satisfies Ct = X and 0 otherwise SelectorCounter0, SelectorCounter1, SelectorCounter3, SelectorCounter4, SelectorCounter5 ifaces.Column ComputeSelectorCounter0, ComputeSelectorCounter1, ComputeSelectorCounter3, ComputeSelectorCounter4, ComputeSelectorCounter5 wizard.ProverAction // SelectFirstTopicL2L1Hi/Lo is 1 on rows where the first topic has the shape expected from L2L1 logs SelectFirstTopicL2L1Hi, SelectFirstTopicL2L1Lo ifaces.Column ComputeSelectFirstTopicL2L1Hi, ComputeSelectFirstTopicL2L1Lo wizard.ProverAction // SelectFirstTopicRollingHi/Lo is 1 on rows where the first topic has the shape expected from L2L1 logs SelectFirstTopicRollingHi, SelectFirstTopicRollingLo ifaces.Column ComputeSelectFirstTopicRollingHi, ComputeSelectFirstTopicRollingLo wizard.ProverAction // columns containing the hi and lo parts of l2BridgeAddress L2BridgeAddressColHI, L2BridgeAddressColLo ifaces.Column // SelectorL2BridgeAddressHi/Lo is 1 on rows where the OutgoingHi/Lo columns contain the bridge address, // as expected from L2L1 logs SelectorL2BridgeAddressHi, SelectorL2BridgeAddressLo ifaces.Column ComputeSelectorL2BridgeAddressHi, ComputeSelectorL2BridgeAddressLo wizard.ProverAction }
Selectors contains helper columns for extracting the messages in a secure manner
func NewSelectorColumns ¶
func NewSelectorColumns(comp *wizard.CompiledIOP, lc LogColumns) Selectors
NewSelectorColumns creates the selector columns used to fetch data from LogColumns