(o *utils.OutputBuf, i *Instruction, field field.Field)
| 6 | ) |
| 7 | |
| 8 | func serializeInstruction(o *utils.OutputBuf, i *Instruction, field field.Field) { |
| 9 | o.AppendUint8(uint8(i.Type)) |
| 10 | switch i.Type { |
| 11 | case LinComb: |
| 12 | if len(i.Inputs) != len(i.LinCombCoef) { |
| 13 | panic("gg") |
| 14 | } |
| 15 | o.AppendUint64(uint64(len(i.Inputs))) |
| 16 | for _, x := range i.Inputs { |
| 17 | o.AppendUint64(uint64(x)) |
| 18 | } |
| 19 | for _, x := range i.LinCombCoef { |
| 20 | o.AppendFieldElement(field, x) |
| 21 | } |
| 22 | o.AppendFieldElement(field, i.Const) |
| 23 | case Mul: |
| 24 | o.AppendIntSlice(i.Inputs) |
| 25 | case Div: |
| 26 | o.AppendUint64(uint64(i.X)) |
| 27 | o.AppendUint64(uint64(i.Y)) |
| 28 | o.AppendUint8(uint8(i.ExtraId)) |
| 29 | case BoolBinOp: |
| 30 | o.AppendUint64(uint64(i.X)) |
| 31 | o.AppendUint64(uint64(i.Y)) |
| 32 | o.AppendUint8(uint8(i.ExtraId)) |
| 33 | case IsZero: |
| 34 | o.AppendUint64(uint64(i.X)) |
| 35 | case Commit: |
| 36 | o.AppendIntSlice(i.Inputs) |
| 37 | case Hint: |
| 38 | o.AppendUint64(uint64(i.ExtraId)) |
| 39 | o.AppendIntSlice(i.Inputs) |
| 40 | o.AppendUint64(uint64(i.NumOutputs)) |
| 41 | case ConstantLike: |
| 42 | if i.ExtraId == 0 { |
| 43 | o.AppendUint8(1) |
| 44 | o.AppendFieldElement(field, i.Const) |
| 45 | } else if i.ExtraId == 1 { |
| 46 | o.AppendUint8(2) |
| 47 | } else { |
| 48 | o.AppendUint8(3) |
| 49 | o.AppendUint64(uint64(i.ExtraId) - 2) |
| 50 | } |
| 51 | case SubCircuitCall: |
| 52 | o.AppendUint64(uint64(i.ExtraId)) |
| 53 | o.AppendIntSlice(i.Inputs) |
| 54 | o.AppendUint64(uint64(i.NumOutputs)) |
| 55 | case UnconstrainedBinOp: |
| 56 | panic("no unconstrained binop in gnark") |
| 57 | case UnconstrainedSelect: |
| 58 | panic("no unconstrained select in gnark") |
| 59 | case CustomGate: |
| 60 | o.AppendUint64(uint64(i.ExtraId)) |
| 61 | o.AppendIntSlice(i.Inputs) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func serializeCircuit(o *utils.OutputBuf, c *Circuit, field field.Field) { |
no test coverage detected