arnaucube
arnaucube/gnark-plonky2-verifierPublic Self-hosted repository
gnark-plonky2-verifier/verifier/internal/gates/selectors.go
verifier/internal/gates/selectors.goRaw
 1package gates
 2
 3const UNUSED_SELECTOR = uint64(^uint32(0)) // max uint32
 4
 5type Range struct {
 6	start uint64
 7	end   uint64
 8}
 9
10type SelectorsInfo struct {
11	selectorIndices []uint64
12	groups          []Range
13}
14
15func NewSelectorsInfo(selectorIndices []uint64, groupStarts []uint64, groupEnds []uint64) *SelectorsInfo {
16	if len(groupStarts) != len(groupEnds) {
17		panic("groupStarts and groupEnds must have the same length")
18	}
19
20	groups := []Range{}
21	for i := range groupStarts {
22		groups = append(groups, Range{
23			start: groupStarts[i],
24			end:   groupEnds[i],
25		})
26	}
27
28	return &SelectorsInfo{
29		selectorIndices: selectorIndices,
30		groups:          groups,
31	}
32}
33
34func (s *SelectorsInfo) NumSelectors() uint64 {
35	return uint64(len(s.groups))
36}