@aztec/bb.js 3.0.0-canary.a9708bd → 3.0.0-manual.20251030

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +13 -79
  2. package/dest/browser/barretenberg/backend.d.ts +2 -2
  3. package/dest/browser/barretenberg/backend.d.ts.map +1 -1
  4. package/dest/browser/barretenberg/backend.js +40 -25
  5. package/dest/browser/barretenberg/index.d.ts +45 -44
  6. package/dest/browser/barretenberg/index.d.ts.map +1 -1
  7. package/dest/browser/barretenberg/index.js +131 -80
  8. package/dest/browser/barretenberg_wasm/barretenberg_wasm_base/index.d.ts +1 -1
  9. package/dest/browser/barretenberg_wasm/barretenberg_wasm_base/index.d.ts.map +1 -1
  10. package/dest/browser/barretenberg_wasm/barretenberg_wasm_base/index.js +2 -2
  11. package/dest/browser/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts +4 -4
  12. package/dest/browser/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts.map +1 -1
  13. package/dest/browser/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.js +18 -10
  14. package/dest/browser/barretenberg_wasm/barretenberg_wasm_main/index.d.ts +3 -0
  15. package/dest/browser/barretenberg_wasm/barretenberg_wasm_main/index.d.ts.map +1 -1
  16. package/dest/browser/barretenberg_wasm/barretenberg_wasm_main/index.js +55 -14
  17. package/dest/browser/barretenberg_wasm/fetch_code/browser/barretenberg-threads.js +1 -1
  18. package/dest/browser/barretenberg_wasm/fetch_code/browser/barretenberg.js +1 -1
  19. package/dest/browser/bb_backends/browser/index.d.ts +11 -0
  20. package/dest/browser/bb_backends/browser/index.d.ts.map +1 -0
  21. package/dest/browser/bb_backends/browser/index.js +39 -0
  22. package/dest/browser/bb_backends/index.d.ts +45 -0
  23. package/dest/browser/bb_backends/index.d.ts.map +1 -0
  24. package/dest/browser/bb_backends/index.js +15 -0
  25. package/dest/browser/bb_backends/interface.d.ts +33 -0
  26. package/dest/browser/bb_backends/interface.d.ts.map +1 -0
  27. package/dest/browser/bb_backends/interface.js +2 -0
  28. package/dest/browser/bb_backends/sync_to_async_adapter.d.ts +15 -0
  29. package/dest/browser/bb_backends/sync_to_async_adapter.d.ts.map +1 -0
  30. package/dest/browser/bb_backends/sync_to_async_adapter.js +20 -0
  31. package/dest/browser/bb_backends/wasm.d.ts +49 -0
  32. package/dest/browser/bb_backends/wasm.d.ts.map +1 -0
  33. package/dest/browser/bb_backends/wasm.js +83 -0
  34. package/dest/browser/bbapi_exception.d.ts +7 -0
  35. package/dest/browser/bbapi_exception.d.ts.map +1 -0
  36. package/dest/browser/bbapi_exception.js +14 -0
  37. package/dest/browser/cbind/generate.js +94 -7
  38. package/dest/browser/cbind/generated/api_types.d.ts +1640 -227
  39. package/dest/browser/cbind/generated/api_types.d.ts.map +1 -1
  40. package/dest/browser/cbind/generated/api_types.js +2366 -478
  41. package/dest/browser/cbind/generated/async.d.ts +52 -13
  42. package/dest/browser/cbind/generated/async.d.ts.map +1 -1
  43. package/dest/browser/cbind/generated/async.js +586 -72
  44. package/dest/browser/cbind/generated/curve_constants.d.ts +45 -0
  45. package/dest/browser/cbind/generated/curve_constants.d.ts.map +1 -0
  46. package/dest/browser/cbind/generated/curve_constants.js +45 -0
  47. package/dest/browser/cbind/generated/sync.d.ts +53 -14
  48. package/dest/browser/cbind/generated/sync.d.ts.map +1 -1
  49. package/dest/browser/cbind/generated/sync.js +548 -72
  50. package/dest/browser/cbind/schema_compiler.d.ts +2 -4
  51. package/dest/browser/cbind/schema_compiler.d.ts.map +1 -1
  52. package/dest/browser/cbind/schema_compiler.js +97 -181
  53. package/dest/browser/index.d.ts +4 -2
  54. package/dest/browser/index.d.ts.map +1 -1
  55. package/dest/browser/index.js +5 -3
  56. package/dest/browser/serialize/index.d.ts +0 -2
  57. package/dest/browser/serialize/index.d.ts.map +1 -1
  58. package/dest/browser/serialize/index.js +1 -3
  59. package/dest/browser/serialize/serialize.d.ts +0 -35
  60. package/dest/browser/serialize/serialize.d.ts.map +1 -1
  61. package/dest/browser/serialize/serialize.js +1 -68
  62. package/dest/browser/types/fields.d.ts +6 -26
  63. package/dest/browser/types/fields.d.ts.map +1 -1
  64. package/dest/browser/types/fields.js +16 -57
  65. package/dest/browser/types/index.d.ts +0 -3
  66. package/dest/browser/types/index.d.ts.map +1 -1
  67. package/dest/browser/types/index.js +1 -4
  68. package/dest/browser/types/point.d.ts +8 -6
  69. package/dest/browser/types/point.d.ts.map +1 -1
  70. package/dest/browser/types/point.js +12 -15
  71. package/dest/node/barretenberg/__snapshots__/pedersen.test.js.snap +2 -2
  72. package/dest/node/barretenberg/__snapshots__/poseidon.test.js.snap +3 -3
  73. package/dest/node/barretenberg/backend.d.ts +2 -2
  74. package/dest/node/barretenberg/backend.d.ts.map +1 -1
  75. package/dest/node/barretenberg/backend.js +40 -25
  76. package/dest/node/barretenberg/blake2s.test.js +21 -18
  77. package/dest/node/barretenberg/index.d.ts +45 -44
  78. package/dest/node/barretenberg/index.d.ts.map +1 -1
  79. package/dest/node/barretenberg/index.js +131 -80
  80. package/dest/node/barretenberg/pedersen.test.js +24 -17
  81. package/dest/node/barretenberg/poseidon.bench.test.d.ts +2 -0
  82. package/dest/node/barretenberg/poseidon.bench.test.d.ts.map +1 -0
  83. package/dest/node/barretenberg/poseidon.bench.test.js +217 -0
  84. package/dest/node/barretenberg/poseidon.test.js +15 -15
  85. package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  86. package/dest/node/barretenberg_wasm/barretenberg_wasm_base/index.d.ts +1 -1
  87. package/dest/node/barretenberg_wasm/barretenberg_wasm_base/index.d.ts.map +1 -1
  88. package/dest/node/barretenberg_wasm/barretenberg_wasm_base/index.js +2 -2
  89. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts +4 -4
  90. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts.map +1 -1
  91. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.js +18 -10
  92. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/index.d.ts +3 -0
  93. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/index.d.ts.map +1 -1
  94. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/index.js +55 -14
  95. package/dest/node/barretenberg_wasm/index.test.js +11 -10
  96. package/dest/node/bb_backends/browser/index.d.ts +11 -0
  97. package/dest/node/bb_backends/browser/index.d.ts.map +1 -0
  98. package/dest/node/bb_backends/browser/index.js +39 -0
  99. package/dest/node/bb_backends/index.d.ts +45 -0
  100. package/dest/node/bb_backends/index.d.ts.map +1 -0
  101. package/dest/node/bb_backends/index.js +15 -0
  102. package/dest/node/bb_backends/interface.d.ts +33 -0
  103. package/dest/node/bb_backends/interface.d.ts.map +1 -0
  104. package/dest/node/bb_backends/interface.js +2 -0
  105. package/dest/node/bb_backends/node/index.d.ts +11 -0
  106. package/dest/node/bb_backends/node/index.d.ts.map +1 -0
  107. package/dest/node/bb_backends/node/index.js +80 -0
  108. package/dest/node/bb_backends/node/native_pipe.d.ts +25 -0
  109. package/dest/node/bb_backends/node/native_pipe.d.ts.map +1 -0
  110. package/dest/node/bb_backends/node/native_pipe.js +113 -0
  111. package/dest/node/bb_backends/node/native_shm.d.ts +28 -0
  112. package/dest/node/bb_backends/node/native_shm.d.ts.map +1 -0
  113. package/dest/node/bb_backends/node/native_shm.js +150 -0
  114. package/dest/node/bb_backends/node/native_socket.d.ts +34 -0
  115. package/dest/node/bb_backends/node/native_socket.d.ts.map +1 -0
  116. package/dest/node/bb_backends/node/native_socket.js +269 -0
  117. package/dest/node/bb_backends/node/platform.d.ts +27 -0
  118. package/dest/node/bb_backends/node/platform.d.ts.map +1 -0
  119. package/dest/node/bb_backends/node/platform.js +124 -0
  120. package/dest/node/bb_backends/sync_to_async_adapter.d.ts +15 -0
  121. package/dest/node/bb_backends/sync_to_async_adapter.d.ts.map +1 -0
  122. package/dest/node/bb_backends/sync_to_async_adapter.js +20 -0
  123. package/dest/node/bb_backends/wasm.d.ts +49 -0
  124. package/dest/node/bb_backends/wasm.d.ts.map +1 -0
  125. package/dest/node/bb_backends/wasm.js +83 -0
  126. package/dest/node/bbapi_exception.d.ts +7 -0
  127. package/dest/node/bbapi_exception.d.ts.map +1 -0
  128. package/dest/node/bbapi_exception.js +14 -0
  129. package/dest/node/cbind/generate.js +94 -7
  130. package/dest/node/cbind/generated/api_types.d.ts +1640 -227
  131. package/dest/node/cbind/generated/api_types.d.ts.map +1 -1
  132. package/dest/node/cbind/generated/api_types.js +2366 -478
  133. package/dest/node/cbind/generated/async.d.ts +52 -13
  134. package/dest/node/cbind/generated/async.d.ts.map +1 -1
  135. package/dest/node/cbind/generated/async.js +586 -72
  136. package/dest/node/cbind/generated/curve_constants.d.ts +45 -0
  137. package/dest/node/cbind/generated/curve_constants.d.ts.map +1 -0
  138. package/dest/node/cbind/generated/curve_constants.js +45 -0
  139. package/dest/node/cbind/generated/sync.d.ts +53 -14
  140. package/dest/node/cbind/generated/sync.d.ts.map +1 -1
  141. package/dest/node/cbind/generated/sync.js +548 -72
  142. package/dest/node/cbind/schema_compiler.d.ts +2 -4
  143. package/dest/node/cbind/schema_compiler.d.ts.map +1 -1
  144. package/dest/node/cbind/schema_compiler.js +97 -181
  145. package/dest/node/index.d.ts +4 -2
  146. package/dest/node/index.d.ts.map +1 -1
  147. package/dest/node/index.js +5 -3
  148. package/dest/node/serialize/index.d.ts +0 -2
  149. package/dest/node/serialize/index.d.ts.map +1 -1
  150. package/dest/node/serialize/index.js +1 -3
  151. package/dest/node/serialize/serialize.d.ts +0 -35
  152. package/dest/node/serialize/serialize.d.ts.map +1 -1
  153. package/dest/node/serialize/serialize.js +1 -68
  154. package/dest/node/types/fields.d.ts +6 -26
  155. package/dest/node/types/fields.d.ts.map +1 -1
  156. package/dest/node/types/fields.js +16 -57
  157. package/dest/node/types/index.d.ts +0 -3
  158. package/dest/node/types/index.d.ts.map +1 -1
  159. package/dest/node/types/index.js +1 -4
  160. package/dest/node/types/point.d.ts +8 -6
  161. package/dest/node/types/point.d.ts.map +1 -1
  162. package/dest/node/types/point.js +12 -15
  163. package/dest/node-cjs/barretenberg/backend.d.ts +2 -2
  164. package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
  165. package/dest/node-cjs/barretenberg/backend.js +38 -23
  166. package/dest/node-cjs/barretenberg/blake2s.test.js +19 -16
  167. package/dest/node-cjs/barretenberg/index.d.ts +45 -44
  168. package/dest/node-cjs/barretenberg/index.d.ts.map +1 -1
  169. package/dest/node-cjs/barretenberg/index.js +137 -85
  170. package/dest/node-cjs/barretenberg/pedersen.test.js +24 -17
  171. package/dest/node-cjs/barretenberg/poseidon.bench.test.d.ts +2 -0
  172. package/dest/node-cjs/barretenberg/poseidon.bench.test.d.ts.map +1 -0
  173. package/dest/node-cjs/barretenberg/poseidon.bench.test.js +219 -0
  174. package/dest/node-cjs/barretenberg/poseidon.test.js +15 -15
  175. package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  176. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_base/index.d.ts +1 -1
  177. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_base/index.d.ts.map +1 -1
  178. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_base/index.js +2 -2
  179. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts +4 -4
  180. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts.map +1 -1
  181. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.js +18 -10
  182. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/index.d.ts +3 -0
  183. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/index.d.ts.map +1 -1
  184. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/index.js +55 -14
  185. package/dest/node-cjs/barretenberg_wasm/index.test.js +11 -10
  186. package/dest/node-cjs/bb_backends/browser/index.d.ts +11 -0
  187. package/dest/node-cjs/bb_backends/browser/index.d.ts.map +1 -0
  188. package/dest/node-cjs/bb_backends/browser/index.js +43 -0
  189. package/dest/node-cjs/bb_backends/index.d.ts +45 -0
  190. package/dest/node-cjs/bb_backends/index.d.ts.map +1 -0
  191. package/dest/node-cjs/bb_backends/index.js +18 -0
  192. package/dest/node-cjs/bb_backends/interface.d.ts +33 -0
  193. package/dest/node-cjs/bb_backends/interface.d.ts.map +1 -0
  194. package/dest/node-cjs/bb_backends/interface.js +3 -0
  195. package/dest/node-cjs/bb_backends/node/index.d.ts +11 -0
  196. package/dest/node-cjs/bb_backends/node/index.d.ts.map +1 -0
  197. package/dest/node-cjs/bb_backends/node/index.js +84 -0
  198. package/dest/node-cjs/bb_backends/node/native_pipe.d.ts +25 -0
  199. package/dest/node-cjs/bb_backends/node/native_pipe.d.ts.map +1 -0
  200. package/dest/node-cjs/bb_backends/node/native_pipe.js +117 -0
  201. package/dest/node-cjs/bb_backends/node/native_shm.d.ts +28 -0
  202. package/dest/node-cjs/bb_backends/node/native_shm.d.ts.map +1 -0
  203. package/dest/node-cjs/bb_backends/node/native_shm.js +154 -0
  204. package/dest/node-cjs/bb_backends/node/native_socket.d.ts +34 -0
  205. package/dest/node-cjs/bb_backends/node/native_socket.d.ts.map +1 -0
  206. package/dest/node-cjs/bb_backends/node/native_socket.js +274 -0
  207. package/dest/node-cjs/bb_backends/node/platform.d.ts +27 -0
  208. package/dest/node-cjs/bb_backends/node/platform.d.ts.map +1 -0
  209. package/dest/node-cjs/bb_backends/node/platform.js +131 -0
  210. package/dest/node-cjs/bb_backends/sync_to_async_adapter.d.ts +15 -0
  211. package/dest/node-cjs/bb_backends/sync_to_async_adapter.d.ts.map +1 -0
  212. package/dest/node-cjs/bb_backends/sync_to_async_adapter.js +24 -0
  213. package/dest/node-cjs/bb_backends/wasm.d.ts +49 -0
  214. package/dest/node-cjs/bb_backends/wasm.d.ts.map +1 -0
  215. package/dest/node-cjs/bb_backends/wasm.js +88 -0
  216. package/dest/node-cjs/bbapi_exception.d.ts +7 -0
  217. package/dest/node-cjs/bbapi_exception.d.ts.map +1 -0
  218. package/dest/node-cjs/bbapi_exception.js +18 -0
  219. package/dest/node-cjs/cbind/generate.js +93 -6
  220. package/dest/node-cjs/cbind/generated/api_types.d.ts +1640 -227
  221. package/dest/node-cjs/cbind/generated/api_types.d.ts.map +1 -1
  222. package/dest/node-cjs/cbind/generated/api_types.js +2572 -516
  223. package/dest/node-cjs/cbind/generated/async.d.ts +52 -13
  224. package/dest/node-cjs/cbind/generated/async.d.ts.map +1 -1
  225. package/dest/node-cjs/cbind/generated/async.js +585 -71
  226. package/dest/node-cjs/cbind/generated/curve_constants.d.ts +45 -0
  227. package/dest/node-cjs/cbind/generated/curve_constants.d.ts.map +1 -0
  228. package/dest/node-cjs/cbind/generated/curve_constants.js +48 -0
  229. package/dest/node-cjs/cbind/generated/sync.d.ts +53 -14
  230. package/dest/node-cjs/cbind/generated/sync.d.ts.map +1 -1
  231. package/dest/node-cjs/cbind/generated/sync.js +547 -71
  232. package/dest/node-cjs/cbind/schema_compiler.d.ts +2 -4
  233. package/dest/node-cjs/cbind/schema_compiler.d.ts.map +1 -1
  234. package/dest/node-cjs/cbind/schema_compiler.js +97 -182
  235. package/dest/node-cjs/index.d.ts +4 -2
  236. package/dest/node-cjs/index.d.ts.map +1 -1
  237. package/dest/node-cjs/index.js +24 -9
  238. package/dest/node-cjs/serialize/index.d.ts +0 -2
  239. package/dest/node-cjs/serialize/index.d.ts.map +1 -1
  240. package/dest/node-cjs/serialize/index.js +1 -3
  241. package/dest/node-cjs/serialize/serialize.d.ts +0 -35
  242. package/dest/node-cjs/serialize/serialize.d.ts.map +1 -1
  243. package/dest/node-cjs/serialize/serialize.js +1 -79
  244. package/dest/node-cjs/types/fields.d.ts +6 -26
  245. package/dest/node-cjs/types/fields.d.ts.map +1 -1
  246. package/dest/node-cjs/types/fields.js +16 -58
  247. package/dest/node-cjs/types/index.d.ts +0 -3
  248. package/dest/node-cjs/types/index.d.ts.map +1 -1
  249. package/dest/node-cjs/types/index.js +1 -4
  250. package/dest/node-cjs/types/point.d.ts +8 -6
  251. package/dest/node-cjs/types/point.d.ts.map +1 -1
  252. package/dest/node-cjs/types/point.js +13 -16
  253. package/package.json +6 -6
  254. package/src/barretenberg/__snapshots__/pedersen.test.ts.snap +2 -2
  255. package/src/barretenberg/__snapshots__/poseidon.test.ts.snap +3 -3
  256. package/src/barretenberg/backend.ts +54 -42
  257. package/src/barretenberg/blake2s.test.ts +20 -21
  258. package/src/barretenberg/index.ts +137 -118
  259. package/src/barretenberg/pedersen.test.ts +23 -16
  260. package/src/barretenberg/poseidon.bench.test.ts +268 -0
  261. package/src/barretenberg/poseidon.test.ts +14 -14
  262. package/src/barretenberg_wasm/barretenberg_wasm_base/index.ts +3 -3
  263. package/src/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.ts +17 -9
  264. package/src/barretenberg_wasm/barretenberg_wasm_main/index.ts +67 -16
  265. package/src/barretenberg_wasm/index.test.ts +12 -11
  266. package/src/bb_backends/browser/index.ts +50 -0
  267. package/src/bb_backends/index.ts +49 -0
  268. package/src/bb_backends/interface.ts +35 -0
  269. package/src/bb_backends/node/index.ts +94 -0
  270. package/src/bb_backends/node/native_pipe.ts +127 -0
  271. package/src/bb_backends/node/native_shm.ts +171 -0
  272. package/src/bb_backends/node/native_socket.ts +312 -0
  273. package/src/bb_backends/node/platform.ts +151 -0
  274. package/src/bb_backends/sync_to_async_adapter.ts +21 -0
  275. package/src/bb_backends/wasm.ts +103 -0
  276. package/src/bbapi_exception.ts +13 -0
  277. package/src/cbind/README.md +1 -1
  278. package/src/cbind/generate.ts +99 -6
  279. package/src/cbind/schema_compiler.ts +156 -244
  280. package/src/index.ts +29 -1
  281. package/src/serialize/index.ts +0 -2
  282. package/src/serialize/serialize.ts +0 -82
  283. package/src/types/fields.ts +15 -64
  284. package/src/types/index.ts +0 -3
  285. package/src/types/point.ts +13 -19
  286. package/dest/browser/barretenberg_api/index.d.ts +0 -109
  287. package/dest/browser/barretenberg_api/index.d.ts.map +0 -1
  288. package/dest/browser/barretenberg_api/index.js +0 -699
  289. package/dest/browser/cbind/generated/native.d.ts +0 -31
  290. package/dest/browser/cbind/generated/native.d.ts.map +0 -1
  291. package/dest/browser/cbind/generated/native.js +0 -234
  292. package/dest/browser/serialize/buffer_reader.d.ts +0 -28
  293. package/dest/browser/serialize/buffer_reader.d.ts.map +0 -1
  294. package/dest/browser/serialize/buffer_reader.js +0 -66
  295. package/dest/browser/serialize/output_type.d.ts +0 -11
  296. package/dest/browser/serialize/output_type.d.ts.map +0 -1
  297. package/dest/browser/serialize/output_type.js +0 -44
  298. package/dest/browser/types/fixed_size_buffer.d.ts +0 -26
  299. package/dest/browser/types/fixed_size_buffer.d.ts.map +0 -1
  300. package/dest/browser/types/fixed_size_buffer.js +0 -51
  301. package/dest/browser/types/ptr.d.ts +0 -13
  302. package/dest/browser/types/ptr.d.ts.map +0 -1
  303. package/dest/browser/types/ptr.js +0 -19
  304. package/dest/browser/types/raw_buffer.d.ts +0 -3
  305. package/dest/browser/types/raw_buffer.d.ts.map +0 -1
  306. package/dest/browser/types/raw_buffer.js +0 -5
  307. package/dest/node/barretenberg/common.test.d.ts +0 -2
  308. package/dest/node/barretenberg/common.test.d.ts.map +0 -1
  309. package/dest/node/barretenberg/common.test.js +0 -20
  310. package/dest/node/barretenberg_api/index.d.ts +0 -109
  311. package/dest/node/barretenberg_api/index.d.ts.map +0 -1
  312. package/dest/node/barretenberg_api/index.js +0 -699
  313. package/dest/node/bindgen/function_declaration.d.ts +0 -11
  314. package/dest/node/bindgen/function_declaration.d.ts.map +0 -1
  315. package/dest/node/bindgen/function_declaration.js +0 -2
  316. package/dest/node/bindgen/index.d.ts +0 -2
  317. package/dest/node/bindgen/index.d.ts.map +0 -1
  318. package/dest/node/bindgen/index.js +0 -15
  319. package/dest/node/bindgen/mappings.d.ts +0 -4
  320. package/dest/node/bindgen/mappings.d.ts.map +0 -1
  321. package/dest/node/bindgen/mappings.js +0 -64
  322. package/dest/node/bindgen/rust.d.ts +0 -2
  323. package/dest/node/bindgen/rust.d.ts.map +0 -1
  324. package/dest/node/bindgen/rust.js +0 -43
  325. package/dest/node/bindgen/to_camel_case.d.ts +0 -2
  326. package/dest/node/bindgen/to_camel_case.d.ts.map +0 -1
  327. package/dest/node/bindgen/to_camel_case.js +0 -11
  328. package/dest/node/bindgen/typescript.d.ts +0 -2
  329. package/dest/node/bindgen/typescript.d.ts.map +0 -1
  330. package/dest/node/bindgen/typescript.js +0 -100
  331. package/dest/node/cbind/generated/native.d.ts +0 -31
  332. package/dest/node/cbind/generated/native.d.ts.map +0 -1
  333. package/dest/node/cbind/generated/native.js +0 -234
  334. package/dest/node/main.d.ts +0 -13
  335. package/dest/node/main.d.ts.map +0 -1
  336. package/dest/node/main.js +0 -459
  337. package/dest/node/serialize/buffer_reader.d.ts +0 -28
  338. package/dest/node/serialize/buffer_reader.d.ts.map +0 -1
  339. package/dest/node/serialize/buffer_reader.js +0 -66
  340. package/dest/node/serialize/output_type.d.ts +0 -11
  341. package/dest/node/serialize/output_type.d.ts.map +0 -1
  342. package/dest/node/serialize/output_type.js +0 -44
  343. package/dest/node/types/fixed_size_buffer.d.ts +0 -26
  344. package/dest/node/types/fixed_size_buffer.d.ts.map +0 -1
  345. package/dest/node/types/fixed_size_buffer.js +0 -51
  346. package/dest/node/types/ptr.d.ts +0 -13
  347. package/dest/node/types/ptr.d.ts.map +0 -1
  348. package/dest/node/types/ptr.js +0 -19
  349. package/dest/node/types/raw_buffer.d.ts +0 -3
  350. package/dest/node/types/raw_buffer.d.ts.map +0 -1
  351. package/dest/node/types/raw_buffer.js +0 -5
  352. package/dest/node-cjs/barretenberg/common.test.d.ts +0 -2
  353. package/dest/node-cjs/barretenberg/common.test.d.ts.map +0 -1
  354. package/dest/node-cjs/barretenberg/common.test.js +0 -22
  355. package/dest/node-cjs/barretenberg_api/index.d.ts +0 -109
  356. package/dest/node-cjs/barretenberg_api/index.d.ts.map +0 -1
  357. package/dest/node-cjs/barretenberg_api/index.js +0 -704
  358. package/dest/node-cjs/bindgen/function_declaration.d.ts +0 -11
  359. package/dest/node-cjs/bindgen/function_declaration.d.ts.map +0 -1
  360. package/dest/node-cjs/bindgen/function_declaration.js +0 -3
  361. package/dest/node-cjs/bindgen/index.d.ts +0 -2
  362. package/dest/node-cjs/bindgen/index.d.ts.map +0 -1
  363. package/dest/node-cjs/bindgen/index.js +0 -17
  364. package/dest/node-cjs/bindgen/mappings.d.ts +0 -4
  365. package/dest/node-cjs/bindgen/mappings.d.ts.map +0 -1
  366. package/dest/node-cjs/bindgen/mappings.js +0 -69
  367. package/dest/node-cjs/bindgen/rust.d.ts +0 -2
  368. package/dest/node-cjs/bindgen/rust.d.ts.map +0 -1
  369. package/dest/node-cjs/bindgen/rust.js +0 -47
  370. package/dest/node-cjs/bindgen/to_camel_case.d.ts +0 -2
  371. package/dest/node-cjs/bindgen/to_camel_case.d.ts.map +0 -1
  372. package/dest/node-cjs/bindgen/to_camel_case.js +0 -14
  373. package/dest/node-cjs/bindgen/typescript.d.ts +0 -2
  374. package/dest/node-cjs/bindgen/typescript.d.ts.map +0 -1
  375. package/dest/node-cjs/bindgen/typescript.js +0 -104
  376. package/dest/node-cjs/cbind/generated/native.d.ts +0 -31
  377. package/dest/node-cjs/cbind/generated/native.d.ts.map +0 -1
  378. package/dest/node-cjs/cbind/generated/native.js +0 -238
  379. package/dest/node-cjs/main.d.ts +0 -13
  380. package/dest/node-cjs/main.d.ts.map +0 -1
  381. package/dest/node-cjs/main.js +0 -470
  382. package/dest/node-cjs/serialize/buffer_reader.d.ts +0 -28
  383. package/dest/node-cjs/serialize/buffer_reader.d.ts.map +0 -1
  384. package/dest/node-cjs/serialize/buffer_reader.js +0 -70
  385. package/dest/node-cjs/serialize/output_type.d.ts +0 -11
  386. package/dest/node-cjs/serialize/output_type.d.ts.map +0 -1
  387. package/dest/node-cjs/serialize/output_type.js +0 -51
  388. package/dest/node-cjs/types/fixed_size_buffer.d.ts +0 -26
  389. package/dest/node-cjs/types/fixed_size_buffer.d.ts.map +0 -1
  390. package/dest/node-cjs/types/fixed_size_buffer.js +0 -57
  391. package/dest/node-cjs/types/ptr.d.ts +0 -13
  392. package/dest/node-cjs/types/ptr.d.ts.map +0 -1
  393. package/dest/node-cjs/types/ptr.js +0 -23
  394. package/dest/node-cjs/types/raw_buffer.d.ts +0 -3
  395. package/dest/node-cjs/types/raw_buffer.d.ts.map +0 -1
  396. package/dest/node-cjs/types/raw_buffer.js +0 -9
  397. package/src/barretenberg/common.test.ts +0 -23
  398. package/src/barretenberg_api/index.ts +0 -1216
  399. package/src/bindgen/function_declaration.ts +0 -11
  400. package/src/bindgen/index.ts +0 -17
  401. package/src/bindgen/mappings.ts +0 -67
  402. package/src/bindgen/rust.ts +0 -52
  403. package/src/bindgen/to_camel_case.ts +0 -10
  404. package/src/bindgen/typescript.ts +0 -116
  405. package/src/main.ts +0 -534
  406. package/src/serialize/buffer_reader.ts +0 -85
  407. package/src/serialize/output_type.ts +0 -53
  408. package/src/types/fixed_size_buffer.ts +0 -59
  409. package/src/types/ptr.ts +0 -20
  410. package/src/types/raw_buffer.ts +0 -3
