You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

683 lines
33 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. # Binary format for R1CS
  2. ---
  3. eip:
  4. title: r1cs binary format
  5. author: Jordi Baylina <jordi@baylina.cat>
  6. discussions-to:
  7. status: draft
  8. type: Standards Track
  9. category: ERC
  10. created: 2019-09-24
  11. requires:
  12. ---
  13. ## Simple Summary
  14. This standard defines a standard format for a binery representation of a r1cs constraint system.
  15. ## Abstract
  16. ## Motivation
  17. The zero knowledge primitives, requires the definition of a statment that wants to be proved. This statment can be expressed as a deterministric program or an algebraic circuit. Lots of primitives like zkSnarks, bulletProofs or aurora, requires to convert this statment to a rank-one constraint system.
  18. This standard specifies a format for a r1cs and allows the to connect a set of tools that compiles a program or a circuit to r1cs that can be used for the zksnarks or bulletproofs primitives.
  19. ## Specification
  20. ### General considerations
  21. The standard extension is `.r1cs`
  22. A deterministic program (or circuit) is a program that generates a set of deterministic values given an input. All those values are labeled from l_{0} to l_{n_labels}
  23. This file defines a map beween l_{i} -> w_{j} and defines a series a R1CS of the form
  24. $$
  25. \left\{ \begin{array}{rclclcl}
  26. (a_{0,0}w_0 + a_{0,1}w_1 + ... + a_{0,n}w_{n}) &\cdot& (b_{0,0} w_0 + b_{0,1} w_1 + ... + b_{0,n} w_{n}) &-& (c_{0,0} w_0 + c_{0,1} w_1 + ... + c_{0,n}w_{n}) &=& 0 \\
  27. (a_{1,0}w_0 + a_{1,1}w_1 + ... + a_{1,n}w_{n}) &\cdot& (b_{1,0} w_0 + b_{1,1} w_1 + ... + b_{1,n} w_{n}) &-& (c_{1,0} w_0 + c_{1,1}w_1 + ... + c_{1,n}w_{n}) &=& 0 \\
  28. ...\\
  29. (a_{m-1,0}w_0 + a_{m-1,1}w_1 + ... + a_{m-1,n}w_{n}) &\cdot& (b_{m-1,0} w_0 + b_{m-1,1} w_1 + ... + b_{m-1,n} w_{n}) &-& (c_{m-1,0} w_0 + c_{m-1,1}w_1 + ... + c_{m-1,n}w_{n}) &=& 0
  30. \end{array} \right.
  31. $$
  32. Wire 0 must be always mapped to label 0 and it's an input forced to value "1" implicitly
  33. ### Format of the file
  34. ````
  35. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  36. โ”ƒ 4 โ”‚ 72 31 63 73 โ”ƒ Magic "r1cs"
  37. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  38. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  39. โ”ƒ 4 โ”‚ 01 00 00 00 โ”ƒ Version 1
  40. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  41. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  42. โ”ƒ 4 โ”‚ 03 00 00 00 โ”ƒ Number of Sections
  43. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  44. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  45. โ”ƒ 4 โ”‚ sectionType โ”ƒ 8 โ”‚ SectionSize โ”ƒ
  46. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  47. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  48. โ”ƒ โ”ƒ
  49. โ”ƒ โ”ƒ
  50. โ”ƒ โ”ƒ
  51. โ”ƒ Section Content โ”ƒ
  52. โ”ƒ โ”ƒ
  53. โ”ƒ โ”ƒ
  54. โ”ƒ โ”ƒ
  55. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  56. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  57. โ”ƒ 4 โ”‚ sectionType โ”ƒ 8 โ”‚ SectionSize โ”ƒ
  58. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  59. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  60. โ”ƒ โ”ƒ
  61. โ”ƒ โ”ƒ
  62. โ”ƒ โ”ƒ
  63. โ”ƒ Section Content โ”ƒ
  64. โ”ƒ โ”ƒ
  65. โ”ƒ โ”ƒ
  66. โ”ƒ โ”ƒ
  67. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  68. ...
  69. ...
  70. ...
  71. ````
  72. #### Magic Number
  73. Size: 4 bytes
  74. The file start with a constant 4 bytes (magic number) "r1cs"
  75. ```
  76. 0x72 0x31 0x63 0x73
  77. ```
  78. #### Version
  79. Size: 4 bytes
  80. Format: Little-Endian
  81. For this standard it's fixed to
  82. ```
  83. 0x01 0x00 0x00 0x00
  84. ```
  85. #### Number of Sections
  86. Size: 4 bytes
  87. Format: Little-Endian
  88. Number of sections contained in the file
  89. #### SectionType
  90. Size: 4 bytes
  91. Format: Little-Endian
  92. Type of the section.
  93. Currently there are 3 types of sections defined:
  94. * 0x00000001 : Header Section
  95. * 0x00000002 : Constraint Section
  96. * 0x00000003 : Wire2LabelId Map Section
  97. If the file contain other types, the format is valid, but they MUST be ignored.
  98. Any order of the section must be accepted.
  99. Example:
  100. ```
  101. 0x01 0x00 0x00 0x00
  102. ```
  103. #### SectionSize
  104. Size: `ws` bytes
  105. Format: Little-Endian
  106. Size in bytes of the section
  107. ### Header Section
  108. Section Type: 0x01
  109. ````
  110. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  111. โ”ƒ 4 โ”‚ FieldDefSize โ”ƒ 4 โ”ƒFieldDef โ”ƒ field Id โ”ƒ
  112. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  113. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  114. โ”ƒ 4 โ”‚ 00 00 00 00 โ”ƒ bigInt Format
  115. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  116. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  117. โ”ƒ 4 โ”‚ is โ”ƒ Id size ( Normally 4 (32bits))
  118. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  119. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  120. โ”ƒ is โ”‚ 01 00 00 00 โ”ƒ nWires
  121. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  122. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  123. โ”ƒ is โ”‚ 01 00 00 00 โ”ƒ nPubOut
  124. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  125. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  126. โ”ƒ is โ”‚ 01 00 00 00 โ”ƒ nPubIn
  127. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  128. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  129. โ”ƒ is โ”‚ 01 00 00 00 โ”ƒ nPrvIn
  130. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  131. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  132. โ”ƒ is โ”‚ 01 00 00 00 โ”ƒ nLabels
  133. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  134. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  135. โ”ƒ is โ”‚ 01 00 00 00 โ”ƒ mConstraints
  136. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  137. ````
  138. #### fieldDefSize
  139. Size: 4 bytes
  140. Format: Little-Endian
  141. Size of the field Definition
  142. Example:
  143. ```
  144. 0x00 0x0 0x00 0x00
  145. ```
  146. #### fieldDef
  147. Field dfinition the first 4 bytes are the type in LE. 0x0000001 Ar prime fields.
  148. For the prime fields, the next bytes are the prime in variable length LE base 256 format.
  149. NOTE: This number is independent of the bigInt Format defined next
  150. #### bigInt Format
  151. Size: 4 bytes
  152. Format: Little-Endian
  153. 0 Means that the Big Int are variable size LE.
  154. That is the First byte indicates the size and the remaining bytes are the number in little enfian (LSB first) base 256.
  155. Numbers from 1 to 16383 are fixed size Litle endian format base 256.
  156. Example:
  157. ```
  158. 0x00 0x00 0x00 0x00
  159. ```
  160. #### Id Size (is)
  161. Size: 4 bytes
  162. Format: Little-Endian
  163. Size of the identifiers for wires, labels and constraints. In small circuits this is going to be 4 (32 bits)
  164. but can be increaset to 8 for bigger circiuits.
  165. The only possible numbers are 4 or 8
  166. #### Number of wires
  167. Size: `is` bytes
  168. Format: Little-Endian
  169. Total Number of wires including ONE signal (Index 0).
  170. #### Number of public outputs
  171. Size: `is` bytes
  172. Format: Little-Endian
  173. Total Number of wires public output wires. They should be starting at idx 1
  174. #### Number of public inputs
  175. Size: `is` bytes
  176. Format: Little-Endian
  177. Total Number of wires public input wires. They should be starting just after the public output
  178. #### Number of private inputs
  179. Size: `is` bytes
  180. Format: Little-Endian
  181. Total Number of wires private input wires. They should be starting just after the public inputs
  182. #### Number of constraints (m)
  183. Size: `รฌs` bytes
  184. Format: Little-Endian
  185. Total Number of constraints
  186. ### Constraints section
  187. Section Type: 0x02
  188. ````
  189. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ•ฒ
  190. โ”ƒ is โ”‚ nA โ”ƒ โ•ฒ
  191. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ•ฒ
  192. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ a_{0,wireId_1} โ”ƒ โ”‚
  193. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚
  194. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ a_{0,wireId_2} โ”ƒ โ”‚
  195. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  196. ... ... โ”‚
  197. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  198. โ”ƒ is โ”‚ wireId_nA โ”ƒ V โ”‚ a_{0,wireId_nA} โ”ƒ โ”‚
  199. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  200. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  201. โ”ƒ is โ”‚ nB โ”ƒ โ”‚
  202. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  203. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ b_{0,wireId_1} โ”ƒ โ”‚
  204. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ•ฒ
  205. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ b_{0,wireId_2} โ”ƒ โ•ฒ
  206. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ•ฑ Constraint_0
  207. ... ... โ•ฑ
  208. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  209. โ”ƒ is โ”‚ wireId_nB โ”ƒ V โ”‚ b_{0,wireId_nB} โ”ƒ โ”‚
  210. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  211. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  212. โ”ƒ is โ”‚ nC โ”ƒ โ”‚
  213. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  214. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ c_{0,wireId_1} โ”ƒ โ”‚
  215. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚
  216. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ c_{0,wireId_2} โ”ƒ โ”‚
  217. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  218. ... ... โ”‚
  219. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  220. โ”ƒ is โ”‚ wireId_nC โ”ƒ V โ”‚ c_{0,wireId_nC} โ”ƒ โ•ฑ
  221. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ•ฑ
  222. โ•ฑ
  223. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ•ฒ
  224. โ”ƒ is โ”‚ nA โ”ƒ โ•ฒ
  225. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ•ฒ
  226. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ a_{1,wireId_1} โ”ƒ โ”‚
  227. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚
  228. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ a_{1,wireId_2} โ”ƒ โ”‚
  229. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  230. ... ... โ”‚
  231. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  232. โ”ƒ is โ”‚ wireId_nA โ”ƒ V โ”‚ a_{1,wireId_nA} โ”ƒ โ”‚
  233. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  234. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  235. โ”ƒ is โ”‚ nB โ”ƒ โ”‚
  236. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  237. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ b_{1,wireId_1} โ”ƒ โ”‚
  238. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ•ฒ
  239. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ b_{1,wireId_2} โ”ƒ โ•ฒ
  240. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ•ฑ Constraint_1
  241. ... ... โ•ฑ
  242. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  243. โ”ƒ is โ”‚ wireId_nB โ”ƒ V โ”‚ b_{1,wireId_nB} โ”ƒ โ”‚
  244. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  245. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  246. โ”ƒ is โ”‚ nC โ”ƒ โ”‚
  247. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  248. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ c_{1,wireId_1} โ”ƒ โ”‚
  249. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚
  250. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ c_{1,wireId_2} โ”ƒ โ”‚
  251. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  252. ... ... โ”‚
  253. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  254. โ”ƒ is โ”‚ wireId_nC โ”ƒ V โ”‚ c_{1,wireId_nC} โ”ƒ โ•ฑ
  255. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ•ฑ
  256. โ•ฑ
  257. ...
  258. ...
  259. ...
  260. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ•ฒ
  261. โ”ƒ is โ”‚ nA โ”ƒ โ•ฒ
  262. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ•ฒ
  263. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ a_{m-1,wireId_1} โ”ƒ โ”‚
  264. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚
  265. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ a_{m-1,wireId_2} โ”ƒ โ”‚
  266. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  267. ... ... โ”‚
  268. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  269. โ”ƒ is โ”‚ wireId_nA โ”ƒ V โ”‚ a_{m-1,wireId_nA} โ”ƒ โ”‚
  270. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  271. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  272. โ”ƒ is โ”‚ nB โ”ƒ โ”‚
  273. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  274. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ b_{m-1,wireId_1} โ”ƒ โ”‚
  275. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ•ฒ
  276. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ b_{m-1,wireId_2} โ”ƒ โ•ฒ
  277. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ•ฑ Constraint_{m-1}
  278. ... ... โ•ฑ
  279. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  280. โ”ƒ is โ”‚ wireId_nB โ”ƒ V โ”‚ b_{m-1,wireId_nB} โ”ƒ โ”‚
  281. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  282. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  283. โ”ƒ is โ”‚ nC โ”ƒ โ”‚
  284. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  285. โ”ƒ is โ”‚ wireId_1 โ”ƒ V โ”‚ c_{m-1,wireId_1} โ”ƒ โ”‚
  286. โ”ฃโ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ โ”‚
  287. โ”ƒ is โ”‚ wireId_2 โ”ƒ V โ”‚ c_{m-1,wireId_2} โ”ƒ โ”‚
  288. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”‚
  289. ... ... โ”‚
  290. โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”‚
  291. โ”ƒ is โ”‚ wireId_nC โ”ƒ V โ”‚ c_{m-1,wireId_nC} โ”ƒ โ•ฑ
  292. โ”—โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ•ฑ
  293. โ•ฑ โ•ฑ
  294. ````
  295. #### Constraints
  296. Each constraint contains 3 linear combinations A, B, C.
  297. The constraint is such that:
  298. ```
  299. A*B-C = 0
  300. ```
  301. #### Linear combination
  302. Each linear combination is of the form:
  303. $$
  304. a_{j,0}w_0 + a_{j,1}w_1 + ... + a_{j,n}w_{n}
  305. $$
  306. #### Number of nonZero Factors
  307. Size: `รฌs` bytes
  308. Format: Little-Endian
  309. Total number of non Zero factors in the linear compination.
  310. The factors MUST be sorted in ascending order.
  311. #### Factor
  312. For each factor we have the index of the factor and the value of the factor.
  313. #### WireId of the factor
  314. Size: `is` bytes
  315. Format: Little-Endian
  316. WireId of the nonZero Factor
  317. #### Value of the factor
  318. The first byte indicate the length N in bytes of the number in the upcoming bytes.
  319. The next N bytes represent the value in Little Endian format.
  320. For example, to represent the linear combination:
  321. $$
  322. 5w_4 +8w_5 + 260w_{886}
  323. $$
  324. The linear combination would be represented as:
  325. ````
  326. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  327. โ”ƒ 03 00 00 00 โ”ƒ
  328. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  329. โ”ƒ 04 00 00 00 โ”ƒ 01 05 โ”ƒ
  330. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  331. โ”ƒ 05 00 00 00 โ”ƒ 01 08 โ”ƒ
  332. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  333. โ”ƒ 76 03 00 00 โ”ƒ 02 04 01 โ”ƒ
  334. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  335. ````
  336. ### WireId2LabelId Map Section
  337. Section Type: 0x03
  338. ````
  339. โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  340. โ”ƒisโ”‚ labelId of Wire_0 โ”ƒisโ”‚ labelId of Wire_1 โ”ƒ ... โ”ƒisโ”‚ labelId of Wire_n โ”ƒ
  341. โ”—โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”› โ”—โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  342. ````
  343. ## Rationale
  344. Variable size for field elements allows to shrink the size of the file and allows to work with any field.
  345. Version allows to update the format.
  346. Have a very good comprasion ratio for sparse r1cs as it's the normal case.
  347. The motivation of having a map between l and w is that this allows optimizers to calculate equivalent r1cs systems but keeping the original values geneated by the circuit.
  348. ## Backward Compatibility
  349. N.A.
  350. ## Test Cases
  351. ### Example
  352. Given this r1cs in a 256 bit Field:
  353. $$
  354. \left\{ \begin{array}{rclclcl}
  355. (3w_5 + 8w_6) &\cdot& (2w_0 + 20w_2 + 12w_3) &-& (5w_0 + 7w_2) &=& 0 \\
  356. (4w_1 + 8w_4 + 3w_5) &\cdot& (6w_6 + 44w_3) && &=& 0 \\
  357. (4w_6) &\cdot& (6w_0 + 5w_3 + 11s_2) &-& (600w_6) &=& 0
  358. \end{array} \right.
  359. $$
  360. And a Wire to label map.
  361. $$
  362. w_0 := l_0 \\
  363. w_1 := l_3 \\
  364. w_2 := l_{10} \\
  365. w_3 := l_{11} \\
  366. w_4 := l_{12} \\
  367. w_5 := l_{15} \\
  368. w_6 := l_{324} \\
  369. $$
  370. The format will be:
  371. ````
  372. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  373. โ”ƒ 72 31 63 73 โ”ƒ Magic
  374. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  375. โ”ƒ 01 00 00 00 โ”ƒ Version
  376. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  377. โ”ƒ 03 00 00 00 โ”ƒ nSections
  378. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  379. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  380. โ”ƒ 01 00 00 00 โ”ƒ 49 00 00 00 โ”ƒ SectionType: Header
  381. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  382. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  383. โ”ƒ 25 00 00 00 โ”ƒ 10 00 00 00 โ”ƒ FieldDefSize FieldDef
  384. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  385. โ”ƒ 20 010000f0 93f5e143 9170b979 48e83328 5d588181 b64550b8 29a031e1 724e6430โ”ƒ
  386. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  387. โ”ƒ 00 00 00 00 โ”ƒ Big Int format
  388. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  389. โ”ƒ 04 00 00 00 โ”ƒ Id Size
  390. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  391. โ”ƒ 07 00 00 00 โ”ƒ # of wires
  392. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  393. โ”ƒ 01 00 00 00 โ”ƒ # Public Outs
  394. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  395. โ”ƒ 02 00 00 00 โ”ƒ # Public Ins
  396. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  397. โ”ƒ 03 00 00 00 โ”ƒ # Private Ins
  398. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  399. โ”ƒ e8 03 00 00 โ”ƒ # Labels
  400. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  401. โ”ƒ 03 00 00 00 โ”ƒ # Constraints
  402. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  403. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  404. โ”ƒ 02 00 00 00 โ”ƒ 8b 00 00 00 โ”ƒ SectionType: Constraints
  405. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  406. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ Constraint 0: (3w_5 + 8w_6) * (2w_0 + 20w_2 + 12w_3) - (5w_0 + 7w_2) = 0
  407. โ”ƒ 02 00 00 00 โ”ƒ
  408. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  409. โ”ƒ 05 00 00 00 โ”ƒ 01 03 โ”ƒ
  410. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  411. โ”ƒ 06 00 00 00 โ”ƒ 01 08 โ”ƒ
  412. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”›
  413. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  414. โ”ƒ 03 00 00 00 โ”ƒ
  415. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  416. โ”ƒ 00 00 00 00 โ”ƒ 01 02 โ”ƒ
  417. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  418. โ”ƒ 02 00 00 00 โ”ƒ 01 14 โ”ƒ
  419. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  420. โ”ƒ 03 00 00 00 โ”ƒ 01 0C โ”ƒ
  421. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”›
  422. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  423. โ”ƒ 02 00 00 00 โ”ƒ
  424. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  425. โ”ƒ 00 00 00 00 โ”ƒ 01 05 โ”ƒ
  426. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  427. โ”ƒ 02 00 00 00 โ”ƒ 01 07 โ”ƒ
  428. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”›
  429. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ Constraint 1: (4w_1 + 8w_4 + 3w_5) * (6w_6 + 44w_3) = 0
  430. โ”ƒ 03 00 00 00 โ”ƒ
  431. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  432. โ”ƒ 01 00 00 00 โ”ƒ 01 04 โ”ƒ
  433. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  434. โ”ƒ 04 00 00 00 โ”ƒ 01 08 โ”ƒ
  435. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  436. โ”ƒ 05 00 00 00 โ”ƒ 01 03 โ”ƒ
  437. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  438. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  439. โ”ƒ 02 00 00 00 โ”ƒ
  440. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  441. โ”ƒ 03 00 00 00 โ”ƒ 01 2C โ”ƒ
  442. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  443. โ”ƒ 06 00 00 00 โ”ƒ 01 06 โ”ƒ
  444. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  445. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  446. โ”ƒ 00 00 00 00 โ”ƒ
  447. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  448. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ Constraint 2: (4w_6) * (6w_0 + 5w_3 + 11w_2) - (600w_6) = 0
  449. โ”ƒ 01 00 00 00 โ”ƒ
  450. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  451. โ”ƒ 06 00 00 00 โ”ƒ 01 04 โ”ƒ
  452. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  453. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  454. โ”ƒ 03 00 00 00 โ”ƒ
  455. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  456. โ”ƒ 00 00 00 00 โ”ƒ 01 06 โ”ƒ
  457. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  458. โ”ƒ 02 00 00 00 โ”ƒ 01 0B โ”ƒ
  459. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  460. โ”ƒ 03 00 00 00 โ”ƒ 01 05 โ”ƒ
  461. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  462. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  463. โ”ƒ 01 00 00 00 โ”ƒ
  464. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‹โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  465. โ”ƒ 06 00 00 00 โ”ƒ 02 58 02 โ”ƒ
  466. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  467. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  468. โ”ƒ 03 00 00 00 โ”ƒ 1c 00 00 00 โ”ƒ Wire to Label Map
  469. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ปโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  470. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
  471. โ”ƒ 00 00 00 00 โ”ƒ
  472. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  473. โ”ƒ 03 00 00 00 โ”ƒ
  474. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  475. โ”ƒ 0a 00 00 00 โ”ƒ
  476. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  477. โ”ƒ 0b 00 00 00 โ”ƒ
  478. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  479. โ”ƒ 0c 00 00 00 โ”ƒ
  480. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  481. โ”ƒ 0f 00 00 00 โ”ƒ
  482. โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
  483. โ”ƒ 44 01 00 00 โ”ƒ
  484. โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›
  485. ````
  486. And the binary representation in Hex:
  487. ````
  488. 72 31 63 77
  489. 01 00 00 00
  490. 03 00 00 00
  491. 01 00 00 00 49 00 00 00
  492. 25 00 00 00 10 00 00 00
  493. 20 010000f0 93f5e143 9170b979 48e83328 5d588181 b64550b8 29a031e1 724e6430
  494. 00 00 00 00
  495. 04 00 00 00
  496. 07 00 00 00
  497. 01 00 00 00
  498. 02 00 00 00
  499. 03 00 00 00
  500. e8 03 00 00
  501. 03 00 00 00
  502. 02 00 00 00 8b 00 00 00
  503. 02 00 00 00
  504. 05 00 00 00 01 03
  505. 06 00 00 00 01 08
  506. 03 00 00 00
  507. 00 00 00 00 01 02
  508. 02 00 00 00 01 14
  509. 03 00 00 00 01 0C
  510. 02 00 00 00
  511. 00 00 00 00 01 05
  512. 02 00 00 00 01 07
  513. 03 00 00 00
  514. 01 00 00 00 01 04
  515. 04 00 00 00 01 08
  516. 05 00 00 00 01 03
  517. 02 00 00 00
  518. 03 00 00 00 01 2C
  519. 06 00 00 00 01 06
  520. 00 00 00 00
  521. 01 00 00 00
  522. 06 00 00 00 01 04
  523. 03 00 00 00
  524. 00 00 00 00 01 06
  525. 02 00 00 00 01 0B
  526. 03 00 00 00 01 05
  527. 01 00 00 00
  528. 06 00 00 00 02 58 02
  529. 03 00 00 00 1c 00 00 00
  530. 00 00 00 00
  531. 03 00 00 00
  532. 0a 00 00 00
  533. 0b 00 00 00
  534. 0c 00 00 00
  535. 0f 00 00 00
  536. 44 01 00 00
  537. ````
  538. ## Implementation
  539. circom will output this format.
  540. ## Copyright
  541. Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).