@aztec/bb.js 3.0.0-nightly.20251016 → 3.0.0-nightly.20251023

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 (368) hide show
  1. package/README.md +12 -78
  2. package/dest/browser/barretenberg/backend.d.ts +1 -1
  3. package/dest/browser/barretenberg/backend.d.ts.map +1 -1
  4. package/dest/browser/barretenberg/backend.js +21 -13
  5. package/dest/browser/barretenberg/index.d.ts +44 -43
  6. package/dest/browser/barretenberg/index.d.ts.map +1 -1
  7. package/dest/browser/barretenberg/index.js +130 -79
  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 +54 -13
  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 +56 -0
  32. package/dest/browser/bb_backends/wasm.d.ts.map +1 -0
  33. package/dest/browser/bb_backends/wasm.js +90 -0
  34. package/dest/browser/cbind/generate.js +2 -7
  35. package/dest/browser/cbind/generated/api_types.d.ts +1167 -0
  36. package/dest/browser/cbind/generated/api_types.d.ts.map +1 -1
  37. package/dest/browser/cbind/generated/api_types.js +1609 -47
  38. package/dest/browser/cbind/generated/async.d.ts +38 -4
  39. package/dest/browser/cbind/generated/async.d.ts.map +1 -1
  40. package/dest/browser/cbind/generated/async.js +327 -21
  41. package/dest/browser/cbind/generated/sync.d.ts +39 -5
  42. package/dest/browser/cbind/generated/sync.d.ts.map +1 -1
  43. package/dest/browser/cbind/generated/sync.js +294 -21
  44. package/dest/browser/cbind/schema_compiler.d.ts +2 -4
  45. package/dest/browser/cbind/schema_compiler.d.ts.map +1 -1
  46. package/dest/browser/cbind/schema_compiler.js +74 -178
  47. package/dest/browser/index.d.ts +2 -2
  48. package/dest/browser/index.d.ts.map +1 -1
  49. package/dest/browser/index.js +3 -3
  50. package/dest/browser/serialize/index.d.ts +0 -1
  51. package/dest/browser/serialize/index.d.ts.map +1 -1
  52. package/dest/browser/serialize/index.js +1 -2
  53. package/dest/browser/serialize/serialize.d.ts +0 -35
  54. package/dest/browser/serialize/serialize.d.ts.map +1 -1
  55. package/dest/browser/serialize/serialize.js +1 -68
  56. package/dest/browser/types/fields.d.ts.map +1 -1
  57. package/dest/browser/types/fields.js +3 -3
  58. package/dest/browser/types/index.d.ts +0 -3
  59. package/dest/browser/types/index.d.ts.map +1 -1
  60. package/dest/browser/types/index.js +1 -4
  61. package/dest/node/barretenberg/__snapshots__/pedersen.test.js.snap +2 -2
  62. package/dest/node/barretenberg/__snapshots__/poseidon.test.js.snap +3 -3
  63. package/dest/node/barretenberg/backend.d.ts +1 -1
  64. package/dest/node/barretenberg/backend.d.ts.map +1 -1
  65. package/dest/node/barretenberg/backend.js +21 -13
  66. package/dest/node/barretenberg/blake2s.test.js +21 -18
  67. package/dest/node/barretenberg/index.d.ts +44 -43
  68. package/dest/node/barretenberg/index.d.ts.map +1 -1
  69. package/dest/node/barretenberg/index.js +130 -79
  70. package/dest/node/barretenberg/pedersen.test.js +24 -17
  71. package/dest/node/barretenberg/poseidon.bench.test.d.ts +2 -0
  72. package/dest/node/barretenberg/poseidon.bench.test.d.ts.map +1 -0
  73. package/dest/node/barretenberg/poseidon.bench.test.js +216 -0
  74. package/dest/node/barretenberg/poseidon.test.js +15 -15
  75. package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  76. package/dest/node/barretenberg_wasm/barretenberg_wasm_base/index.d.ts +1 -1
  77. package/dest/node/barretenberg_wasm/barretenberg_wasm_base/index.d.ts.map +1 -1
  78. package/dest/node/barretenberg_wasm/barretenberg_wasm_base/index.js +2 -2
  79. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts +4 -4
  80. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts.map +1 -1
  81. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.js +18 -10
  82. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/index.d.ts +3 -0
  83. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/index.d.ts.map +1 -1
  84. package/dest/node/barretenberg_wasm/barretenberg_wasm_main/index.js +54 -13
  85. package/dest/node/barretenberg_wasm/index.test.js +11 -10
  86. package/dest/node/bb_backends/browser/index.d.ts +11 -0
  87. package/dest/node/bb_backends/browser/index.d.ts.map +1 -0
  88. package/dest/node/bb_backends/browser/index.js +39 -0
  89. package/dest/node/bb_backends/index.d.ts +45 -0
  90. package/dest/node/bb_backends/index.d.ts.map +1 -0
  91. package/dest/node/bb_backends/index.js +15 -0
  92. package/dest/node/bb_backends/interface.d.ts +33 -0
  93. package/dest/node/bb_backends/interface.d.ts.map +1 -0
  94. package/dest/node/bb_backends/interface.js +2 -0
  95. package/dest/node/bb_backends/node/index.d.ts +11 -0
  96. package/dest/node/bb_backends/node/index.d.ts.map +1 -0
  97. package/dest/node/bb_backends/node/index.js +80 -0
  98. package/dest/node/bb_backends/node/native_pipe.d.ts +25 -0
  99. package/dest/node/bb_backends/node/native_pipe.d.ts.map +1 -0
  100. package/dest/node/bb_backends/node/native_pipe.js +113 -0
  101. package/dest/node/bb_backends/node/native_shm.d.ts +28 -0
  102. package/dest/node/bb_backends/node/native_shm.d.ts.map +1 -0
  103. package/dest/node/bb_backends/node/native_shm.js +150 -0
  104. package/dest/node/bb_backends/node/native_socket.d.ts +34 -0
  105. package/dest/node/bb_backends/node/native_socket.d.ts.map +1 -0
  106. package/dest/node/bb_backends/node/native_socket.js +269 -0
  107. package/dest/node/bb_backends/node/platform.d.ts +27 -0
  108. package/dest/node/bb_backends/node/platform.d.ts.map +1 -0
  109. package/dest/node/bb_backends/node/platform.js +124 -0
  110. package/dest/node/bb_backends/sync_to_async_adapter.d.ts +15 -0
  111. package/dest/node/bb_backends/sync_to_async_adapter.d.ts.map +1 -0
  112. package/dest/node/bb_backends/sync_to_async_adapter.js +20 -0
  113. package/dest/node/bb_backends/wasm.d.ts +56 -0
  114. package/dest/node/bb_backends/wasm.d.ts.map +1 -0
  115. package/dest/node/bb_backends/wasm.js +90 -0
  116. package/dest/node/cbind/generate.js +2 -7
  117. package/dest/node/cbind/generated/api_types.d.ts +1167 -0
  118. package/dest/node/cbind/generated/api_types.d.ts.map +1 -1
  119. package/dest/node/cbind/generated/api_types.js +1609 -47
  120. package/dest/node/cbind/generated/async.d.ts +38 -4
  121. package/dest/node/cbind/generated/async.d.ts.map +1 -1
  122. package/dest/node/cbind/generated/async.js +327 -21
  123. package/dest/node/cbind/generated/sync.d.ts +39 -5
  124. package/dest/node/cbind/generated/sync.d.ts.map +1 -1
  125. package/dest/node/cbind/generated/sync.js +294 -21
  126. package/dest/node/cbind/schema_compiler.d.ts +2 -4
  127. package/dest/node/cbind/schema_compiler.d.ts.map +1 -1
  128. package/dest/node/cbind/schema_compiler.js +74 -178
  129. package/dest/node/index.d.ts +2 -2
  130. package/dest/node/index.d.ts.map +1 -1
  131. package/dest/node/index.js +3 -3
  132. package/dest/node/serialize/index.d.ts +0 -1
  133. package/dest/node/serialize/index.d.ts.map +1 -1
  134. package/dest/node/serialize/index.js +1 -2
  135. package/dest/node/serialize/serialize.d.ts +0 -35
  136. package/dest/node/serialize/serialize.d.ts.map +1 -1
  137. package/dest/node/serialize/serialize.js +1 -68
  138. package/dest/node/types/fields.d.ts.map +1 -1
  139. package/dest/node/types/fields.js +3 -3
  140. package/dest/node/types/index.d.ts +0 -3
  141. package/dest/node/types/index.d.ts.map +1 -1
  142. package/dest/node/types/index.js +1 -4
  143. package/dest/node-cjs/barretenberg/backend.d.ts +1 -1
  144. package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
  145. package/dest/node-cjs/barretenberg/backend.js +20 -12
  146. package/dest/node-cjs/barretenberg/blake2s.test.js +19 -16
  147. package/dest/node-cjs/barretenberg/index.d.ts +44 -43
  148. package/dest/node-cjs/barretenberg/index.d.ts.map +1 -1
  149. package/dest/node-cjs/barretenberg/index.js +136 -84
  150. package/dest/node-cjs/barretenberg/pedersen.test.js +24 -17
  151. package/dest/node-cjs/barretenberg/poseidon.bench.test.d.ts +2 -0
  152. package/dest/node-cjs/barretenberg/poseidon.bench.test.d.ts.map +1 -0
  153. package/dest/node-cjs/barretenberg/poseidon.bench.test.js +218 -0
  154. package/dest/node-cjs/barretenberg/poseidon.test.js +15 -15
  155. package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  156. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_base/index.d.ts +1 -1
  157. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_base/index.d.ts.map +1 -1
  158. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_base/index.js +2 -2
  159. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts +4 -4
  160. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.d.ts.map +1 -1
  161. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.js +18 -10
  162. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/index.d.ts +3 -0
  163. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/index.d.ts.map +1 -1
  164. package/dest/node-cjs/barretenberg_wasm/barretenberg_wasm_main/index.js +54 -13
  165. package/dest/node-cjs/barretenberg_wasm/index.test.js +11 -10
  166. package/dest/node-cjs/bb_backends/browser/index.d.ts +11 -0
  167. package/dest/node-cjs/bb_backends/browser/index.d.ts.map +1 -0
  168. package/dest/node-cjs/bb_backends/browser/index.js +43 -0
  169. package/dest/node-cjs/bb_backends/index.d.ts +45 -0
  170. package/dest/node-cjs/bb_backends/index.d.ts.map +1 -0
  171. package/dest/node-cjs/bb_backends/index.js +18 -0
  172. package/dest/node-cjs/bb_backends/interface.d.ts +33 -0
  173. package/dest/node-cjs/bb_backends/interface.d.ts.map +1 -0
  174. package/dest/node-cjs/bb_backends/interface.js +3 -0
  175. package/dest/node-cjs/bb_backends/node/index.d.ts +11 -0
  176. package/dest/node-cjs/bb_backends/node/index.d.ts.map +1 -0
  177. package/dest/node-cjs/bb_backends/node/index.js +84 -0
  178. package/dest/node-cjs/bb_backends/node/native_pipe.d.ts +25 -0
  179. package/dest/node-cjs/bb_backends/node/native_pipe.d.ts.map +1 -0
  180. package/dest/node-cjs/bb_backends/node/native_pipe.js +117 -0
  181. package/dest/node-cjs/bb_backends/node/native_shm.d.ts +28 -0
  182. package/dest/node-cjs/bb_backends/node/native_shm.d.ts.map +1 -0
  183. package/dest/node-cjs/bb_backends/node/native_shm.js +154 -0
  184. package/dest/node-cjs/bb_backends/node/native_socket.d.ts +34 -0
  185. package/dest/node-cjs/bb_backends/node/native_socket.d.ts.map +1 -0
  186. package/dest/node-cjs/bb_backends/node/native_socket.js +274 -0
  187. package/dest/node-cjs/bb_backends/node/platform.d.ts +27 -0
  188. package/dest/node-cjs/bb_backends/node/platform.d.ts.map +1 -0
  189. package/dest/node-cjs/bb_backends/node/platform.js +131 -0
  190. package/dest/node-cjs/bb_backends/sync_to_async_adapter.d.ts +15 -0
  191. package/dest/node-cjs/bb_backends/sync_to_async_adapter.d.ts.map +1 -0
  192. package/dest/node-cjs/bb_backends/sync_to_async_adapter.js +24 -0
  193. package/dest/node-cjs/bb_backends/wasm.d.ts +56 -0
  194. package/dest/node-cjs/bb_backends/wasm.d.ts.map +1 -0
  195. package/dest/node-cjs/bb_backends/wasm.js +95 -0
  196. package/dest/node-cjs/cbind/generate.js +1 -6
  197. package/dest/node-cjs/cbind/generated/api_types.d.ts +1167 -0
  198. package/dest/node-cjs/cbind/generated/api_types.d.ts.map +1 -1
  199. package/dest/node-cjs/cbind/generated/api_types.js +1747 -47
  200. package/dest/node-cjs/cbind/generated/async.d.ts +38 -4
  201. package/dest/node-cjs/cbind/generated/async.d.ts.map +1 -1
  202. package/dest/node-cjs/cbind/generated/async.js +326 -20
  203. package/dest/node-cjs/cbind/generated/sync.d.ts +39 -5
  204. package/dest/node-cjs/cbind/generated/sync.d.ts.map +1 -1
  205. package/dest/node-cjs/cbind/generated/sync.js +293 -20
  206. package/dest/node-cjs/cbind/schema_compiler.d.ts +2 -4
  207. package/dest/node-cjs/cbind/schema_compiler.d.ts.map +1 -1
  208. package/dest/node-cjs/cbind/schema_compiler.js +74 -179
  209. package/dest/node-cjs/index.d.ts +2 -2
  210. package/dest/node-cjs/index.d.ts.map +1 -1
  211. package/dest/node-cjs/index.js +3 -3
  212. package/dest/node-cjs/serialize/index.d.ts +0 -1
  213. package/dest/node-cjs/serialize/index.d.ts.map +1 -1
  214. package/dest/node-cjs/serialize/index.js +1 -2
  215. package/dest/node-cjs/serialize/serialize.d.ts +0 -35
  216. package/dest/node-cjs/serialize/serialize.d.ts.map +1 -1
  217. package/dest/node-cjs/serialize/serialize.js +1 -79
  218. package/dest/node-cjs/types/fields.d.ts.map +1 -1
  219. package/dest/node-cjs/types/fields.js +2 -2
  220. package/dest/node-cjs/types/index.d.ts +0 -3
  221. package/dest/node-cjs/types/index.d.ts.map +1 -1
  222. package/dest/node-cjs/types/index.js +1 -4
  223. package/package.json +3 -4
  224. package/src/barretenberg/__snapshots__/pedersen.test.ts.snap +2 -2
  225. package/src/barretenberg/__snapshots__/poseidon.test.ts.snap +3 -3
  226. package/src/barretenberg/backend.ts +37 -32
  227. package/src/barretenberg/blake2s.test.ts +20 -21
  228. package/src/barretenberg/index.ts +136 -117
  229. package/src/barretenberg/pedersen.test.ts +23 -16
  230. package/src/barretenberg/poseidon.bench.test.ts +267 -0
  231. package/src/barretenberg/poseidon.test.ts +14 -14
  232. package/src/barretenberg_wasm/barretenberg_wasm_base/index.ts +3 -3
  233. package/src/barretenberg_wasm/barretenberg_wasm_main/heap_allocator.ts +17 -9
  234. package/src/barretenberg_wasm/barretenberg_wasm_main/index.ts +66 -15
  235. package/src/barretenberg_wasm/index.test.ts +12 -11
  236. package/src/bb_backends/browser/index.ts +50 -0
  237. package/src/bb_backends/index.ts +49 -0
  238. package/src/bb_backends/interface.ts +35 -0
  239. package/src/bb_backends/node/index.ts +94 -0
  240. package/src/bb_backends/node/native_pipe.ts +127 -0
  241. package/src/bb_backends/node/native_shm.ts +171 -0
  242. package/src/bb_backends/node/native_socket.ts +312 -0
  243. package/src/bb_backends/node/platform.ts +151 -0
  244. package/src/bb_backends/sync_to_async_adapter.ts +21 -0
  245. package/src/bb_backends/wasm.ts +110 -0
  246. package/src/cbind/README.md +1 -1
  247. package/src/cbind/generate.ts +0 -6
  248. package/src/cbind/schema_compiler.ts +131 -241
  249. package/src/index.ts +2 -1
  250. package/src/serialize/index.ts +0 -1
  251. package/src/serialize/serialize.ts +0 -82
  252. package/src/types/fields.ts +2 -2
  253. package/src/types/index.ts +0 -3
  254. package/dest/browser/barretenberg_api/index.d.ts +0 -109
  255. package/dest/browser/barretenberg_api/index.d.ts.map +0 -1
  256. package/dest/browser/barretenberg_api/index.js +0 -699
  257. package/dest/browser/cbind/generated/native.d.ts +0 -31
  258. package/dest/browser/cbind/generated/native.d.ts.map +0 -1
  259. package/dest/browser/cbind/generated/native.js +0 -234
  260. package/dest/browser/serialize/output_type.d.ts +0 -11
  261. package/dest/browser/serialize/output_type.d.ts.map +0 -1
  262. package/dest/browser/serialize/output_type.js +0 -44
  263. package/dest/browser/types/fixed_size_buffer.d.ts +0 -26
  264. package/dest/browser/types/fixed_size_buffer.d.ts.map +0 -1
  265. package/dest/browser/types/fixed_size_buffer.js +0 -51
  266. package/dest/browser/types/ptr.d.ts +0 -13
  267. package/dest/browser/types/ptr.d.ts.map +0 -1
  268. package/dest/browser/types/ptr.js +0 -19
  269. package/dest/browser/types/raw_buffer.d.ts +0 -3
  270. package/dest/browser/types/raw_buffer.d.ts.map +0 -1
  271. package/dest/browser/types/raw_buffer.js +0 -5
  272. package/dest/node/barretenberg/common.test.d.ts +0 -2
  273. package/dest/node/barretenberg/common.test.d.ts.map +0 -1
  274. package/dest/node/barretenberg/common.test.js +0 -20
  275. package/dest/node/barretenberg_api/index.d.ts +0 -109
  276. package/dest/node/barretenberg_api/index.d.ts.map +0 -1
  277. package/dest/node/barretenberg_api/index.js +0 -699
  278. package/dest/node/bindgen/function_declaration.d.ts +0 -11
  279. package/dest/node/bindgen/function_declaration.d.ts.map +0 -1
  280. package/dest/node/bindgen/function_declaration.js +0 -2
  281. package/dest/node/bindgen/index.d.ts +0 -2
  282. package/dest/node/bindgen/index.d.ts.map +0 -1
  283. package/dest/node/bindgen/index.js +0 -15
  284. package/dest/node/bindgen/mappings.d.ts +0 -4
  285. package/dest/node/bindgen/mappings.d.ts.map +0 -1
  286. package/dest/node/bindgen/mappings.js +0 -64
  287. package/dest/node/bindgen/rust.d.ts +0 -2
  288. package/dest/node/bindgen/rust.d.ts.map +0 -1
  289. package/dest/node/bindgen/rust.js +0 -43
  290. package/dest/node/bindgen/to_camel_case.d.ts +0 -2
  291. package/dest/node/bindgen/to_camel_case.d.ts.map +0 -1
  292. package/dest/node/bindgen/to_camel_case.js +0 -11
  293. package/dest/node/bindgen/typescript.d.ts +0 -2
  294. package/dest/node/bindgen/typescript.d.ts.map +0 -1
  295. package/dest/node/bindgen/typescript.js +0 -100
  296. package/dest/node/cbind/generated/native.d.ts +0 -31
  297. package/dest/node/cbind/generated/native.d.ts.map +0 -1
  298. package/dest/node/cbind/generated/native.js +0 -234
  299. package/dest/node/main.d.ts +0 -13
  300. package/dest/node/main.d.ts.map +0 -1
  301. package/dest/node/main.js +0 -459
  302. package/dest/node/serialize/output_type.d.ts +0 -11
  303. package/dest/node/serialize/output_type.d.ts.map +0 -1
  304. package/dest/node/serialize/output_type.js +0 -44
  305. package/dest/node/types/fixed_size_buffer.d.ts +0 -26
  306. package/dest/node/types/fixed_size_buffer.d.ts.map +0 -1
  307. package/dest/node/types/fixed_size_buffer.js +0 -51
  308. package/dest/node/types/ptr.d.ts +0 -13
  309. package/dest/node/types/ptr.d.ts.map +0 -1
  310. package/dest/node/types/ptr.js +0 -19
  311. package/dest/node/types/raw_buffer.d.ts +0 -3
  312. package/dest/node/types/raw_buffer.d.ts.map +0 -1
  313. package/dest/node/types/raw_buffer.js +0 -5
  314. package/dest/node-cjs/barretenberg/common.test.d.ts +0 -2
  315. package/dest/node-cjs/barretenberg/common.test.d.ts.map +0 -1
  316. package/dest/node-cjs/barretenberg/common.test.js +0 -22
  317. package/dest/node-cjs/barretenberg_api/index.d.ts +0 -109
  318. package/dest/node-cjs/barretenberg_api/index.d.ts.map +0 -1
  319. package/dest/node-cjs/barretenberg_api/index.js +0 -704
  320. package/dest/node-cjs/bindgen/function_declaration.d.ts +0 -11
  321. package/dest/node-cjs/bindgen/function_declaration.d.ts.map +0 -1
  322. package/dest/node-cjs/bindgen/function_declaration.js +0 -3
  323. package/dest/node-cjs/bindgen/index.d.ts +0 -2
  324. package/dest/node-cjs/bindgen/index.d.ts.map +0 -1
  325. package/dest/node-cjs/bindgen/index.js +0 -17
  326. package/dest/node-cjs/bindgen/mappings.d.ts +0 -4
  327. package/dest/node-cjs/bindgen/mappings.d.ts.map +0 -1
  328. package/dest/node-cjs/bindgen/mappings.js +0 -69
  329. package/dest/node-cjs/bindgen/rust.d.ts +0 -2
  330. package/dest/node-cjs/bindgen/rust.d.ts.map +0 -1
  331. package/dest/node-cjs/bindgen/rust.js +0 -47
  332. package/dest/node-cjs/bindgen/to_camel_case.d.ts +0 -2
  333. package/dest/node-cjs/bindgen/to_camel_case.d.ts.map +0 -1
  334. package/dest/node-cjs/bindgen/to_camel_case.js +0 -14
  335. package/dest/node-cjs/bindgen/typescript.d.ts +0 -2
  336. package/dest/node-cjs/bindgen/typescript.d.ts.map +0 -1
  337. package/dest/node-cjs/bindgen/typescript.js +0 -104
  338. package/dest/node-cjs/cbind/generated/native.d.ts +0 -31
  339. package/dest/node-cjs/cbind/generated/native.d.ts.map +0 -1
  340. package/dest/node-cjs/cbind/generated/native.js +0 -238
  341. package/dest/node-cjs/main.d.ts +0 -13
  342. package/dest/node-cjs/main.d.ts.map +0 -1
  343. package/dest/node-cjs/main.js +0 -470
  344. package/dest/node-cjs/serialize/output_type.d.ts +0 -11
  345. package/dest/node-cjs/serialize/output_type.d.ts.map +0 -1
  346. package/dest/node-cjs/serialize/output_type.js +0 -51
  347. package/dest/node-cjs/types/fixed_size_buffer.d.ts +0 -26
  348. package/dest/node-cjs/types/fixed_size_buffer.d.ts.map +0 -1
  349. package/dest/node-cjs/types/fixed_size_buffer.js +0 -57
  350. package/dest/node-cjs/types/ptr.d.ts +0 -13
  351. package/dest/node-cjs/types/ptr.d.ts.map +0 -1
  352. package/dest/node-cjs/types/ptr.js +0 -23
  353. package/dest/node-cjs/types/raw_buffer.d.ts +0 -3
  354. package/dest/node-cjs/types/raw_buffer.d.ts.map +0 -1
  355. package/dest/node-cjs/types/raw_buffer.js +0 -9
  356. package/src/barretenberg/common.test.ts +0 -23
  357. package/src/barretenberg_api/index.ts +0 -1216
  358. package/src/bindgen/function_declaration.ts +0 -11
  359. package/src/bindgen/index.ts +0 -17
  360. package/src/bindgen/mappings.ts +0 -67
  361. package/src/bindgen/rust.ts +0 -52
  362. package/src/bindgen/to_camel_case.ts +0 -10
  363. package/src/bindgen/typescript.ts +0 -116
  364. package/src/main.ts +0 -534
  365. package/src/serialize/output_type.ts +0 -53
  366. package/src/types/fixed_size_buffer.ts +0 -59
  367. package/src/types/ptr.ts +0 -20
  368. 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,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
