zkinterface/
zkinterface_generated.rs

1// automatically generated by the FlatBuffers compiler, do not modify
2
3
4
5use std::mem;
6use std::cmp::Ordering;
7
8extern crate flatbuffers;
9use self::flatbuffers::EndianScalar;
10
11#[allow(unused_imports, dead_code)]
12pub mod zkinterface {
13
14  use std::mem;
15  use std::cmp::Ordering;
16
17  extern crate flatbuffers;
18  use self::flatbuffers::EndianScalar;
19
20#[allow(non_camel_case_types)]
21#[repr(u8)]
22#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
23pub enum Message {
24  NONE = 0,
25  CircuitHeader = 1,
26  ConstraintSystem = 2,
27  Witness = 3,
28  Command = 4,
29
30}
31
32pub const ENUM_MIN_MESSAGE: u8 = 0;
33pub const ENUM_MAX_MESSAGE: u8 = 4;
34
35impl<'a> flatbuffers::Follow<'a> for Message {
36  type Inner = Self;
37  #[inline]
38  fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
39    flatbuffers::read_scalar_at::<Self>(buf, loc)
40  }
41}
42
43impl flatbuffers::EndianScalar for Message {
44  #[inline]
45  fn to_little_endian(self) -> Self {
46    let n = u8::to_le(self as u8);
47    let p = &n as *const u8 as *const Message;
48    unsafe { *p }
49  }
50  #[inline]
51  fn from_little_endian(self) -> Self {
52    let n = u8::from_le(self as u8);
53    let p = &n as *const u8 as *const Message;
54    unsafe { *p }
55  }
56}
57
58impl flatbuffers::Push for Message {
59    type Output = Message;
60    #[inline]
61    fn push(&self, dst: &mut [u8], _rest: &[u8]) {
62        flatbuffers::emplace_scalar::<Message>(dst, *self);
63    }
64}
65
66#[allow(non_camel_case_types)]
67pub const ENUM_VALUES_MESSAGE:[Message; 5] = [
68  Message::NONE,
69  Message::CircuitHeader,
70  Message::ConstraintSystem,
71  Message::Witness,
72  Message::Command
73];
74
75#[allow(non_camel_case_types)]
76pub const ENUM_NAMES_MESSAGE:[&'static str; 5] = [
77    "NONE",
78    "CircuitHeader",
79    "ConstraintSystem",
80    "Witness",
81    "Command"
82];
83
84pub fn enum_name_message(e: Message) -> &'static str {
85  let index = e as u8;
86  ENUM_NAMES_MESSAGE[index as usize]
87}
88
89pub struct MessageUnionTableOffset {}
90pub enum CircuitHeaderOffset {}
91#[derive(Copy, Clone, Debug, PartialEq)]
92
93/// A description of a circuit or sub-circuit.
94/// This can be a complete circuit ready for proving,
95/// or a part of a circuit being built.
96pub struct CircuitHeader<'a> {
97  pub _tab: flatbuffers::Table<'a>,
98}
99
100impl<'a> flatbuffers::Follow<'a> for CircuitHeader<'a> {
101    type Inner = CircuitHeader<'a>;
102    #[inline]
103    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
104        Self {
105            _tab: flatbuffers::Table { buf: buf, loc: loc },
106        }
107    }
108}
109
110impl<'a> CircuitHeader<'a> {
111    #[inline]
112    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
113        CircuitHeader {
114            _tab: table,
115        }
116    }
117    #[allow(unused_mut)]
118    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
119        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
120        args: &'args CircuitHeaderArgs<'args>) -> flatbuffers::WIPOffset<CircuitHeader<'bldr>> {
121      let mut builder = CircuitHeaderBuilder::new(_fbb);
122      builder.add_free_variable_id(args.free_variable_id);
123      if let Some(x) = args.configuration { builder.add_configuration(x); }
124      if let Some(x) = args.field_maximum { builder.add_field_maximum(x); }
125      if let Some(x) = args.instance_variables { builder.add_instance_variables(x); }
126      builder.finish()
127    }
128
129    pub const VT_INSTANCE_VARIABLES: flatbuffers::VOffsetT = 4;
130    pub const VT_FREE_VARIABLE_ID: flatbuffers::VOffsetT = 6;
131    pub const VT_FIELD_MAXIMUM: flatbuffers::VOffsetT = 8;
132    pub const VT_CONFIGURATION: flatbuffers::VOffsetT = 10;
133
134  /// Instance variables. This is also called public inputs to the circuit.
135  ///
136  /// - Variables are allocated by the sender of this message.
137  /// - The same structure must be provided for R1CS and witness generations.
138  /// - Values may be omitted in some contexts, such as in a preprocessing phase.
139  /// - During witness generation, variables must be assigned values.
140  /// - In the particular context of a gadget call, `instance_variables` holds the inputs
141  ///   to the gadget, i.e. variables allocated by the caller that the gadget can
142  ///   refer to. In the context of a gadget response, it holds the outputs of the gadget,
143  ///   i.e. variables allocated by the gadget that the caller can refer to.
144  #[inline]
145  pub fn instance_variables(&self) -> Option<Variables<'a>> {
146    self._tab.get::<flatbuffers::ForwardsUOffset<Variables<'a>>>(CircuitHeader::VT_INSTANCE_VARIABLES, None)
147  }
148  /// A variable ID greater than all IDs allocated by the sender of this message.
149  /// The recipient of this message can allocate new IDs >= free_variable_id.
150  #[inline]
151  pub fn free_variable_id(&self) -> u64 {
152    self._tab.get::<u64>(CircuitHeader::VT_FREE_VARIABLE_ID, Some(0)).unwrap()
153  }
154  /// The largest element of the finite field used by the current system.
155  /// A canonical little-endian representation of the field order minus one.
156  /// See `Variables.values` below.
157  #[inline]
158  pub fn field_maximum(&self) -> Option<&'a [u8]> {
159    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(CircuitHeader::VT_FIELD_MAXIMUM, None).map(|v| v.safe_slice())
160  }
161  /// Optional: Any custom parameter that may influence the circuit construction.
162  ///
163  /// Example: function_name, if a gadget supports multiple function variants.
164  /// Example: the depth of a Merkle tree.
165  /// Counter-example: a Merkle path is not config and belongs in `instance_variables.info`.
166  #[inline]
167  pub fn configuration(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
168    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>>>(CircuitHeader::VT_CONFIGURATION, None)
169  }
170}
171
172pub struct CircuitHeaderArgs<'a> {
173    pub instance_variables: Option<flatbuffers::WIPOffset<Variables<'a >>>,
174    pub free_variable_id: u64,
175    pub field_maximum: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a ,  u8>>>,
176    pub configuration: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a , flatbuffers::ForwardsUOffset<KeyValue<'a >>>>>,
177}
178impl<'a> Default for CircuitHeaderArgs<'a> {
179    #[inline]
180    fn default() -> Self {
181        CircuitHeaderArgs {
182            instance_variables: None,
183            free_variable_id: 0,
184            field_maximum: None,
185            configuration: None,
186        }
187    }
188}
189pub struct CircuitHeaderBuilder<'a: 'b, 'b> {
190  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
191  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
192}
193impl<'a: 'b, 'b> CircuitHeaderBuilder<'a, 'b> {
194  #[inline]
195  pub fn add_instance_variables(&mut self, instance_variables: flatbuffers::WIPOffset<Variables<'b >>) {
196    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Variables>>(CircuitHeader::VT_INSTANCE_VARIABLES, instance_variables);
197  }
198  #[inline]
199  pub fn add_free_variable_id(&mut self, free_variable_id: u64) {
200    self.fbb_.push_slot::<u64>(CircuitHeader::VT_FREE_VARIABLE_ID, free_variable_id, 0);
201  }
202  #[inline]
203  pub fn add_field_maximum(&mut self, field_maximum: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
204    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(CircuitHeader::VT_FIELD_MAXIMUM, field_maximum);
205  }
206  #[inline]
207  pub fn add_configuration(&mut self, configuration: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<KeyValue<'b >>>>) {
208    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(CircuitHeader::VT_CONFIGURATION, configuration);
209  }
210  #[inline]
211  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> CircuitHeaderBuilder<'a, 'b> {
212    let start = _fbb.start_table();
213    CircuitHeaderBuilder {
214      fbb_: _fbb,
215      start_: start,
216    }
217  }
218  #[inline]
219  pub fn finish(self) -> flatbuffers::WIPOffset<CircuitHeader<'a>> {
220    let o = self.fbb_.end_table(self.start_);
221    flatbuffers::WIPOffset::new(o.value())
222  }
223}
224
225pub enum ConstraintSystemOffset {}
226#[derive(Copy, Clone, Debug, PartialEq)]
227
228/// ConstraintSystem represents constraints to be added to the constraint system.
229///
230/// Multiple such messages are equivalent to the concatenation of `constraints` arrays.
231pub struct ConstraintSystem<'a> {
232  pub _tab: flatbuffers::Table<'a>,
233}
234
235impl<'a> flatbuffers::Follow<'a> for ConstraintSystem<'a> {
236    type Inner = ConstraintSystem<'a>;
237    #[inline]
238    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
239        Self {
240            _tab: flatbuffers::Table { buf: buf, loc: loc },
241        }
242    }
243}
244
245impl<'a> ConstraintSystem<'a> {
246    #[inline]
247    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
248        ConstraintSystem {
249            _tab: table,
250        }
251    }
252    #[allow(unused_mut)]
253    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
254        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
255        args: &'args ConstraintSystemArgs<'args>) -> flatbuffers::WIPOffset<ConstraintSystem<'bldr>> {
256      let mut builder = ConstraintSystemBuilder::new(_fbb);
257      if let Some(x) = args.info { builder.add_info(x); }
258      if let Some(x) = args.constraints { builder.add_constraints(x); }
259      builder.finish()
260    }
261
262    pub const VT_CONSTRAINTS: flatbuffers::VOffsetT = 4;
263    pub const VT_INFO: flatbuffers::VOffsetT = 6;
264
265  #[inline]
266  pub fn constraints(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<BilinearConstraint<'a>>>> {
267    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<BilinearConstraint<'a>>>>>(ConstraintSystem::VT_CONSTRAINTS, None)
268  }
269  /// Optional: Any complementary info that may be useful.
270  ///
271  /// Example: human-readable descriptions.
272  /// Example: custom hints to an optimizer or analyzer.
273  #[inline]
274  pub fn info(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
275    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>>>(ConstraintSystem::VT_INFO, None)
276  }
277}
278
279pub struct ConstraintSystemArgs<'a> {
280    pub constraints: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a , flatbuffers::ForwardsUOffset<BilinearConstraint<'a >>>>>,
281    pub info: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a , flatbuffers::ForwardsUOffset<KeyValue<'a >>>>>,
282}
283impl<'a> Default for ConstraintSystemArgs<'a> {
284    #[inline]
285    fn default() -> Self {
286        ConstraintSystemArgs {
287            constraints: None,
288            info: None,
289        }
290    }
291}
292pub struct ConstraintSystemBuilder<'a: 'b, 'b> {
293  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
294  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
295}
296impl<'a: 'b, 'b> ConstraintSystemBuilder<'a, 'b> {
297  #[inline]
298  pub fn add_constraints(&mut self, constraints: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<BilinearConstraint<'b >>>>) {
299    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ConstraintSystem::VT_CONSTRAINTS, constraints);
300  }
301  #[inline]
302  pub fn add_info(&mut self, info: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<KeyValue<'b >>>>) {
303    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(ConstraintSystem::VT_INFO, info);
304  }
305  #[inline]
306  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> ConstraintSystemBuilder<'a, 'b> {
307    let start = _fbb.start_table();
308    ConstraintSystemBuilder {
309      fbb_: _fbb,
310      start_: start,
311    }
312  }
313  #[inline]
314  pub fn finish(self) -> flatbuffers::WIPOffset<ConstraintSystem<'a>> {
315    let o = self.fbb_.end_table(self.start_);
316    flatbuffers::WIPOffset::new(o.value())
317  }
318}
319
320pub enum WitnessOffset {}
321#[derive(Copy, Clone, Debug, PartialEq)]
322
323/// Witness represents an assignment of values to variables.
324///
325/// - Does not include variables already given in `CircuitHeader.instance_variables`.
326/// - Does not include the constant one variable.
327/// - Multiple such messages are equivalent to the concatenation of `Variables` arrays.
328pub struct Witness<'a> {
329  pub _tab: flatbuffers::Table<'a>,
330}
331
332impl<'a> flatbuffers::Follow<'a> for Witness<'a> {
333    type Inner = Witness<'a>;
334    #[inline]
335    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
336        Self {
337            _tab: flatbuffers::Table { buf: buf, loc: loc },
338        }
339    }
340}
341
342impl<'a> Witness<'a> {
343    #[inline]
344    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
345        Witness {
346            _tab: table,
347        }
348    }
349    #[allow(unused_mut)]
350    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
351        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
352        args: &'args WitnessArgs<'args>) -> flatbuffers::WIPOffset<Witness<'bldr>> {
353      let mut builder = WitnessBuilder::new(_fbb);
354      if let Some(x) = args.assigned_variables { builder.add_assigned_variables(x); }
355      builder.finish()
356    }
357
358    pub const VT_ASSIGNED_VARIABLES: flatbuffers::VOffsetT = 4;
359
360  #[inline]
361  pub fn assigned_variables(&self) -> Option<Variables<'a>> {
362    self._tab.get::<flatbuffers::ForwardsUOffset<Variables<'a>>>(Witness::VT_ASSIGNED_VARIABLES, None)
363  }
364}
365
366pub struct WitnessArgs<'a> {
367    pub assigned_variables: Option<flatbuffers::WIPOffset<Variables<'a >>>,
368}
369impl<'a> Default for WitnessArgs<'a> {
370    #[inline]
371    fn default() -> Self {
372        WitnessArgs {
373            assigned_variables: None,
374        }
375    }
376}
377pub struct WitnessBuilder<'a: 'b, 'b> {
378  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
379  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
380}
381impl<'a: 'b, 'b> WitnessBuilder<'a, 'b> {
382  #[inline]
383  pub fn add_assigned_variables(&mut self, assigned_variables: flatbuffers::WIPOffset<Variables<'b >>) {
384    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Variables>>(Witness::VT_ASSIGNED_VARIABLES, assigned_variables);
385  }
386  #[inline]
387  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> WitnessBuilder<'a, 'b> {
388    let start = _fbb.start_table();
389    WitnessBuilder {
390      fbb_: _fbb,
391      start_: start,
392    }
393  }
394  #[inline]
395  pub fn finish(self) -> flatbuffers::WIPOffset<Witness<'a>> {
396    let o = self.fbb_.end_table(self.start_);
397    flatbuffers::WIPOffset::new(o.value())
398  }
399}
400
401pub enum CommandOffset {}
402#[derive(Copy, Clone, Debug, PartialEq)]
403
404/// Optional: Command messages can be used to request actions from the receiver. This makes it
405/// possible to write code that works in different environments. Commands and parameters
406/// can be passed over the same byte stream as other messages; if so Command must be the first
407/// message. This reduces the need for environment-specific methods (it can replace CLI --flags, etc).
408pub struct Command<'a> {
409  pub _tab: flatbuffers::Table<'a>,
410}
411
412impl<'a> flatbuffers::Follow<'a> for Command<'a> {
413    type Inner = Command<'a>;
414    #[inline]
415    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
416        Self {
417            _tab: flatbuffers::Table { buf: buf, loc: loc },
418        }
419    }
420}
421
422impl<'a> Command<'a> {
423    #[inline]
424    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
425        Command {
426            _tab: table,
427        }
428    }
429    #[allow(unused_mut)]
430    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
431        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
432        args: &'args CommandArgs<'args>) -> flatbuffers::WIPOffset<Command<'bldr>> {
433      let mut builder = CommandBuilder::new(_fbb);
434      if let Some(x) = args.parameters { builder.add_parameters(x); }
435      builder.add_witness_generation(args.witness_generation);
436      builder.add_constraints_generation(args.constraints_generation);
437      builder.finish()
438    }
439
440    pub const VT_CONSTRAINTS_GENERATION: flatbuffers::VOffsetT = 4;
441    pub const VT_WITNESS_GENERATION: flatbuffers::VOffsetT = 6;
442    pub const VT_PARAMETERS: flatbuffers::VOffsetT = 8;
443
444  /// For gadget flows.
445  /// Request the generation of a constraint system (or part thereof).
446  /// If true, this must be followed by a CircuitHeader.
447  /// The response must be another CircuitHeader message with a greater `free_variable_id`
448  /// followed by one or more ConstraintSystem messages.
449  #[inline]
450  pub fn constraints_generation(&self) -> bool {
451    self._tab.get::<bool>(Command::VT_CONSTRAINTS_GENERATION, Some(false)).unwrap()
452  }
453  /// For gadget flows.
454  /// Request the generation of a witness (or part thereof).
455  /// If true, this must be followed by a CircuitHeader, and the `instance_variables`
456  /// variables must contain input values.
457  /// The response must be another CircuitHeader message, with a greater `free_variable_id`,
458  /// with output values in `instance_variables`, followed by one or more `Witness` messages.
459  #[inline]
460  pub fn witness_generation(&self) -> bool {
461    self._tab.get::<bool>(Command::VT_WITNESS_GENERATION, Some(false)).unwrap()
462  }
463  /// Optional: Any complementary parameter that may be useful.
464  #[inline]
465  pub fn parameters(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
466    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>>>(Command::VT_PARAMETERS, None)
467  }
468}
469
470pub struct CommandArgs<'a> {
471    pub constraints_generation: bool,
472    pub witness_generation: bool,
473    pub parameters: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a , flatbuffers::ForwardsUOffset<KeyValue<'a >>>>>,
474}
475impl<'a> Default for CommandArgs<'a> {
476    #[inline]
477    fn default() -> Self {
478        CommandArgs {
479            constraints_generation: false,
480            witness_generation: false,
481            parameters: None,
482        }
483    }
484}
485pub struct CommandBuilder<'a: 'b, 'b> {
486  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
487  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
488}
489impl<'a: 'b, 'b> CommandBuilder<'a, 'b> {
490  #[inline]
491  pub fn add_constraints_generation(&mut self, constraints_generation: bool) {
492    self.fbb_.push_slot::<bool>(Command::VT_CONSTRAINTS_GENERATION, constraints_generation, false);
493  }
494  #[inline]
495  pub fn add_witness_generation(&mut self, witness_generation: bool) {
496    self.fbb_.push_slot::<bool>(Command::VT_WITNESS_GENERATION, witness_generation, false);
497  }
498  #[inline]
499  pub fn add_parameters(&mut self, parameters: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<KeyValue<'b >>>>) {
500    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Command::VT_PARAMETERS, parameters);
501  }
502  #[inline]
503  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> CommandBuilder<'a, 'b> {
504    let start = _fbb.start_table();
505    CommandBuilder {
506      fbb_: _fbb,
507      start_: start,
508    }
509  }
510  #[inline]
511  pub fn finish(self) -> flatbuffers::WIPOffset<Command<'a>> {
512    let o = self.fbb_.end_table(self.start_);
513    flatbuffers::WIPOffset::new(o.value())
514  }
515}
516
517pub enum BilinearConstraintOffset {}
518#[derive(Copy, Clone, Debug, PartialEq)]
519
520/// A single R1CS constraint between variables.
521///
522/// - Represents the linear combinations of variables A, B, C such that:
523///       (A) * (B) = (C)
524/// - A linear combination is given as a sequence of (variable ID, coefficient).
525pub struct BilinearConstraint<'a> {
526  pub _tab: flatbuffers::Table<'a>,
527}
528
529impl<'a> flatbuffers::Follow<'a> for BilinearConstraint<'a> {
530    type Inner = BilinearConstraint<'a>;
531    #[inline]
532    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
533        Self {
534            _tab: flatbuffers::Table { buf: buf, loc: loc },
535        }
536    }
537}
538
539impl<'a> BilinearConstraint<'a> {
540    #[inline]
541    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
542        BilinearConstraint {
543            _tab: table,
544        }
545    }
546    #[allow(unused_mut)]
547    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
548        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
549        args: &'args BilinearConstraintArgs<'args>) -> flatbuffers::WIPOffset<BilinearConstraint<'bldr>> {
550      let mut builder = BilinearConstraintBuilder::new(_fbb);
551      if let Some(x) = args.linear_combination_c { builder.add_linear_combination_c(x); }
552      if let Some(x) = args.linear_combination_b { builder.add_linear_combination_b(x); }
553      if let Some(x) = args.linear_combination_a { builder.add_linear_combination_a(x); }
554      builder.finish()
555    }
556
557    pub const VT_LINEAR_COMBINATION_A: flatbuffers::VOffsetT = 4;
558    pub const VT_LINEAR_COMBINATION_B: flatbuffers::VOffsetT = 6;
559    pub const VT_LINEAR_COMBINATION_C: flatbuffers::VOffsetT = 8;
560
561  #[inline]
562  pub fn linear_combination_a(&self) -> Option<Variables<'a>> {
563    self._tab.get::<flatbuffers::ForwardsUOffset<Variables<'a>>>(BilinearConstraint::VT_LINEAR_COMBINATION_A, None)
564  }
565  #[inline]
566  pub fn linear_combination_b(&self) -> Option<Variables<'a>> {
567    self._tab.get::<flatbuffers::ForwardsUOffset<Variables<'a>>>(BilinearConstraint::VT_LINEAR_COMBINATION_B, None)
568  }
569  #[inline]
570  pub fn linear_combination_c(&self) -> Option<Variables<'a>> {
571    self._tab.get::<flatbuffers::ForwardsUOffset<Variables<'a>>>(BilinearConstraint::VT_LINEAR_COMBINATION_C, None)
572  }
573}
574
575pub struct BilinearConstraintArgs<'a> {
576    pub linear_combination_a: Option<flatbuffers::WIPOffset<Variables<'a >>>,
577    pub linear_combination_b: Option<flatbuffers::WIPOffset<Variables<'a >>>,
578    pub linear_combination_c: Option<flatbuffers::WIPOffset<Variables<'a >>>,
579}
580impl<'a> Default for BilinearConstraintArgs<'a> {
581    #[inline]
582    fn default() -> Self {
583        BilinearConstraintArgs {
584            linear_combination_a: None,
585            linear_combination_b: None,
586            linear_combination_c: None,
587        }
588    }
589}
590pub struct BilinearConstraintBuilder<'a: 'b, 'b> {
591  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
592  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
593}
594impl<'a: 'b, 'b> BilinearConstraintBuilder<'a, 'b> {
595  #[inline]
596  pub fn add_linear_combination_a(&mut self, linear_combination_a: flatbuffers::WIPOffset<Variables<'b >>) {
597    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Variables>>(BilinearConstraint::VT_LINEAR_COMBINATION_A, linear_combination_a);
598  }
599  #[inline]
600  pub fn add_linear_combination_b(&mut self, linear_combination_b: flatbuffers::WIPOffset<Variables<'b >>) {
601    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Variables>>(BilinearConstraint::VT_LINEAR_COMBINATION_B, linear_combination_b);
602  }
603  #[inline]
604  pub fn add_linear_combination_c(&mut self, linear_combination_c: flatbuffers::WIPOffset<Variables<'b >>) {
605    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<Variables>>(BilinearConstraint::VT_LINEAR_COMBINATION_C, linear_combination_c);
606  }
607  #[inline]
608  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> BilinearConstraintBuilder<'a, 'b> {
609    let start = _fbb.start_table();
610    BilinearConstraintBuilder {
611      fbb_: _fbb,
612      start_: start,
613    }
614  }
615  #[inline]
616  pub fn finish(self) -> flatbuffers::WIPOffset<BilinearConstraint<'a>> {
617    let o = self.fbb_.end_table(self.start_);
618    flatbuffers::WIPOffset::new(o.value())
619  }
620}
621
622pub enum VariablesOffset {}
623#[derive(Copy, Clone, Debug, PartialEq)]
624
625/// A description of multiple variables.
626///
627/// - Each variable is identified by a numerical ID.
628/// - Each variable can be assigned a concrete value.
629/// - In `CircuitHeader.instance_variables`, the IDs indicate which variables are
630///   meant to be shared as inputs or outputs of a sub-circuit.
631/// - During witness generation, the values form the assignment to the variables.
632/// - In `BilinearConstraint` linear combinations, the values are the coefficients
633///   applied to variables in a linear combination.
634pub struct Variables<'a> {
635  pub _tab: flatbuffers::Table<'a>,
636}
637
638impl<'a> flatbuffers::Follow<'a> for Variables<'a> {
639    type Inner = Variables<'a>;
640    #[inline]
641    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
642        Self {
643            _tab: flatbuffers::Table { buf: buf, loc: loc },
644        }
645    }
646}
647
648impl<'a> Variables<'a> {
649    #[inline]
650    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
651        Variables {
652            _tab: table,
653        }
654    }
655    #[allow(unused_mut)]
656    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
657        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
658        args: &'args VariablesArgs<'args>) -> flatbuffers::WIPOffset<Variables<'bldr>> {
659      let mut builder = VariablesBuilder::new(_fbb);
660      if let Some(x) = args.info { builder.add_info(x); }
661      if let Some(x) = args.values { builder.add_values(x); }
662      if let Some(x) = args.variable_ids { builder.add_variable_ids(x); }
663      builder.finish()
664    }
665
666    pub const VT_VARIABLE_IDS: flatbuffers::VOffsetT = 4;
667    pub const VT_VALUES: flatbuffers::VOffsetT = 6;
668    pub const VT_INFO: flatbuffers::VOffsetT = 8;
669
670  /// The IDs of the variables.
671  ///
672  /// - IDs must be unique within a constraint system.
673  /// - The ID 0 always represents the constant variable one.
674  #[inline]
675  pub fn variable_ids(&self) -> Option<flatbuffers::Vector<'a, u64>> {
676    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u64>>>(Variables::VT_VARIABLE_IDS, None)
677  }
678  /// Optional: values assigned to variables.
679  ///
680  /// - Values are finite field elements as defined by `header.field_maximum`.
681  /// - Elements are represented in canonical little-endian form.
682  /// - Elements appear in the same order as variable_ids.
683  /// - Multiple elements are concatenated in a single byte array.
684  /// - The element representation may be truncated and its size shorter
685  ///   than `header.field_maximum`. Truncated bytes are treated as zeros.
686  /// - The size of an element representation is determined by:
687  ///
688  ///     element size = values.length / variable_ids.length
689  #[inline]
690  pub fn values(&self) -> Option<&'a [u8]> {
691    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Variables::VT_VALUES, None).map(|v| v.safe_slice())
692  }
693  /// Optional: Any complementary info that may be useful to the recipient.
694  ///
695  /// Example: human-readable names.
696  /// Example: custom variable typing information (`is_bit`, ...).
697  /// Example: a Merkle authentication path in some custom format.
698  #[inline]
699  pub fn info(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
700    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>>>(Variables::VT_INFO, None)
701  }
702}
703
704pub struct VariablesArgs<'a> {
705    pub variable_ids: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a ,  u64>>>,
706    pub values: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a ,  u8>>>,
707    pub info: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a , flatbuffers::ForwardsUOffset<KeyValue<'a >>>>>,
708}
709impl<'a> Default for VariablesArgs<'a> {
710    #[inline]
711    fn default() -> Self {
712        VariablesArgs {
713            variable_ids: None,
714            values: None,
715            info: None,
716        }
717    }
718}
719pub struct VariablesBuilder<'a: 'b, 'b> {
720  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
721  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
722}
723impl<'a: 'b, 'b> VariablesBuilder<'a, 'b> {
724  #[inline]
725  pub fn add_variable_ids(&mut self, variable_ids: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u64>>) {
726    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Variables::VT_VARIABLE_IDS, variable_ids);
727  }
728  #[inline]
729  pub fn add_values(&mut self, values: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
730    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Variables::VT_VALUES, values);
731  }
732  #[inline]
733  pub fn add_info(&mut self, info: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<KeyValue<'b >>>>) {
734    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Variables::VT_INFO, info);
735  }
736  #[inline]
737  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> VariablesBuilder<'a, 'b> {
738    let start = _fbb.start_table();
739    VariablesBuilder {
740      fbb_: _fbb,
741      start_: start,
742    }
743  }
744  #[inline]
745  pub fn finish(self) -> flatbuffers::WIPOffset<Variables<'a>> {
746    let o = self.fbb_.end_table(self.start_);
747    flatbuffers::WIPOffset::new(o.value())
748  }
749}
750
751pub enum KeyValueOffset {}
752#[derive(Copy, Clone, Debug, PartialEq)]
753
754/// Generic key-value for custom attributes.
755/// The key must be a string.
756/// The value can be one of several types.
757pub struct KeyValue<'a> {
758  pub _tab: flatbuffers::Table<'a>,
759}
760
761impl<'a> flatbuffers::Follow<'a> for KeyValue<'a> {
762    type Inner = KeyValue<'a>;
763    #[inline]
764    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
765        Self {
766            _tab: flatbuffers::Table { buf: buf, loc: loc },
767        }
768    }
769}
770
771impl<'a> KeyValue<'a> {
772    #[inline]
773    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
774        KeyValue {
775            _tab: table,
776        }
777    }
778    #[allow(unused_mut)]
779    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
780        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
781        args: &'args KeyValueArgs<'args>) -> flatbuffers::WIPOffset<KeyValue<'bldr>> {
782      let mut builder = KeyValueBuilder::new(_fbb);
783      builder.add_number(args.number);
784      if let Some(x) = args.text { builder.add_text(x); }
785      if let Some(x) = args.data { builder.add_data(x); }
786      if let Some(x) = args.key { builder.add_key(x); }
787      builder.finish()
788    }
789
790    pub const VT_KEY: flatbuffers::VOffsetT = 4;
791    pub const VT_DATA: flatbuffers::VOffsetT = 6;
792    pub const VT_TEXT: flatbuffers::VOffsetT = 8;
793    pub const VT_NUMBER: flatbuffers::VOffsetT = 10;
794
795  #[inline]
796  pub fn key(&self) -> Option<&'a str> {
797    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(KeyValue::VT_KEY, None)
798  }
799  #[inline]
800  pub fn data(&self) -> Option<&'a [u8]> {
801    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(KeyValue::VT_DATA, None).map(|v| v.safe_slice())
802  }
803  #[inline]
804  pub fn text(&self) -> Option<&'a str> {
805    self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(KeyValue::VT_TEXT, None)
806  }
807  #[inline]
808  pub fn number(&self) -> i64 {
809    self._tab.get::<i64>(KeyValue::VT_NUMBER, Some(0)).unwrap()
810  }
811}
812
813pub struct KeyValueArgs<'a> {
814    pub key: Option<flatbuffers::WIPOffset<&'a  str>>,
815    pub data: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a ,  u8>>>,
816    pub text: Option<flatbuffers::WIPOffset<&'a  str>>,
817    pub number: i64,
818}
819impl<'a> Default for KeyValueArgs<'a> {
820    #[inline]
821    fn default() -> Self {
822        KeyValueArgs {
823            key: None,
824            data: None,
825            text: None,
826            number: 0,
827        }
828    }
829}
830pub struct KeyValueBuilder<'a: 'b, 'b> {
831  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
832  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
833}
834impl<'a: 'b, 'b> KeyValueBuilder<'a, 'b> {
835  #[inline]
836  pub fn add_key(&mut self, key: flatbuffers::WIPOffset<&'b  str>) {
837    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(KeyValue::VT_KEY, key);
838  }
839  #[inline]
840  pub fn add_data(&mut self, data: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
841    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(KeyValue::VT_DATA, data);
842  }
843  #[inline]
844  pub fn add_text(&mut self, text: flatbuffers::WIPOffset<&'b  str>) {
845    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(KeyValue::VT_TEXT, text);
846  }
847  #[inline]
848  pub fn add_number(&mut self, number: i64) {
849    self.fbb_.push_slot::<i64>(KeyValue::VT_NUMBER, number, 0);
850  }
851  #[inline]
852  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> KeyValueBuilder<'a, 'b> {
853    let start = _fbb.start_table();
854    KeyValueBuilder {
855      fbb_: _fbb,
856      start_: start,
857    }
858  }
859  #[inline]
860  pub fn finish(self) -> flatbuffers::WIPOffset<KeyValue<'a>> {
861    let o = self.fbb_.end_table(self.start_);
862    flatbuffers::WIPOffset::new(o.value())
863  }
864}
865
866pub enum RootOffset {}
867#[derive(Copy, Clone, Debug, PartialEq)]
868
869pub struct Root<'a> {
870  pub _tab: flatbuffers::Table<'a>,
871}
872
873impl<'a> flatbuffers::Follow<'a> for Root<'a> {
874    type Inner = Root<'a>;
875    #[inline]
876    fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
877        Self {
878            _tab: flatbuffers::Table { buf: buf, loc: loc },
879        }
880    }
881}
882
883impl<'a> Root<'a> {
884    #[inline]
885    pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
886        Root {
887            _tab: table,
888        }
889    }
890    #[allow(unused_mut)]
891    pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
892        _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
893        args: &'args RootArgs) -> flatbuffers::WIPOffset<Root<'bldr>> {
894      let mut builder = RootBuilder::new(_fbb);
895      if let Some(x) = args.message { builder.add_message(x); }
896      builder.add_message_type(args.message_type);
897      builder.finish()
898    }
899
900    pub const VT_MESSAGE_TYPE: flatbuffers::VOffsetT = 4;
901    pub const VT_MESSAGE: flatbuffers::VOffsetT = 6;
902
903  #[inline]
904  pub fn message_type(&self) -> Message {
905    self._tab.get::<Message>(Root::VT_MESSAGE_TYPE, Some(Message::NONE)).unwrap()
906  }
907  #[inline]
908  pub fn message(&self) -> Option<flatbuffers::Table<'a>> {
909    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Root::VT_MESSAGE, None)
910  }
911  #[inline]
912  #[allow(non_snake_case)]
913  pub fn message_as_circuit_header(&self) -> Option<CircuitHeader<'a>> {
914    if self.message_type() == Message::CircuitHeader {
915      self.message().map(|u| CircuitHeader::init_from_table(u))
916    } else {
917      None
918    }
919  }
920
921  #[inline]
922  #[allow(non_snake_case)]
923  pub fn message_as_constraint_system(&self) -> Option<ConstraintSystem<'a>> {
924    if self.message_type() == Message::ConstraintSystem {
925      self.message().map(|u| ConstraintSystem::init_from_table(u))
926    } else {
927      None
928    }
929  }
930
931  #[inline]
932  #[allow(non_snake_case)]
933  pub fn message_as_witness(&self) -> Option<Witness<'a>> {
934    if self.message_type() == Message::Witness {
935      self.message().map(|u| Witness::init_from_table(u))
936    } else {
937      None
938    }
939  }
940
941  #[inline]
942  #[allow(non_snake_case)]
943  pub fn message_as_command(&self) -> Option<Command<'a>> {
944    if self.message_type() == Message::Command {
945      self.message().map(|u| Command::init_from_table(u))
946    } else {
947      None
948    }
949  }
950
951}
952
953pub struct RootArgs {
954    pub message_type: Message,
955    pub message: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
956}
957impl<'a> Default for RootArgs {
958    #[inline]
959    fn default() -> Self {
960        RootArgs {
961            message_type: Message::NONE,
962            message: None,
963        }
964    }
965}
966pub struct RootBuilder<'a: 'b, 'b> {
967  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
968  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
969}
970impl<'a: 'b, 'b> RootBuilder<'a, 'b> {
971  #[inline]
972  pub fn add_message_type(&mut self, message_type: Message) {
973    self.fbb_.push_slot::<Message>(Root::VT_MESSAGE_TYPE, message_type, Message::NONE);
974  }
975  #[inline]
976  pub fn add_message(&mut self, message: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
977    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Root::VT_MESSAGE, message);
978  }
979  #[inline]
980  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> RootBuilder<'a, 'b> {
981    let start = _fbb.start_table();
982    RootBuilder {
983      fbb_: _fbb,
984      start_: start,
985    }
986  }
987  #[inline]
988  pub fn finish(self) -> flatbuffers::WIPOffset<Root<'a>> {
989    let o = self.fbb_.end_table(self.start_);
990    flatbuffers::WIPOffset::new(o.value())
991  }
992}
993
994#[inline]
995pub fn get_root_as_root<'a>(buf: &'a [u8]) -> Root<'a> {
996  flatbuffers::get_root::<Root<'a>>(buf)
997}
998
999#[inline]
1000pub fn get_size_prefixed_root_as_root<'a>(buf: &'a [u8]) -> Root<'a> {
1001  flatbuffers::get_size_prefixed_root::<Root<'a>>(buf)
1002}
1003
1004pub const ROOT_IDENTIFIER: &'static str = "zkif";
1005
1006#[inline]
1007pub fn root_buffer_has_identifier(buf: &[u8]) -> bool {
1008  return flatbuffers::buffer_has_identifier(buf, ROOT_IDENTIFIER, false);
1009}
1010
1011#[inline]
1012pub fn root_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool {
1013  return flatbuffers::buffer_has_identifier(buf, ROOT_IDENTIFIER, true);
1014}
1015
1016pub const ROOT_EXTENSION: &'static str = "zkif";
1017
1018#[inline]
1019pub fn finish_root_buffer<'a, 'b>(
1020    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
1021    root: flatbuffers::WIPOffset<Root<'a>>) {
1022  fbb.finish(root, Some(ROOT_IDENTIFIER));
1023}
1024
1025#[inline]
1026pub fn finish_size_prefixed_root_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Root<'a>>) {
1027  fbb.finish_size_prefixed(root, Some(ROOT_IDENTIFIER));
1028}
1029}  // pub mod zkinterface
1030