package/src/main.ts DELETED
@@ -1,534 +0,0 @@
1
- #!/usr/bin/env node
2
- import 'source-map-support/register.js';
3
- import { Crs, Barretenberg, RawBuffer } from './index.js';
4
- import { createDebugLogger, initLogger } from './log/index.js';
5
- import { readFileSync, writeFileSync } from 'fs';
6
- import { gunzipSync } from 'zlib';
7
- import { Command } from 'commander';
8
- import { UltraHonkBackendOptions } from './barretenberg/backend.js';
9
-
10
- let debug: (msg: string) => void;
11
-
12
- const threads = +process.env.HARDWARE_CONCURRENCY! || undefined;
13
-
14
- function getBytecode(bytecodePath: string): Uint8Array {
15
- const extension = bytecodePath.substring(bytecodePath.lastIndexOf('.') + 1);
16
-
17
- if (extension == 'json') {
18
- const encodedCircuit = JSON.parse(readFileSync(bytecodePath, 'utf8'));
19
- const decompressed = gunzipSync(Buffer.from(encodedCircuit.bytecode, 'base64'));
20
- return Uint8Array.from(decompressed);
21
- }
22
-
23
- const encodedCircuit = readFileSync(bytecodePath);
24
- const decompressed = gunzipSync(encodedCircuit);
25
- return Uint8Array.from(decompressed);
26
- }
27
-
28
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): split this into separate Plonk and Honk functions as their gate count differs
29
- async function getGatesUltra(bytecodePath: string, recursive: boolean, honkRecursion: boolean, api: Barretenberg) {
30
- const { total } = await computeCircuitSize(bytecodePath, recursive, honkRecursion, api);
31
- return total;
32
- }
33
-
34
- function getWitness(witnessPath: string): Uint8Array {
35
- const data = readFileSync(witnessPath);
36
- const decompressed = gunzipSync(data);
37
- return Uint8Array.from(decompressed);
38
- }
39
-
40
- async function computeCircuitSize(bytecodePath: string, recursive: boolean, honkRecursion: boolean, api: Barretenberg) {
41
- debug(`Computing circuit size for ${bytecodePath}`);
42
- const bytecode = getBytecode(bytecodePath);
43
- const [total, subgroup] = await api.acirGetCircuitSizes(bytecode, recursive, honkRecursion);
44
- return { total, subgroup };
45
- }
46
-
47
- async function initUltraHonk(bytecodePath: string, crsPath: string) {
48
- const api = await Barretenberg.new({
49
- threads,
50
- });
51
-
52
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice.
53
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraHonk function
54
- // recursive here is useless for UH, as it does not affect anything
55
- const circuitSize = await getGatesUltra(bytecodePath, /*recursive=*/ false, /*honkRecursion=*/ true, api);
56
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin
57
- const dyadicCircuitSize = Math.pow(2, Math.ceil(Math.log2(circuitSize)));
58
-
59
- debug(`Loading CRS for UltraHonk with circuit-size=${circuitSize} dyadic-circuit-size=${dyadicCircuitSize}`);
60
- const crs = await Crs.new(dyadicCircuitSize + 1, crsPath);
61
-
62
- // Load CRS into wasm global CRS state.
63
- // TODO: Make RawBuffer be default behavior, and have a specific Vector type for when wanting length prefixed.
64
- await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
65
- return { api, circuitSize, dyadicCircuitSize };
66
- }
67
-
68
- async function initLite(crsPath: string) {
69
- const api = await Barretenberg.new({ threads: 1 });
70
-
71
- // Plus 1 needed! (Move +1 into Crs?)
72
- const crs = await Crs.new(1, crsPath);
73
-
74
- // Load CRS into wasm global CRS state.
75
- await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
76
-
77
- return { api };
78
- }
79
-
80
- export async function proveAndVerifyUltraHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
81
- /* eslint-disable camelcase */
82
- const { api } = await initUltraHonk(bytecodePath, crsPath);
83
- try {
84
- const bytecode = getBytecode(bytecodePath);
85
- const witness = getWitness(witnessPath);
86
-
87
- const verified = await api.acirProveAndVerifyUltraHonk(bytecode, witness);
88
- return verified;
89
- } finally {
90
- await api.destroy();
91
- }
92
- /* eslint-enable camelcase */
93
- }
94
-
95
- export async function proveAndVerifyMegaHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
96
- /* eslint-disable camelcase */
97
- const { api } = await initUltraHonk(bytecodePath, crsPath);
98
- try {
99
- const bytecode = getBytecode(bytecodePath);
100
- const witness = getWitness(witnessPath);
101
-
102
- const verified = await api.acirProveAndVerifyMegaHonk(bytecode, witness);
103
- return verified;
104
- } finally {
105
- await api.destroy();
106
- }
107
- /* eslint-enable camelcase */
108
- }
109
-
110
- export async function gateCountUltra(bytecodePath: string, recursive: boolean, honkRecursion: boolean) {
111
- const api = await Barretenberg.new({ threads: 1 });
112
- try {
113
- const numberOfGates = await getGatesUltra(bytecodePath, recursive, honkRecursion, api);
114
- debug(`Number of gates: ${numberOfGates}`);
115
- // Create an 8-byte buffer and write the number into it.
116
- // Writing number directly to stdout will result in a variable sized
117
- // input depending on the size.
118
- const buffer = Buffer.alloc(8);
119
- buffer.writeBigInt64LE(BigInt(numberOfGates));
120
-
121
- process.stdout.write(Uint8Array.from(buffer));
122
- } finally {
123
- await api.destroy();
124
- }
125
- }
126
-
127
- export async function contractUltraHonk(bytecodePath: string, vkPath: string, crsPath: string, outputPath: string) {
128
- const { api } = await initUltraHonk(bytecodePath, crsPath);
129
- try {
130
- debug(`Creating UltraHonk verifier contract bytecode=${bytecodePath} vk=${vkPath}`);
131
- const bytecode = getBytecode(bytecodePath);
132
- const vk = new RawBuffer(readFileSync(vkPath));
133
- const contract = await api.acirHonkSolidityVerifier(bytecode, vk);
134
-
135
- if (outputPath === '-') {
136
- process.stdout.write(contract);
137
- debug(`Solidity verifier contract written to stdout`);
138
- } else {
139
- writeFileSync(outputPath, contract);
140
- debug(`Solidity verifier contract written to ${outputPath}`);
141
- }
142
- } finally {
143
- await api.destroy();
144
- }
145
- }
146
-
147
- export async function proveUltraHonk(
148
- bytecodePath: string,
149
- witnessPath: string,
150
- crsPath: string,
151
- vkPath: string,
152
- outputPath: string,
153
- options?: UltraHonkBackendOptions,
154
- ) {
155
- const { api } = await initUltraHonk(bytecodePath, crsPath);
156
- try {
157
- debug(`Creating UltraHonk proof bytecode=${bytecodePath}`);
158
- const bytecode = getBytecode(bytecodePath);
159
- const witness = getWitness(witnessPath);
160
-
161
- const acirProveUltraHonk = options?.keccak
162
- ? api.acirProveUltraKeccakHonk.bind(api)
163
- : options?.keccakZK
164
- ? api.acirProveUltraKeccakZkHonk.bind(api)
165
- : options?.starknet
166
- ? api.acirProveUltraStarknetHonk.bind(api)
167
- : options?.starknetZK
168
- ? api.acirProveUltraStarknetZkHonk.bind(api)
169
- : api.acirProveUltraZKHonk.bind(api);
170
- const proof = await acirProveUltraHonk(bytecode, witness, new RawBuffer(readFileSync(vkPath)));
171
-
172
- if (outputPath === '-') {
173
- process.stdout.write(proof);
174
- debug(`Proof written to stdout`);
175
- } else {
176
- writeFileSync(outputPath, proof);
177
- debug(`Proof written to ${outputPath}`);
178
- }
179
- } finally {
180
- await api.destroy();
181
- }
182
- }
183
-
184
- export async function writeVkUltraHonk(
185
- bytecodePath: string,
186
- crsPath: string,
187
- outputPath: string,
188
- options?: UltraHonkBackendOptions,
189
- ) {
190
- const { api } = await initUltraHonk(bytecodePath, crsPath);
191
- try {
192
- const bytecode = getBytecode(bytecodePath);
193
- debug(`Initializing UltraHonk verification key bytecode=${bytecodePath}`);
194
-
195
- const acirWriteVkUltraHonk = options?.keccak
196
- ? api.acirWriteVkUltraKeccakHonk.bind(api)
197
- : options?.keccakZK
198
- ? api.acirWriteVkUltraKeccakZkHonk.bind(api)
199
- : options?.starknet
200
- ? api.acirWriteVkUltraStarknetHonk.bind(api)
201
- : options?.starknetZK
202
- ? api.acirWriteVkUltraStarknetZkHonk.bind(api)
203
- : api.acirWriteVkUltraHonk.bind(api);
204
- const vk = await acirWriteVkUltraHonk(bytecode);
205
-
206
- if (outputPath === '-') {
207
- process.stdout.write(vk);
208
- debug(`Verification key written to stdout`);
209
- } else {
210
- writeFileSync(outputPath, vk);
211
- debug(`Verification key written to ${outputPath}`);
212
- }
213
- } finally {
214
- await api.destroy();
215
- }
216
- }
217
-
218
- export async function verifyUltraHonk(
219
- proofPath: string,
220
- vkPath: string,
221
- crsPath: string,
222
- options?: UltraHonkBackendOptions,
223
- ) {
224
- const { api } = await initLite(crsPath);
225
- try {
226
- const acirVerifyUltraHonk = options?.keccak
227
- ? api.acirVerifyUltraKeccakHonk.bind(api)
228
- : options?.keccakZK
229
- ? api.acirVerifyUltraKeccakZkHonk.bind(api)
230
- : options?.starknet
231
- ? api.acirVerifyUltraStarknetHonk.bind(api)
232
- : options?.starknetZK
233
- ? api.acirVerifyUltraStarknetZkHonk.bind(api)
234
- : api.acirVerifyUltraZKHonk.bind(api);
235
- const verified = await acirVerifyUltraHonk(
236
- Uint8Array.from(readFileSync(proofPath)),
237
- new RawBuffer(readFileSync(vkPath)),
238
- );
239
-
240
- debug(`Verification ${verified ? 'successful' : 'failed'}`);
241
- return verified;
242
- } finally {
243
- await api.destroy();
244
- }
245
- }
246
-
247
- export async function proofAsFieldsUltraHonk(proofPath: string, outputPath: string, crsPath: string) {
248
- const { api } = await initLite(crsPath);
249
- try {
250
- debug(`Outputting UltraHonk proof as vector of fields proof=${proofPath}`);
251
- const proofAsFields = await api.acirProofAsFieldsUltraHonk(Uint8Array.from(readFileSync(proofPath)));
252
- const jsonProofAsFields = JSON.stringify(proofAsFields.map(f => f.toString()));
253
-
254
- if (outputPath === '-') {
255
- process.stdout.write(jsonProofAsFields);
256
- debug(`Proof as fields written to stdout`);
257
- } else {
258
- writeFileSync(outputPath, jsonProofAsFields);
259
- debug(`Proof as fields written to ${outputPath}`);
260
- }
261
- } finally {
262
- await api.destroy();
263
- }
264
- }
265
-
266
- export async function vkAsFieldsUltraHonk(vkPath: string, vkeyOutputPath: string, crsPath: string) {
267
- const { api } = await initLite(crsPath);
268
-
269
- try {
270
- debug(`Serializing vk byte array into field elements vk=${vkPath}`);
271
- const vkAsFields = await api.acirVkAsFieldsUltraHonk(new RawBuffer(readFileSync(vkPath)));
272
- const jsonVKAsFields = JSON.stringify(vkAsFields.map(f => f.toString()));
273
-
274
- if (vkeyOutputPath === '-') {
275
- process.stdout.write(jsonVKAsFields);
276
- debug(`Verification key as fields written to stdout`);
277
- } else {
278
- writeFileSync(vkeyOutputPath, jsonVKAsFields);
279
- debug(`Verification key as fields written to ${vkeyOutputPath}`);
280
- }
281
- } finally {
282
- await api.destroy();
283
- }
284
- }
285
-
286
- const program = new Command('bb');
287
-
288
- program.option('-v, --verbose', 'enable verbose logging', false);
289
- program.option('-c, --crs-path <path>', 'set crs path', './crs');
290
-
291
- function handleGlobalOptions() {
292
- initLogger({ useStdErr: true, level: program.opts().verbose ? 'debug' : 'info' });
293
- debug = createDebugLogger('bb');
294
- return { crsPath: program.opts().crsPath };
295
- }
296
-
297
- const deprecatedCommandError = () => async () => {
298
- console.error(
299
- `Error: UltraPlonk is now deprecated (see https://github.com/AztecProtocol/barretenberg/issues/1377). Use UltraHonk!`,
300
- );
301
- process.exit(1);
302
- };
303
-
304
- program
305
- .command('prove_and_verify')
306
- .description('Generate a proof and verify it. Process exits with success or failure code. [DEPRECATED]')
307
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
308
- .option('-r, --recursive', 'Whether to use a SNARK friendly proof', false)
309
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
310
- .action(deprecatedCommandError());
311
-
312
- program
313
- .command('prove_and_verify_ultra_honk')
314
- .description('Generate an UltraHonk proof and verify it. Process exits with success or failure code.')
315
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
316
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
317
- .action(async ({ bytecodePath, witnessPath }) => {
318
- const { crsPath } = handleGlobalOptions();
319
- const result = await proveAndVerifyUltraHonk(bytecodePath, witnessPath, crsPath);
320
- process.exit(result ? 0 : 1);
321
- });
322
-
323
- program
324
- .command('prove_and_verify_mega_honk')
325
- .description('Generate a MegaHonk proof and verify it. Process exits with success or failure code.')
326
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
327
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
328
- .action(async ({ bytecodePath, witnessPath }) => {
329
- const { crsPath } = handleGlobalOptions();
330
- const result = await proveAndVerifyMegaHonk(bytecodePath, witnessPath, crsPath);
331
- process.exit(result ? 0 : 1);
332
- });
333
-
334
- program
335
- .command('prove')
336
- .description('Generate a proof and write it to a file. [DEPRECATED]')
337
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
338
- .option('-r, --recursive', 'Create a SNARK friendly proof', false)
339
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
340
- .option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
341
- .action(deprecatedCommandError());
342
-
343
- program
344
- .command('gates')
345
- .description('Print Ultra Builder gate count to standard output.')
346
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
347
- .option('-r, --recursive', 'Create a SNARK friendly proof', false)
348
- .option('-hr, --honk-recursion', 'Specify whether to use UltraHonk recursion', false)
349
- .action(async ({ bytecodePath, recursive, honkRecursion: honkRecursion }) => {
350
- handleGlobalOptions();
351
- await gateCountUltra(bytecodePath, recursive, honkRecursion);
352
- });
353
-
354
- program
355
- .command('verify')
356
- .description('Verify a proof. Process exists with success or failure code. [DEPRECATED]')
357
- .requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
358
- .requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
359
- .action(deprecatedCommandError());
360
-
361
- program
362
- .command('contract')
363
- .description('Output solidity verification key contract. [DEPRECATED]')
364
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
365
- .option('-o, --output-path <path>', 'Specify the path to write the contract', './target/contract.sol')
366
- .requiredOption('-k, --vk-path <path>', 'Path to a verification key. avoids recomputation.')
367
- .action(deprecatedCommandError());
368
-
369
- program
370
- .command('contract_ultra_honk')
371
- .description('Output solidity verification key contract.')
372
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
373
- .option('-o, --output-path <path>', 'Specify the path to write the contract', './target/contract.sol')
374
- .requiredOption('-k, --vk-path <path>', 'Path to a verification key.')
375
- .action(async ({ bytecodePath, outputPath, vkPath }) => {
376
- const { crsPath } = handleGlobalOptions();
377
- await contractUltraHonk(bytecodePath, vkPath, crsPath, outputPath);
378
- });
379
-
380
- program
381
- .command('write_vk')
382
- .description('Output verification key. [DEPRECATED]')
383
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
384
- .option('-r, --recursive', 'Create a SNARK friendly proof', false)
385
- .option('-o, --output-path <path>', 'Specify the path to write the key')
386
- .action(deprecatedCommandError());
387
-
388
- program
389
- .command('write_pk')
390
- .description('Output proving key. [DEPRECATED]')
391
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
392
- .option('-r, --recursive', 'Create a SNARK friendly proof', false)
393
- .requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
394
- .action(deprecatedCommandError());
395
-
396
- program
397
- .command('proof_as_fields')
398
- .description('Return the proof as fields elements. [DEPRECATED]')
399
- .requiredOption('-p, --proof-path <path>', 'Specify the proof path')
400
- .requiredOption('-k, --vk-path <path>', 'Path to verification key.')
401
- .requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the proof fields')
402
- .action(deprecatedCommandError());
403
-
404
- program
405
- .command('vk_as_fields')
406
- .description(
407
- 'Return the verification key represented as fields elements. Also return the verification key hash. [DEPRECATED]',
408
- )
409
- .requiredOption('-k, --vk-path <path>', 'Path to verification key.')
410
- .requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the verification key fields and key hash')
411
- .action(deprecatedCommandError());
412
-
413
- program
414
- .command('prove_ultra_honk')
415
- .description('Generate a proof and write it to a file.')
416
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
417
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
418
- .option('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
419
- .option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
420
- .action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
421
- const { crsPath } = handleGlobalOptions();
422
- debug(`Creating UltraHonk proof bytecodePath=${bytecodePath}, witnessPath=${witnessPath}, vkPath=${vkPath}`);
423
- await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath);
424
- });
425
-
426
- program
427
- .command('prove_ultra_keccak_honk')
428
- .description('Generate a proof and write it to a file.')
429
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
430
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
431
- .option('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
432
- .option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
433
- .action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
434
- const { crsPath } = handleGlobalOptions();
435
- await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath, { keccak: true });
436
- });
437
-
438
- program
439
- .command('prove_ultra_starknet_honk')
440
- .description('Generate a proof and write it to a file.')
441
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
442
- .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
443
- .option('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
444
- .option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
445
- .action(async ({ bytecodePath, witnessPath, vkPath, outputPath }) => {
446
- const { crsPath } = handleGlobalOptions();
447
- await proveUltraHonk(bytecodePath, witnessPath, crsPath, vkPath, outputPath, { starknet: true });
448
- });
449
-
450
- program
451
- .command('write_vk_ultra_honk')
452
- .description('Output verification key.')
453
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
454
- .requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
455
- .action(async ({ bytecodePath, outputPath }) => {
456
- const { crsPath } = handleGlobalOptions();
457
- debug(`Writing verification key to ${outputPath}`);
458
- await writeVkUltraHonk(bytecodePath, crsPath, outputPath);
459
- });
460
-
461
- program
462
- .command('write_vk_ultra_keccak_honk')
463
- .description('Output verification key.')
464
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
465
- .requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
466
- .action(async ({ bytecodePath, outputPath }) => {
467
- const { crsPath } = handleGlobalOptions();
468
- await writeVkUltraHonk(bytecodePath, crsPath, outputPath, { keccak: true });
469
- });
470
-
471
- program
472
- .command('write_vk_ultra_starknet_honk')
473
- .description('Output verification key.')
474
- .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
475
- .requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
476
- .action(async ({ bytecodePath, outputPath }) => {
477
- const { crsPath } = handleGlobalOptions();
478
- await writeVkUltraHonk(bytecodePath, crsPath, outputPath, { starknet: true });
479
- });
480
-
481
- program
482
- .command('verify_ultra_honk')
483
- .description('Verify a proof. Process exists with success or failure code.')
484
- .requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
485
- .requiredOption('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
486
- .action(async ({ proofPath, vkPath }) => {
487
- const { crsPath } = handleGlobalOptions();
488
- const result = await verifyUltraHonk(proofPath, vkPath, crsPath);
489
- process.exit(result ? 0 : 1);
490
- });
491
-
492
- program
493
- .command('verify_ultra_keccak_honk')
494
- .description('Verify a proof. Process exists with success or failure code.')
495
- .requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
496
- .requiredOption('-k, --vk-path <path>', 'path to a verification key. avoids recomputation.')
497
- .action(async ({ proofPath, vkPath }) => {
498
- const { crsPath } = handleGlobalOptions();
499
- const result = await verifyUltraHonk(proofPath, vkPath, crsPath, { keccak: true });
500
- process.exit(result ? 0 : 1);
501
- });
502
-
503
- program
504
- .command('verify_ultra_starknet_honk')
505
- .description('Verify a proof. Process exists with success or failure code.')
506
- .requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
507
- .requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
508
- .action(async ({ proofPath, vk }) => {
509
- const { crsPath } = handleGlobalOptions();
510
- const result = await verifyUltraHonk(proofPath, vk, crsPath, { starknet: true });
511
- process.exit(result ? 0 : 1);
512
- });
513
-
514
- program
515
- .command('proof_as_fields_honk')
516
- .description('Return the proof as fields elements')
517
- .requiredOption('-p, --proof-path <path>', 'Specify the proof path')
518
- .requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the proof fields')
519
- .action(async ({ proofPath, outputPath }) => {
520
- const { crsPath } = handleGlobalOptions();
521
- await proofAsFieldsUltraHonk(proofPath, outputPath, crsPath);
522
- });
523
-
524
- program
525
- .command('vk_as_fields_ultra_honk')
526
- .description('Return the verification key represented as fields elements.')
527
- .requiredOption('-k, --vk-path <path>', 'Path to verification key.')
528
- .requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the verification key fields.')
529
- .action(async ({ vkPath, outputPath }) => {
530
- const { crsPath } = handleGlobalOptions();
531
- await vkAsFieldsUltraHonk(vkPath, outputPath, crsPath);
532
- });
533
-
534
- program.name('bb.js').parse(process.argv);
@@ -1,85 +0,0 @@
1
- export class BufferReader {
2
- private index: number;
3
- constructor(
4
- private buffer: Uint8Array,
5
- offset = 0,
6
- ) {
7
- this.index = offset;
8
- }
9
-
10
- public static asReader(bufferOrReader: Uint8Array | BufferReader) {
11
- return bufferOrReader instanceof BufferReader ? bufferOrReader : new BufferReader(bufferOrReader);
12
- }
13
-
14
- public readNumber(): number {
15
- const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.index, 4);
16
- this.index += 4;
17
- return dataView.getUint32(0, false);
18
- }
19
-
20
- public readBoolean(): boolean {
21
- this.index += 1;
22
- return Boolean(this.buffer.at(this.index - 1));
23
- }
24
-
25
- public readBytes(n: number): Uint8Array {
26
- this.index += n;
27
- return this.buffer.slice(this.index - n, this.index);
28
- }
29
-
30
- public readNumberVector(): number[] {
31
- return this.readVector({
32
- fromBuffer: (reader: BufferReader) => reader.readNumber(),
33
- });
34
- }
35
-
36
- public readVector<T>(itemDeserializer: { fromBuffer: (reader: BufferReader) => T }): T[] {
37
- const size = this.readNumber();
38
- const result = new Array<T>(size);
39
- for (let i = 0; i < size; i++) {
40
- result[i] = itemDeserializer.fromBuffer(this);
41
- }
42
- return result;
43
- }
44
-
45
- public readArray<T>(
46
- size: number,
47
- itemDeserializer: {
48
- fromBuffer: (reader: BufferReader) => T;
49
- },
50
- ): T[] {
51
- const result = new Array<T>(size);
52
- for (let i = 0; i < size; i++) {
53
- result[i] = itemDeserializer.fromBuffer(this);
54
- }
55
- return result;
56
- }
57
-
58
- public readObject<T>(deserializer: { fromBuffer: (reader: BufferReader) => T }): T {
59
- return deserializer.fromBuffer(this);
60
- }
61
-
62
- public peekBytes(n?: number) {
63
- return this.buffer.subarray(this.index, n ? this.index + n : undefined);
64
- }
65
-
66
- public readString(): string {
67
- return new TextDecoder().decode(this.readBuffer());
68
- }
69
-
70
- public readBuffer(): Uint8Array {
71
- const size = this.readNumber();
72
- return this.readBytes(size);
73
- }
74
-
75
- public readMap<T>(deserializer: { fromBuffer: (reader: BufferReader) => T }): { [key: string]: T } {
76
- const numEntries = this.readNumber();
77
- const map: { [key: string]: T } = {};
78
- for (let i = 0; i < numEntries; i++) {
79
- const key = this.readString();
80
- const value = this.readObject<T>(deserializer);
81
- map[key] = value;
82
- }
83
- return map;
84
- }
85
- }
@@ -1,53 +0,0 @@
1
- import { BufferReader } from './buffer_reader.js';
2
-
3
- export interface OutputType<T = any> {
4
- SIZE_IN_BYTES?: number;
5
- fromBuffer: (b: Uint8Array | BufferReader) => T;
6
- }
7
-
8
- export function BoolDeserializer(): OutputType {
9
- return {
10
- SIZE_IN_BYTES: 1,
11
- fromBuffer: (buf: Uint8Array | BufferReader) => {
12
- const reader = BufferReader.asReader(buf);
13
- return reader.readBoolean();
14
- },
15
- };
16
- }
17
-
18
- export function NumberDeserializer(): OutputType {
19
- return {
20
- SIZE_IN_BYTES: 4,
21
- fromBuffer: (buf: Uint8Array | BufferReader) => {
22
- const reader = BufferReader.asReader(buf);
23
- return reader.readNumber();
24
- },
25
- };
26
- }
27
-
28
- export function VectorDeserializer<T>(t: OutputType<T>): OutputType {
29
- return {
30
- fromBuffer: (buf: Uint8Array | BufferReader) => {
31
- const reader = BufferReader.asReader(buf);
32
- return reader.readVector(t);
33
- },
34
- };
35
- }
36
-
37
- export function BufferDeserializer(): OutputType {
38
- return {
39
- fromBuffer: (buf: Uint8Array | BufferReader) => {
40
- const reader = BufferReader.asReader(buf);
41
- return reader.readBuffer();
42
- },
43
- };
44
- }
45
-
46
- export function StringDeserializer(): OutputType {
47
- return {
48
- fromBuffer: (buf: Uint8Array | BufferReader) => {
49
- const reader = BufferReader.asReader(buf);
50
- return reader.readString();
51
- },
52
- };
53
- }