- }
@@ -1,59 +0,0 @@
1
- import { randomBytes } from '../random/index.js';
2
- import { BufferReader } from '../serialize/index.js';
3
-
4
- export class Buffer32 {
5
- static SIZE_IN_BYTES = 32;
6
-
7
- constructor(public readonly buffer: Uint8Array) {}
8
-
9
- static fromBuffer(buffer: Uint8Array | BufferReader) {
10
- const reader = BufferReader.asReader(buffer);
11
- return new Buffer32(reader.readBytes(this.SIZE_IN_BYTES));
12
- }
13
-
14
- static random() {
15
- return new Buffer32(randomBytes(this.SIZE_IN_BYTES));
16
- }
17
-
18
- toBuffer() {
19
- return this.buffer;
20
- }
21
- }
22
-
23
- export class Buffer64 {
24
- static SIZE_IN_BYTES = 64;
25
-
26
- constructor(public readonly buffer: Uint8Array) {}
27
-
28
- static fromBuffer(buffer: Uint8Array | BufferReader) {
29
- const reader = BufferReader.asReader(buffer);
30
- return new Buffer64(reader.readBytes(this.SIZE_IN_BYTES));
31
- }
32
-
33
- static random() {
34
- return new Buffer64(randomBytes(this.SIZE_IN_BYTES));
35
- }
36
-
37
- toBuffer() {
38
- return this.buffer;
39
- }
40
- }
41
-
42
- export class Buffer128 {
43
- static SIZE_IN_BYTES = 128;
44
-
45
- constructor(public readonly buffer: Uint8Array) {}
46
-
47
- static fromBuffer(buffer: Uint8Array | BufferReader) {
48
- const reader = BufferReader.asReader(buffer);
49
- return new Buffer128(reader.readBytes(this.SIZE_IN_BYTES));
50
- }
51
-
52
- static random() {
53
- return new Buffer128(randomBytes(this.SIZE_IN_BYTES));
54
- }
55
-
56
- toBuffer() {
57
- return this.buffer;
58
- }
59
- }
package/src/types/ptr.ts DELETED
@@ -1,20 +0,0 @@
1
- import { BufferReader } from '../serialize/index.js';
2
-
3
- /**
4
- * Holds an opaque pointer into WASM memory.
5
- * Currently only 4 bytes, but could grow to 8 bytes with wasm64.
6
- */
7
- export class Ptr {
8
- static SIZE_IN_BYTES = 4;
9
-
10
- constructor(public readonly value: Uint8Array) {}
11
-
12
- static fromBuffer(buffer: Uint8Array | BufferReader) {
13
- const reader = BufferReader.asReader(buffer);
14
- return new this(reader.readBytes(this.SIZE_IN_BYTES));
15
- }
16
-
17
- toBuffer() {
18
- return this.value;
19
- }
20
- }
@@ -1,3 +0,0 @@
1
- // Used when the data is to be sent exactly as is. i.e. no length prefix will be added.
2
- // This is useful for sending structured data that can be parsed-as-you-go, as opposed to just an array of bytes.
3
- export class RawBuffer extends Uint8Array {}