MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / DeserializeRootCircuit

Function DeserializeRootCircuit

ecgo/layered/serialize.go:94–168  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

92}
93
94func DeserializeRootCircuit(buf []byte) *RootCircuit {
95 in := utils.NewInputBuf(buf)
96 if in.ReadUint64() != MAGIC {
97 panic("invalid file header")
98 }
99 rc := &RootCircuit{}
100 rc.Field = in.ReadBigInt(32)
101 rc.NumPublicInputs = int(in.ReadUint64())
102 rc.NumActualOutputs = int(in.ReadUint64())
103 rc.ExpectedNumOutputZeroes = int(in.ReadUint64())
104 bnlen := field.GetFieldFromOrder(rc.Field).SerializedLen()
105 nbCircuits := in.ReadUint64()
106 rc.Circuits = make([]*Circuit, nbCircuits)
107 for i := uint64(0); i < nbCircuits; i++ {
108 c := &Circuit{}
109 c.InputLen = in.ReadUint64()
110 c.OutputLen = in.ReadUint64()
111 nbSubCircuits := in.ReadUint64()
112 c.SubCircuits = make([]SubCircuit, nbSubCircuits)
113 for j := uint64(0); j < nbSubCircuits; j++ {
114 sub := SubCircuit{}
115 sub.Id = in.ReadUint64()
116 nbAllocations := in.ReadUint64()
117 sub.Allocations = make([]Allocation, nbAllocations)
118 for k := uint64(0); k < nbAllocations; k++ {
119 sub.Allocations[k].InputOffset = in.ReadUint64()
120 sub.Allocations[k].OutputOffset = in.ReadUint64()
121 }
122 c.SubCircuits[j] = sub
123 }
124 nbMul := in.ReadUint64()
125 c.Mul = make([]GateMul, nbMul)
126 for j := uint64(0); j < nbMul; j++ {
127 c.Mul[j].In0 = in.ReadUint64()
128 c.Mul[j].In1 = in.ReadUint64()
129 c.Mul[j].Out = in.ReadUint64()
130 c.Mul[j].Coef, c.Mul[j].CoefType, c.Mul[j].PublicInputId = deserializeCoef(in, bnlen)
131 }
132 nbAdd := in.ReadUint64()
133 c.Add = make([]GateAdd, nbAdd)
134 for j := uint64(0); j < nbAdd; j++ {
135 c.Add[j].In = in.ReadUint64()
136 c.Add[j].Out = in.ReadUint64()
137 c.Add[j].Coef, c.Add[j].CoefType, c.Add[j].PublicInputId = deserializeCoef(in, bnlen)
138 }
139 nbCst := in.ReadUint64()
140 c.Cst = make([]GateCst, nbCst)
141 for j := uint64(0); j < nbCst; j++ {
142 c.Cst[j].Out = in.ReadUint64()
143 c.Cst[j].Coef, c.Cst[j].CoefType, c.Cst[j].PublicInputId = deserializeCoef(in, bnlen)
144 }
145 nbCustom := in.ReadUint64()
146 c.Custom = make([]GateCustom, nbCustom)
147 for j := uint64(0); j < nbCustom; j++ {
148 c.Custom[j].GateType = in.ReadUint64()
149 nbIn := in.ReadUint64()
150 c.Custom[j].In = make([]uint64, nbIn)
151 for k := uint64(0); k < nbIn; k++ {

Callers 2

CompileFunction · 0.92

Calls 7

ReadUint64Method · 0.95
ReadBigIntMethod · 0.95
IsEndMethod · 0.95
NewInputBufFunction · 0.92
GetFieldFromOrderFunction · 0.92
deserializeCoefFunction · 0.85
SerializedLenMethod · 0.65

Tested by

no test coverage detected