diff --git a/protos/README.md b/protos/README.md new file mode 100644 index 0000000..c712a49 --- /dev/null +++ b/protos/README.md @@ -0,0 +1,4 @@ + +These protobuf definitions are taken from +the [`circom-witnesscalc`](https://github.com/iden3/circom-witnesscalc/tree/main/protos) +repository diff --git a/protos/messages.proto b/protos/messages.proto new file mode 100644 index 0000000..75cf6be --- /dev/null +++ b/protos/messages.proto @@ -0,0 +1,85 @@ +syntax = "proto3"; + +package circom_witnesscalc.proto; + +enum DuoOp { + Mul = 0; + Div = 1; + Add = 2; + Sub = 3; + Pow = 4; + Idiv = 5; + Mod = 6; + Eq = 7; + Neq = 8; + Lt = 9; + Gt = 10; + Leq = 11; + Geq = 12; + Land = 13; + Lor = 14; + Shl = 15; + Shr = 16; + Bor = 17; + Band = 18; + Bxor = 19; +} + +enum UnoOp { + Neg = 0; + Id = 1; +} + +enum TresOp { + TernCond = 0; +} + +message BigUInt { + bytes valueLE = 1; +} + +message InputNode { + uint32 idx = 1; +} + +message ConstantNode { + BigUInt value = 1; +} + +message UnoOpNode { + UnoOp op = 1; + uint32 aIdx = 2; +} + +message DuoOpNode { + DuoOp op = 1; + uint32 aIdx = 2; + uint32 bIdx = 3; +} + +message TresOpNode { + TresOp op = 1; + uint32 aIdx = 2; + uint32 bIdx = 3; + uint32 cIdx = 4; +} + +message Node { + oneof node { + InputNode input = 1; + ConstantNode constant = 2; + UnoOpNode unoOp = 3; + DuoOpNode duoOp = 4; + TresOpNode tresOp = 5; + } +} + +message SignalDescription { + uint32 offset = 1; + uint32 len = 2; +} + +message GraphMetadata { + repeated uint32 witnessSignals = 1; + map inputs = 2; +} diff --git a/protos/vm.proto b/protos/vm.proto new file mode 100644 index 0000000..11b6501 --- /dev/null +++ b/protos/vm.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package circom_witnesscalc.proto.vm; + +import "protos/messages.proto"; + +// Virtual Machine metadata +message VmMd { + uint32 main_template_id = 1; + uint32 templates_num = 2; + uint32 functions_num = 3; + uint32 signals_num = 4; + uint32 constants_num = 5; + map inputs = 9; + repeated uint32 witness_signals = 7; + map io_map = 8; +} + +message ComponentTmpl { + string symbol = 1; + uint64 sub_cmp_idx = 2; + uint64 number_of_cmp = 3; + string name_subcomponent = 4; + uint64 signal_offset = 5; + uint64 signal_offset_jump = 6; + uint64 template_id = 7; + bool has_inputs = 8; +} + +message Template { + string name = 1; + bytes code = 2; + repeated uint64 line_numbers = 3; + repeated ComponentTmpl components = 4; + uint64 var_stack_depth = 5; + uint64 number_of_inputs = 6; +} + +message Function { + string name = 1; + string symbol = 2; + bytes code = 3; + repeated uint64 line_numbers = 4; +} + +message IoDef { + uint32 code = 1; + uint32 offset = 2; + repeated uint32 lengths = 3; +} + +message IoDefs { + repeated IoDef io_defs = 1; +} \ No newline at end of file