longfellow 0.1.0

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 (289) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +10 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +152 -0
  5. data/ext/longfellow/CMakeLists.txt +76 -0
  6. data/ext/longfellow/extconf.rb +77 -0
  7. data/lib/longfellow/attribute.rb +65 -0
  8. data/lib/longfellow/c.rb +105 -0
  9. data/lib/longfellow/errors.rb +78 -0
  10. data/lib/longfellow/version.rb +5 -0
  11. data/lib/longfellow/zk_spec.rb +40 -0
  12. data/lib/longfellow.rb +162 -0
  13. data/sig/longfellow.rbs +74 -0
  14. data/vendor/longfellow-zk/LICENSE +203 -0
  15. data/vendor/longfellow-zk/lib/algebra/blas.h +121 -0
  16. data/vendor/longfellow-zk/lib/algebra/bogorng.h +68 -0
  17. data/vendor/longfellow-zk/lib/algebra/compare.h +40 -0
  18. data/vendor/longfellow-zk/lib/algebra/convolution.h +219 -0
  19. data/vendor/longfellow-zk/lib/algebra/crt.cc +42 -0
  20. data/vendor/longfellow-zk/lib/algebra/crt.h +299 -0
  21. data/vendor/longfellow-zk/lib/algebra/crt_convolution.h +114 -0
  22. data/vendor/longfellow-zk/lib/algebra/crt_test.cc +371 -0
  23. data/vendor/longfellow-zk/lib/algebra/fft.h +104 -0
  24. data/vendor/longfellow-zk/lib/algebra/fft_interpolation.h +304 -0
  25. data/vendor/longfellow-zk/lib/algebra/fft_interpolation_test.cc +168 -0
  26. data/vendor/longfellow-zk/lib/algebra/fft_test.cc +257 -0
  27. data/vendor/longfellow-zk/lib/algebra/fp.h +59 -0
  28. data/vendor/longfellow-zk/lib/algebra/fp2.h +240 -0
  29. data/vendor/longfellow-zk/lib/algebra/fp24.h +342 -0
  30. data/vendor/longfellow-zk/lib/algebra/fp24_6.h +305 -0
  31. data/vendor/longfellow-zk/lib/algebra/fp24_6_test.cc +197 -0
  32. data/vendor/longfellow-zk/lib/algebra/fp2_test.cc +280 -0
  33. data/vendor/longfellow-zk/lib/algebra/fp_generic.h +533 -0
  34. data/vendor/longfellow-zk/lib/algebra/fp_p128.h +91 -0
  35. data/vendor/longfellow-zk/lib/algebra/fp_p256.h +68 -0
  36. data/vendor/longfellow-zk/lib/algebra/fp_p256k1.h +123 -0
  37. data/vendor/longfellow-zk/lib/algebra/fp_p384.h +65 -0
  38. data/vendor/longfellow-zk/lib/algebra/fp_p521.h +62 -0
  39. data/vendor/longfellow-zk/lib/algebra/fp_test.cc +522 -0
  40. data/vendor/longfellow-zk/lib/algebra/hash.h +39 -0
  41. data/vendor/longfellow-zk/lib/algebra/interpolation.h +117 -0
  42. data/vendor/longfellow-zk/lib/algebra/interpolation_test.cc +74 -0
  43. data/vendor/longfellow-zk/lib/algebra/limb.h +153 -0
  44. data/vendor/longfellow-zk/lib/algebra/limb_test.cc +75 -0
  45. data/vendor/longfellow-zk/lib/algebra/nat.cc +32 -0
  46. data/vendor/longfellow-zk/lib/algebra/nat.h +212 -0
  47. data/vendor/longfellow-zk/lib/algebra/nat_test.cc +183 -0
  48. data/vendor/longfellow-zk/lib/algebra/nussbaumer.h +400 -0
  49. data/vendor/longfellow-zk/lib/algebra/nussbaumer_test.cc +138 -0
  50. data/vendor/longfellow-zk/lib/algebra/nussbaumerfp2_test.cc +139 -0
  51. data/vendor/longfellow-zk/lib/algebra/permutations.h +79 -0
  52. data/vendor/longfellow-zk/lib/algebra/poly.h +240 -0
  53. data/vendor/longfellow-zk/lib/algebra/poly_test.cc +123 -0
  54. data/vendor/longfellow-zk/lib/algebra/reed_solomon.h +150 -0
  55. data/vendor/longfellow-zk/lib/algebra/reed_solomon_extension.h +108 -0
  56. data/vendor/longfellow-zk/lib/algebra/reed_solomon_extension_test.cc +76 -0
  57. data/vendor/longfellow-zk/lib/algebra/reed_solomon_test.cc +473 -0
  58. data/vendor/longfellow-zk/lib/algebra/rfft.h +400 -0
  59. data/vendor/longfellow-zk/lib/algebra/rfft_test.cc +102 -0
  60. data/vendor/longfellow-zk/lib/algebra/static_string.h +29 -0
  61. data/vendor/longfellow-zk/lib/algebra/sysdep.h +495 -0
  62. data/vendor/longfellow-zk/lib/algebra/sysdep_test.cc +41 -0
  63. data/vendor/longfellow-zk/lib/algebra/twiddle.h +59 -0
  64. data/vendor/longfellow-zk/lib/algebra/utility.h +86 -0
  65. data/vendor/longfellow-zk/lib/algebra/utility_test.cc +86 -0
  66. data/vendor/longfellow-zk/lib/arrays/affine.h +56 -0
  67. data/vendor/longfellow-zk/lib/arrays/affine_test.cc +220 -0
  68. data/vendor/longfellow-zk/lib/arrays/dense.h +210 -0
  69. data/vendor/longfellow-zk/lib/arrays/eq.h +75 -0
  70. data/vendor/longfellow-zk/lib/arrays/eqs.h +137 -0
  71. data/vendor/longfellow-zk/lib/arrays/eqs_test.cc +151 -0
  72. data/vendor/longfellow-zk/lib/arrays/sparse.h +192 -0
  73. data/vendor/longfellow-zk/lib/cbor/host_decoder.h +323 -0
  74. data/vendor/longfellow-zk/lib/cbor/host_decoder_test.cc +541 -0
  75. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor.h +594 -0
  76. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_byte_decoder.h +150 -0
  77. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_byte_decoder_test.cc +147 -0
  78. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_constants.h +27 -0
  79. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_pluck.h +110 -0
  80. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_pluck_test.cc +55 -0
  81. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_test.cc +174 -0
  82. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_testing.h +98 -0
  83. data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_witness.h +312 -0
  84. data/vendor/longfellow-zk/lib/circuits/cbor_parser/mso2_test.cc +662 -0
  85. data/vendor/longfellow-zk/lib/circuits/cbor_parser/mso_test.cc +485 -0
  86. data/vendor/longfellow-zk/lib/circuits/cbor_parser/scan.h +104 -0
  87. data/vendor/longfellow-zk/lib/circuits/cbor_parser/scan_test.cc +137 -0
  88. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor.h +640 -0
  89. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_byte_decoder.h +150 -0
  90. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_byte_decoder_test.cc +147 -0
  91. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_constants.h +27 -0
  92. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_testing.h +99 -0
  93. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_witness.h +319 -0
  94. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/lexer_test.cc +120 -0
  95. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/mdoc_examples_test.cc +89 -0
  96. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/parser_circuit_test.cc +506 -0
  97. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/parser_size_test.cc +79 -0
  98. data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/parser_test.cc +473 -0
  99. data/vendor/longfellow-zk/lib/circuits/compiler/canonicalization_test.cc +185 -0
  100. data/vendor/longfellow-zk/lib/circuits/compiler/circuit_dump.h +65 -0
  101. data/vendor/longfellow-zk/lib/circuits/compiler/compiler.h +471 -0
  102. data/vendor/longfellow-zk/lib/circuits/compiler/compiler_test.cc +110 -0
  103. data/vendor/longfellow-zk/lib/circuits/compiler/node.h +176 -0
  104. data/vendor/longfellow-zk/lib/circuits/compiler/pdqhash.h +127 -0
  105. data/vendor/longfellow-zk/lib/circuits/compiler/schedule.h +435 -0
  106. data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_circuit.h +371 -0
  107. data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_external_test.cc +246 -0
  108. data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_test.cc +587 -0
  109. data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_witness.h +201 -0
  110. data/vendor/longfellow-zk/lib/circuits/logic/bit_adder.h +140 -0
  111. data/vendor/longfellow-zk/lib/circuits/logic/bit_adder_test.cc +64 -0
  112. data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker.h +247 -0
  113. data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker_constants.h +35 -0
  114. data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker_encoder.h +72 -0
  115. data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker_test.cc +183 -0
  116. data/vendor/longfellow-zk/lib/circuits/logic/compiler_backend.h +62 -0
  117. data/vendor/longfellow-zk/lib/circuits/logic/counter.h +171 -0
  118. data/vendor/longfellow-zk/lib/circuits/logic/counter_test.cc +102 -0
  119. data/vendor/longfellow-zk/lib/circuits/logic/evaluation_backend.h +94 -0
  120. data/vendor/longfellow-zk/lib/circuits/logic/logic.h +1232 -0
  121. data/vendor/longfellow-zk/lib/circuits/logic/logic_circuit_test.cc +310 -0
  122. data/vendor/longfellow-zk/lib/circuits/logic/logic_test.cc +521 -0
  123. data/vendor/longfellow-zk/lib/circuits/logic/memcmp.h +68 -0
  124. data/vendor/longfellow-zk/lib/circuits/logic/memcmp_test.cc +148 -0
  125. data/vendor/longfellow-zk/lib/circuits/logic/polynomial.h +94 -0
  126. data/vendor/longfellow-zk/lib/circuits/logic/polynomial_test.cc +62 -0
  127. data/vendor/longfellow-zk/lib/circuits/logic/routing.h +445 -0
  128. data/vendor/longfellow-zk/lib/circuits/logic/routing_test.cc +241 -0
  129. data/vendor/longfellow-zk/lib/circuits/logic/unary.h +55 -0
  130. data/vendor/longfellow-zk/lib/circuits/logic/unary_plucker.h +77 -0
  131. data/vendor/longfellow-zk/lib/circuits/logic/unary_plucker_constants.h +37 -0
  132. data/vendor/longfellow-zk/lib/circuits/logic/unary_plucker_test.cc +53 -0
  133. data/vendor/longfellow-zk/lib/circuits/logic/unary_size_test.cc +69 -0
  134. data/vendor/longfellow-zk/lib/circuits/logic/unary_test.cc +62 -0
  135. data/vendor/longfellow-zk/lib/circuits/mac/mac_circuit.h +193 -0
  136. data/vendor/longfellow-zk/lib/circuits/mac/mac_circuit_test.cc +223 -0
  137. data/vendor/longfellow-zk/lib/circuits/mac/mac_reference.h +72 -0
  138. data/vendor/longfellow-zk/lib/circuits/mac/mac_witness.h +94 -0
  139. data/vendor/longfellow-zk/lib/circuits/mdoc/circuit_maker.cc +242 -0
  140. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_attribute_ids.h +311 -0
  141. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_attribute_test.cc +64 -0
  142. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_circuit_id.cc +85 -0
  143. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_constants.h +85 -0
  144. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_decompress.cc +41 -0
  145. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_decompress.h +27 -0
  146. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_examples.h +5232 -0
  147. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_generate_circuit.cc +199 -0
  148. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_hash.h +554 -0
  149. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_signature.h +143 -0
  150. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_signature_test.cc +444 -0
  151. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_test_attributes.h +157 -0
  152. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_witness.h +863 -0
  153. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_zk.cc +693 -0
  154. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_zk.h +216 -0
  155. data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_zk_test.cc +724 -0
  156. data/vendor/longfellow-zk/lib/circuits/mdoc/zk_spec.cc +100 -0
  157. data/vendor/longfellow-zk/lib/circuits/mdoc/zk_spec_test.cc +155 -0
  158. data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_circuit.h +330 -0
  159. data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_circuit_test.cc +607 -0
  160. data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_io.h +26 -0
  161. data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_witness.cc +163 -0
  162. data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_witness.h +47 -0
  163. data/vendor/longfellow-zk/lib/circuits/sha/sha256_constants.cc +34 -0
  164. data/vendor/longfellow-zk/lib/circuits/sha/sha256_constants.h +27 -0
  165. data/vendor/longfellow-zk/lib/circuits/sha/sha256_test_values.h +389 -0
  166. data/vendor/longfellow-zk/lib/circuits/tests/anoncred/ptrcred.h +171 -0
  167. data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small.h +218 -0
  168. data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_examples.h +118 -0
  169. data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_io.h +25 -0
  170. data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_test.cc +208 -0
  171. data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_witness.h +130 -0
  172. data/vendor/longfellow-zk/lib/circuits/tests/base64/decode.h +508 -0
  173. data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_circuit_test.cc +95 -0
  174. data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_test.cc +119 -0
  175. data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_util.cc +47 -0
  176. data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_util.h +29 -0
  177. data/vendor/longfellow-zk/lib/circuits/tests/ec/pk_circuit.h +231 -0
  178. data/vendor/longfellow-zk/lib/circuits/tests/ec/pk_circuit_test.cc +428 -0
  179. data/vendor/longfellow-zk/lib/circuits/tests/ec/pk_witness.h +102 -0
  180. data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt.h +190 -0
  181. data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt_constants.h +26 -0
  182. data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt_test.cc +559 -0
  183. data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt_witness.h +315 -0
  184. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f.h +411 -0
  185. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f_io.h +32 -0
  186. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f_test.cc +364 -0
  187. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f_witness.h +278 -0
  188. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation.h +146 -0
  189. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation_constants.h +25 -0
  190. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation_test.cc +315 -0
  191. data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation_witness.h +136 -0
  192. data/vendor/longfellow-zk/lib/circuits/tests/pq/bitaddr/bitaddr.h +250 -0
  193. data/vendor/longfellow-zk/lib/circuits/tests/pq/bitaddr/bitaddr_test.cc +333 -0
  194. data/vendor/longfellow-zk/lib/circuits/tests/pq/bitaddr/bitaddr_witness.h +152 -0
  195. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44.h +903 -0
  196. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_circuit_test.cc +274 -0
  197. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_eval_test.cc +440 -0
  198. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_examples.cc +8851 -0
  199. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_examples.h +93 -0
  200. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_types.cc +24 -0
  201. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_types.h +118 -0
  202. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_witness.h +453 -0
  203. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_witness_test.cc +49 -0
  204. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref.cc +458 -0
  205. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref.h +150 -0
  206. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test.cc +398 -0
  207. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test_vectors.inc +3618 -0
  208. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test_vectors_pkdecode.inc +689 -0
  209. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test_vectors_sigdecode.inc +1501 -0
  210. data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/sigdecode_test_vectors.inc +540 -0
  211. data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_circuit.h +394 -0
  212. data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_circuit_test.cc +577 -0
  213. data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_constants.h +90 -0
  214. data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_witness.cc +174 -0
  215. data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_witness.h +140 -0
  216. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_circuit.h +351 -0
  217. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_circuit_test.cc +466 -0
  218. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_reference.cc +207 -0
  219. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_reference.h +59 -0
  220. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_reference_test.cc +153 -0
  221. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_round_constants.cc +39 -0
  222. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_round_constants.h +29 -0
  223. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_slicing.h +31 -0
  224. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_witness.cc +83 -0
  225. data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_witness.h +72 -0
  226. data/vendor/longfellow-zk/lib/circuits/tests/sha3/shake_test_vectors.h +477 -0
  227. data/vendor/longfellow-zk/lib/ec/elliptic_curve.h +596 -0
  228. data/vendor/longfellow-zk/lib/ec/elliptic_curve_test.cc +548 -0
  229. data/vendor/longfellow-zk/lib/ec/p256.cc +36 -0
  230. data/vendor/longfellow-zk/lib/ec/p256.h +60 -0
  231. data/vendor/longfellow-zk/lib/ec/p256k1.cc +34 -0
  232. data/vendor/longfellow-zk/lib/ec/p256k1.h +60 -0
  233. data/vendor/longfellow-zk/lib/gf2k/gf2_128.h +503 -0
  234. data/vendor/longfellow-zk/lib/gf2k/gf2_128_bench.cc +48 -0
  235. data/vendor/longfellow-zk/lib/gf2k/gf2_128_test.cc +416 -0
  236. data/vendor/longfellow-zk/lib/gf2k/gf2poly.h +74 -0
  237. data/vendor/longfellow-zk/lib/gf2k/lch14.h +242 -0
  238. data/vendor/longfellow-zk/lib/gf2k/lch14_bench.cc +75 -0
  239. data/vendor/longfellow-zk/lib/gf2k/lch14_reed_solomon.h +127 -0
  240. data/vendor/longfellow-zk/lib/gf2k/lch14_reed_solomon_test.cc +110 -0
  241. data/vendor/longfellow-zk/lib/gf2k/lch14_test.cc +246 -0
  242. data/vendor/longfellow-zk/lib/gf2k/sysdep.h +329 -0
  243. data/vendor/longfellow-zk/lib/ligero/ligero_param.h +449 -0
  244. data/vendor/longfellow-zk/lib/ligero/ligero_prover.h +354 -0
  245. data/vendor/longfellow-zk/lib/ligero/ligero_test.cc +136 -0
  246. data/vendor/longfellow-zk/lib/ligero/ligero_transcript.h +67 -0
  247. data/vendor/longfellow-zk/lib/ligero/ligero_verifier.h +272 -0
  248. data/vendor/longfellow-zk/lib/merkle/merkle_commitment.h +104 -0
  249. data/vendor/longfellow-zk/lib/merkle/merkle_tree.h +216 -0
  250. data/vendor/longfellow-zk/lib/merkle/merkle_tree_test.cc +240 -0
  251. data/vendor/longfellow-zk/lib/proto/circuit.h +354 -0
  252. data/vendor/longfellow-zk/lib/proto/circuit_test.cc +202 -0
  253. data/vendor/longfellow-zk/lib/random/random.h +119 -0
  254. data/vendor/longfellow-zk/lib/random/random_test.cc +189 -0
  255. data/vendor/longfellow-zk/lib/random/secure_random_engine.h +37 -0
  256. data/vendor/longfellow-zk/lib/random/transcript.h +193 -0
  257. data/vendor/longfellow-zk/lib/random/transcript_test.cc +344 -0
  258. data/vendor/longfellow-zk/lib/sumcheck/circuit.h +148 -0
  259. data/vendor/longfellow-zk/lib/sumcheck/circuit_id.h +71 -0
  260. data/vendor/longfellow-zk/lib/sumcheck/equad.h +126 -0
  261. data/vendor/longfellow-zk/lib/sumcheck/hquad.h +115 -0
  262. data/vendor/longfellow-zk/lib/sumcheck/prover.h +59 -0
  263. data/vendor/longfellow-zk/lib/sumcheck/prover_layers.h +362 -0
  264. data/vendor/longfellow-zk/lib/sumcheck/quad.h +227 -0
  265. data/vendor/longfellow-zk/lib/sumcheck/quad_builder.h +211 -0
  266. data/vendor/longfellow-zk/lib/sumcheck/quad_test.cc +169 -0
  267. data/vendor/longfellow-zk/lib/sumcheck/sumcheck_test.cc +324 -0
  268. data/vendor/longfellow-zk/lib/sumcheck/testing.h +69 -0
  269. data/vendor/longfellow-zk/lib/sumcheck/transcript_sumcheck.h +85 -0
  270. data/vendor/longfellow-zk/lib/sumcheck/verifier.h +84 -0
  271. data/vendor/longfellow-zk/lib/sumcheck/verifier_layers.h +221 -0
  272. data/vendor/longfellow-zk/lib/testing/test_main.cc +50 -0
  273. data/vendor/longfellow-zk/lib/util/ceildiv.h +164 -0
  274. data/vendor/longfellow-zk/lib/util/ceildiv_test.cc +152 -0
  275. data/vendor/longfellow-zk/lib/util/crc64.h +45 -0
  276. data/vendor/longfellow-zk/lib/util/crypto.cc +39 -0
  277. data/vendor/longfellow-zk/lib/util/crypto.h +108 -0
  278. data/vendor/longfellow-zk/lib/util/log.cc +110 -0
  279. data/vendor/longfellow-zk/lib/util/log.h +33 -0
  280. data/vendor/longfellow-zk/lib/util/panic.h +40 -0
  281. data/vendor/longfellow-zk/lib/util/readbuffer.h +67 -0
  282. data/vendor/longfellow-zk/lib/util/serialization.h +54 -0
  283. data/vendor/longfellow-zk/lib/zk/zk_common.h +455 -0
  284. data/vendor/longfellow-zk/lib/zk/zk_proof.h +378 -0
  285. data/vendor/longfellow-zk/lib/zk/zk_prover.h +202 -0
  286. data/vendor/longfellow-zk/lib/zk/zk_test.cc +340 -0
  287. data/vendor/longfellow-zk/lib/zk/zk_testing.h +154 -0
  288. data/vendor/longfellow-zk/lib/zk/zk_verifier.h +109 -0
  289. metadata +347 -0
@@ -0,0 +1,146 @@
1
+ // Copyright 2026 Google LLC.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_H_
16
+ #define PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_H_
17
+
18
+ #include <cstddef>
19
+
20
+ #include "circuits/ecdsa/verify_circuit.h"
21
+ #include "circuits/logic/bit_plucker.h"
22
+ #include "circuits/sha/flatsha256_circuit.h"
23
+ #include "circuits/tests/mdoc/mdoc_revocation_constants.h"
24
+
25
+ namespace proofs {
26
+
27
+ // The first revocation approach works for small lists that are expected to
28
+ // be small. In this case, the prover simply asserts that their identifier is
29
+ // different from all the identifiers in the list.
30
+ template <class LogicCircuit>
31
+ class MdocRevocationList {
32
+ using EltW = typename LogicCircuit::EltW;
33
+
34
+ public:
35
+ explicit MdocRevocationList(const LogicCircuit& lc) : lc_(lc) {}
36
+
37
+ // This function asserts that a given identifier is not on a revocation list.
38
+ // The method is to assert that Prod_i (list[i) - id) != 0.
39
+ void assert_not_on_list(EltW list[], size_t list_size,
40
+ /* the witness */ EltW id, EltW prodinv) const {
41
+ EltW prod =
42
+ lc_.mul(0, list_size, [&](size_t i) { return lc_.sub(list[i], id); });
43
+ EltW want_one = lc_.mul(prod, prodinv);
44
+ lc_.assert_eq(want_one, lc_.konst(lc_.one()));
45
+ }
46
+
47
+ const LogicCircuit& lc_;
48
+ };
49
+
50
+ // The second revocation approach works for larger lists. In this case, the
51
+ // prover retrieves a witness that their credential is *not* on the revoked
52
+ // list by presenting a signature of the span (l,r) and proving that their
53
+ // revocation identifier rev_id satisfied l < rev_id < r.
54
+ // Specifically, the format of the span is:
55
+ // epoch || l || r
56
+ // where epoch is a 64 bit integer, l and r are 256 bit integers. All of
57
+ // the values are encoded in little endian order.
58
+ template <class LogicCircuit, class Field, class EC>
59
+ class MdocRevocationSpan {
60
+ using EltW = typename LogicCircuit::EltW;
61
+ using Nat = typename Field::N;
62
+ using Ecdsa = VerifyCircuit<LogicCircuit, Field, EC>;
63
+ using EcdsaWitness = typename Ecdsa::Witness;
64
+ using v8 = typename LogicCircuit::v8;
65
+ using v256 = typename LogicCircuit::v256;
66
+ using Flatsha =
67
+ FlatSHA256Circuit<LogicCircuit,
68
+ BitPlucker<LogicCircuit, kSHARevocationPluckerBits>>;
69
+ using ShaBlockWitness = typename Flatsha::BlockWitness;
70
+ using sha_packed_v32 = typename Flatsha::packed_v32;
71
+
72
+ public:
73
+ class Witness {
74
+ public:
75
+ EltW r_, s_, e_;
76
+ EcdsaWitness rev_sig_;
77
+ v8 preimage_[64 * 2]; // epoch || l || r in little endian order
78
+ v256 id_bits_;
79
+ v256 e_bits_;
80
+ ShaBlockWitness sha_[2];
81
+
82
+ void input(const LogicCircuit& lc) {
83
+ r_ = lc.eltw_input();
84
+ s_ = lc.eltw_input();
85
+ e_ = lc.eltw_input();
86
+ rev_sig_.input(lc);
87
+ for (size_t i = 0; i < 64 * 2; ++i) {
88
+ preimage_[i] = lc.template vinput<8>();
89
+ }
90
+ id_bits_ = lc.template vinput<256>();
91
+ e_bits_ = lc.template vinput<256>();
92
+ for (size_t j = 0; j < 2; j++) {
93
+ sha_[j].input(lc);
94
+ }
95
+ }
96
+ };
97
+
98
+ explicit MdocRevocationSpan(const LogicCircuit& lc, const EC& ec,
99
+ const Nat& order)
100
+ : lc_(lc), ec_(ec), order_(order), sha_(lc) {}
101
+
102
+ // This function asserts that id is not on the revocation list by verifying
103
+ // that the signature (r,s) on the span (l,r) is valid, and then verifying
104
+ // that l < id < r. The argument (craPkX, craPkY) represent the public key
105
+ // of the issuer of the revocation list.
106
+ void assert_not_on_list(EltW craPkx, EltW craPkY,
107
+ /* the witness */ EltW id, Witness& vw) const {
108
+ Ecdsa ecc(lc_, ec_, order_);
109
+
110
+ ecc.verify_signature3(craPkx, craPkY, vw.e_, vw.rev_sig_);
111
+
112
+ lc_.vassert_is_bit(vw.e_bits_);
113
+ lc_.vassert_is_bit(vw.id_bits_);
114
+
115
+ // Check that e = hash(epoch || l || r)
116
+ auto two = lc_.template vbit<8>(2);
117
+ sha_.assert_message_hash(2, two, vw.preimage_, vw.e_bits_, vw.sha_);
118
+
119
+ // Check that the bits of e match the EltW for e.
120
+ auto twok = lc_.one();
121
+ auto est = lc_.konst(0);
122
+ for (size_t i = 0; i < 256; ++i) {
123
+ est = lc_.axpy(est, twok, lc_.eval(vw.e_bits_[i]));
124
+ lc_.f_.add(twok, twok);
125
+ }
126
+ lc_.assert_eq(est, vw.e_);
127
+
128
+ // // Check that l < id < r
129
+ v256 ll, rr;
130
+ for (size_t i = 0; i < 256; ++i) {
131
+ ll[i] = vw.preimage_[8 + i / 8][i % 8];
132
+ rr[i] = vw.preimage_[40 + i / 8][i % 8];
133
+ }
134
+ lc_.assert1(lc_.vlt(ll, vw.id_bits_));
135
+ lc_.assert1(lc_.vlt(vw.id_bits_, rr));
136
+ }
137
+
138
+ const LogicCircuit& lc_;
139
+ const EC& ec_;
140
+ const Nat& order_;
141
+ Flatsha sha_;
142
+ };
143
+
144
+ } // namespace proofs
145
+
146
+ #endif // PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_H_
@@ -0,0 +1,25 @@
1
+ // Copyright 2026 Google LLC.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_CONSTANTS_H_
16
+ #define PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_CONSTANTS_H_
17
+
18
+ #include <cstddef>
19
+ namespace proofs {
20
+
21
+ static constexpr size_t kSHARevocationPluckerBits = 4u;
22
+
23
+ } // namespace proofs
24
+
25
+ #endif // PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_CONSTANTS_H_
@@ -0,0 +1,315 @@
1
+ // Copyright 2026 Google LLC.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include "circuits/tests/mdoc/mdoc_revocation.h"
16
+
17
+ #include <cstddef>
18
+ #include <cstdint>
19
+ #include <memory>
20
+ #include <vector>
21
+
22
+ #include "algebra/convolution.h"
23
+ #include "algebra/fp2.h"
24
+ #include "algebra/reed_solomon.h"
25
+ #include "algebra/static_string.h"
26
+ #include "arrays/dense.h"
27
+ #include "circuits/compiler/circuit_dump.h"
28
+ #include "circuits/compiler/compiler.h"
29
+ #include "circuits/logic/compiler_backend.h"
30
+ #include "circuits/logic/logic.h"
31
+ #include "circuits/tests/mdoc/mdoc_revocation_witness.h"
32
+ #include "ec/p256.h"
33
+ #include "random/secure_random_engine.h"
34
+ #include "random/transcript.h"
35
+ #include "sumcheck/circuit.h"
36
+ #include "util/log.h"
37
+ #include "util/panic.h"
38
+ #include "zk/zk_proof.h"
39
+ #include "zk/zk_prover.h"
40
+ #include "zk/zk_testing.h"
41
+ #include "benchmark/benchmark.h"
42
+ #include "gtest/gtest.h"
43
+
44
+ namespace proofs {
45
+ namespace {
46
+
47
+ TEST(mdoc, mdoc_revocation_list_test) {
48
+ using Elt = Fp256Base::Elt;
49
+ set_log_level(INFO);
50
+
51
+ constexpr size_t kListSize = 50000;
52
+
53
+ std::unique_ptr<Circuit<Fp256Base>> CIRCUIT;
54
+
55
+ // ======== compile time =========================
56
+ {
57
+ using CompilerBackend = CompilerBackend<Fp256Base>;
58
+ using LogicCircuit = Logic<Fp256Base, CompilerBackend>;
59
+ using EltW = LogicCircuit::EltW;
60
+ using MdocRevocation = MdocRevocationList<LogicCircuit>;
61
+ QuadCircuit<Fp256Base> Q(p256_base);
62
+ const CompilerBackend cbk(&Q);
63
+ const LogicCircuit LC(&cbk, p256_base);
64
+
65
+ MdocRevocation mdr(LC);
66
+ EltW list[kListSize];
67
+ for (size_t i = 0; i < kListSize; ++i) {
68
+ list[i] = LC.eltw_input();
69
+ }
70
+
71
+ Q.private_input();
72
+ EltW id = LC.eltw_input();
73
+ EltW inv = LC.eltw_input();
74
+
75
+ mdr.assert_not_on_list(list, kListSize, id, inv);
76
+
77
+ CIRCUIT = Q.mkcircuit(/*nc=*/1);
78
+ dump_info("mdoc revocation list", Q);
79
+ log(INFO, "Compile done");
80
+ }
81
+
82
+ // ======== Witness
83
+ // Generate a witness from the mdoc data structure to remain close
84
+ // to the application use case.
85
+ std::vector<Elt> list(kListSize);
86
+ SecureRandomEngine rng;
87
+ Elt id = rng.elt(p256_base);
88
+ for (size_t i = 0; i < kListSize; ++i) {
89
+ list[i] = rng.elt(p256_base);
90
+ }
91
+ Elt prodinv = compute_mdoc_revocation_list_witness(id, list.data(), kListSize,
92
+ p256_base);
93
+
94
+ // ========= Fill witness
95
+ auto W = Dense<Fp256Base>(1, CIRCUIT->ninputs);
96
+ auto pub = Dense<Fp256Base>(1, CIRCUIT->npub_in);
97
+ DenseFiller<Fp256Base> filler(W);
98
+ DenseFiller<Fp256Base> pub_filler(pub);
99
+
100
+ filler.push_back(p256_base.one());
101
+ pub_filler.push_back(p256_base.one());
102
+ for (size_t i = 0; i < kListSize; ++i) {
103
+ filler.push_back(list[i]);
104
+ pub_filler.push_back(list[i]);
105
+ }
106
+
107
+ filler.push_back(id);
108
+ filler.push_back(prodinv);
109
+
110
+ log(INFO, "Fill done");
111
+
112
+ // =========== ZK test
113
+ run2_test_zk(
114
+ *CIRCUIT, W, pub, p256_base,
115
+ p256_base.of_string("1126492241464102818735004576096902583730188404304894"
116
+ "08729223714171582664680802"), /* omega_x*/
117
+ p256_base.of_string("8408799435854090769574046142781866056018216899718237"
118
+ "8749313018254450460212908"), /* omega_y */
119
+ 1ull << 31);
120
+ }
121
+
122
+ typedef struct {
123
+ StaticString pkx, pky; /* public key of the crl issuer */
124
+ StaticString left, right;
125
+ StaticString id;
126
+ uint64_t epoch;
127
+ StaticString e, r, s; /* sig on the span*/
128
+ } MdocRevocationSpanTests;
129
+
130
+ static const MdocRevocationSpanTests span_tests[] = {
131
+ {
132
+ StaticString("0x3cef945f99f65a1fd5d917a4783dc4fc6078a723aae8bfee0e472e1"
133
+ "0b43d3b91"),
134
+ StaticString("0x82480a801559d9bce4bf413e641178e64370ea80504f15f7b1efb10"
135
+ "56a784789"),
136
+ StaticString("0x7fff"), /* left */
137
+ StaticString("0x2f6038b853cf3ae407fb1a9845ea98ca5251fb41d088bb0bce5667d"
138
+ "25e9a1052"), /* right */
139
+ StaticString("0x2f6038b853cf3ae407fb1a9845ea98ca5251fb41d088bb0bce5667d"
140
+ "25e9a1051"), /* id */
141
+ 1025, /* epoch */
142
+ StaticString("0xa771beecd93838ed1a68e017b78a6d930153d2375158398ffe7cabf"
143
+ "8e591044c"),
144
+ StaticString("0xc6e44683a459281f7cd07ce05a5c9d389659925aef90fa950a7007b"
145
+ "08a0adec9"),
146
+ StaticString("0x35b3fc87f6e755acebc61efee92b1c6c6af68cdcb2c20ea9b1cbf8c"
147
+ "d11aae4d9"),
148
+ },
149
+ };
150
+
151
+ std::unique_ptr<Circuit<Fp256Base>> make_circuit(const Fp256Base& f) {
152
+ using CompilerBackend = CompilerBackend<Fp256Base>;
153
+ using LogicCircuit = Logic<Fp256Base, CompilerBackend>;
154
+ using MdocRevocation = MdocRevocationSpan<LogicCircuit, Fp256Base, P256>;
155
+ using EltW = LogicCircuit::EltW;
156
+
157
+ QuadCircuit<Fp256Base> Q(p256_base);
158
+ const CompilerBackend cbk(&Q);
159
+ const LogicCircuit lc(&cbk, p256_base);
160
+
161
+ MdocRevocation mdspan(lc, p256, n256_order);
162
+ EltW crapkX, crapkY;
163
+ crapkX = lc.eltw_input();
164
+ crapkY = lc.eltw_input();
165
+
166
+ Q.private_input();
167
+ EltW id = lc.eltw_input();
168
+ typename MdocRevocation::Witness vwc;
169
+ vwc.input(lc);
170
+
171
+ mdspan.assert_not_on_list(crapkX, crapkY, id, vwc);
172
+
173
+ auto CIRCUIT = Q.mkcircuit(/*nc=*/1);
174
+ dump_info("mdoc revocation list", Q);
175
+
176
+ return CIRCUIT;
177
+ }
178
+
179
+ void fill_input(Dense<Fp256Base>& W, const Fp256Base& f, bool prover = true) {
180
+ using Nat = Fp256Base::N;
181
+ using Elt = Fp256Base::Elt;
182
+ using SpanWitness = MdocRevocationSpanWitness<P256, Fp256Scalar>;
183
+
184
+ SpanWitness sw(p256, p256_scalar);
185
+ size_t t_ind = 0;
186
+ Elt pkX = p256_base.of_string(span_tests[t_ind].pkx);
187
+ Elt pkY = p256_base.of_string(span_tests[t_ind].pky);
188
+ Nat ne(span_tests[t_ind].e);
189
+ Nat nr(span_tests[t_ind].r);
190
+ Nat ns(span_tests[t_ind].s);
191
+ Nat id(span_tests[t_ind].id);
192
+ Nat ll(span_tests[t_ind].left);
193
+ Nat rr(span_tests[t_ind].right);
194
+ uint64_t epoch = span_tests[t_ind].epoch;
195
+ bool ok = sw.compute_witness(pkX, pkY, ne, nr, ns, id, ll, rr, epoch);
196
+
197
+ check(ok, "Could not compute signature witness");
198
+
199
+ // ========= Fill witness
200
+ DenseFiller<Fp256Base> filler(W);
201
+ filler.push_back(p256_base.one());
202
+ filler.push_back(pkX);
203
+ filler.push_back(pkY);
204
+
205
+ if (prover) {
206
+ filler.push_back(p256_base.to_montgomery(id));
207
+ sw.fill_witness(filler);
208
+ }
209
+ log(INFO, "Fill done");
210
+ }
211
+
212
+ TEST(mdoc, mdoc_revocation_span_test) {
213
+ using Elt = Fp256Base::Elt;
214
+ using Nat = Fp256Base::N;
215
+ using SpanWitness = MdocRevocationSpanWitness<P256, Fp256Scalar>;
216
+
217
+ set_log_level(INFO);
218
+
219
+ std::unique_ptr<Circuit<Fp256Base>> CIRCUIT = make_circuit(p256_base);
220
+
221
+ // ======== Witness
222
+ // Generate a witness from the mdoc data structure to remain close
223
+ // to the application use case.
224
+ SpanWitness sw(p256, p256_scalar);
225
+ size_t t_ind = 0;
226
+ Elt pkX = p256_base.of_string(span_tests[t_ind].pkx);
227
+ Elt pkY = p256_base.of_string(span_tests[t_ind].pky);
228
+ Nat ne(span_tests[t_ind].e);
229
+ Nat nr(span_tests[t_ind].r);
230
+ Nat ns(span_tests[t_ind].s);
231
+ Nat id(span_tests[t_ind].id);
232
+ Nat ll(span_tests[t_ind].left);
233
+ Nat rr(span_tests[t_ind].right);
234
+ uint64_t epoch = span_tests[t_ind].epoch;
235
+
236
+ bool ok = sw.compute_witness(pkX, pkY, ne, nr, ns, id, ll, rr, epoch);
237
+
238
+ check(ok, "Could not compute signature witness");
239
+
240
+ // ========= Fill witness
241
+ auto W = Dense<Fp256Base>(1, CIRCUIT->ninputs);
242
+ auto pub = Dense<Fp256Base>(1, CIRCUIT->npub_in);
243
+ DenseFiller<Fp256Base> filler(W);
244
+ DenseFiller<Fp256Base> pub_filler(pub);
245
+
246
+ filler.push_back(p256_base.one());
247
+ pub_filler.push_back(p256_base.one());
248
+
249
+ filler.push_back(pkX);
250
+ pub_filler.push_back(pkX);
251
+ filler.push_back(pkY);
252
+ pub_filler.push_back(pkY);
253
+
254
+ filler.push_back(p256_base.to_montgomery(id));
255
+ sw.fill_witness(filler);
256
+ log(INFO, "Fill done");
257
+
258
+ // =========== ZK test
259
+ run2_test_zk(
260
+ *CIRCUIT, W, pub, p256_base,
261
+ p256_base.of_string("1126492241464102818735004576096902583730188404304894"
262
+ "08729223714171582664680802"), /* omega_x*/
263
+ p256_base.of_string("8408799435854090769574046142781866056018216899718237"
264
+ "8749313018254450460212908"), /* omega_y */
265
+ 1ull << 31);
266
+ }
267
+
268
+ // ============ Benchmarks ====================================================
269
+ //
270
+ // To run the benchmarks:
271
+ //
272
+ // blaze run -c opt --dynamic_mode=off --copt=-gmlt \
273
+ // //circuits/mdoc:mdoc_revocation_test --
274
+ // --benchmark_filter=all
275
+ //
276
+
277
+ void BM_MdocRevocationProver(benchmark::State& state) {
278
+ std::unique_ptr<Circuit<Fp256Base>> CIRCUIT = make_circuit(p256_base);
279
+
280
+ auto W = Dense<Fp256Base>(1, CIRCUIT->ninputs);
281
+
282
+ fill_input(W, p256_base);
283
+
284
+ using f2_p256 = Fp2<Fp256Base>;
285
+ using Elt2 = f2_p256::Elt;
286
+ using FftExtConvolutionFactory = FFTExtConvolutionFactory<Fp256Base, f2_p256>;
287
+ using RSFactory = ReedSolomonFactory<Fp256Base, FftExtConvolutionFactory>;
288
+ const f2_p256 p256_2(p256_base);
289
+
290
+ // Root of unity for the f_p256^2 extension field.
291
+ static constexpr char kRootX[] =
292
+ "112649224146410281873500457609690258373018840430489408729223714171582664"
293
+ "680802";
294
+ static constexpr char kRootY[] =
295
+ "840879943585409076957404614278186605601821689971823787493130182544504602"
296
+ "12908";
297
+ const Elt2 omega = p256_2.of_string(kRootX, kRootY);
298
+ const FftExtConvolutionFactory fft_b(p256_base, p256_2, omega, 1ull << 31);
299
+ const RSFactory rsf(fft_b, p256_base);
300
+
301
+ Transcript tp((uint8_t*)"test", 4);
302
+ SecureRandomEngine rng;
303
+
304
+ ZkProof<Fp256Base> zkpr(*CIRCUIT, 4, 128);
305
+ ZkProver<Fp256Base, RSFactory> prover(*CIRCUIT, p256_base, rsf);
306
+
307
+ for (auto s : state) {
308
+ prover.commit(zkpr, W, tp, rng);
309
+ prover.prove(zkpr, W, tp);
310
+ }
311
+ }
312
+ BENCHMARK(BM_MdocRevocationProver);
313
+
314
+ } // namespace
315
+ } // namespace proofs
@@ -0,0 +1,136 @@
1
+ // Copyright 2026 Google LLC.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_WITNESS_H_
16
+ #define PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_WITNESS_H_
17
+
18
+ #include <cstddef>
19
+ #include <cstdint>
20
+ #include <cstdio>
21
+ #include <vector>
22
+
23
+ #include "arrays/dense.h"
24
+ #include "circuits/ecdsa/verify_witness.h"
25
+ #include "circuits/logic/bit_plucker_encoder.h"
26
+ #include "circuits/sha/flatsha256_witness.h"
27
+ #include "circuits/tests/mdoc/mdoc_revocation_constants.h"
28
+
29
+ namespace proofs {
30
+
31
+ template <class Field>
32
+ typename Field::Elt compute_mdoc_revocation_list_witness(
33
+ typename Field::Elt id, const typename Field::Elt list[], size_t list_size,
34
+ const Field& F) {
35
+ typename Field::Elt prodinv = F.one();
36
+ for (size_t i = 0; i < list_size; ++i) {
37
+ prodinv = F.mulf(prodinv, F.subf(list[i], id));
38
+ }
39
+ F.invert(prodinv);
40
+ return prodinv;
41
+ }
42
+
43
+ template <class EC, class ScalarField>
44
+ class MdocRevocationSpanWitness {
45
+ using Field = typename EC::Field;
46
+ using Elt = typename Field::Elt;
47
+ using Nat = typename Field::N;
48
+ using EcdsaWitness = VerifyWitness3<EC, ScalarField>;
49
+ const EC& ec_;
50
+
51
+ public:
52
+ Elt e_, r_, s_;
53
+ EcdsaWitness sig_;
54
+ uint8_t preimage_[64 * 2];
55
+ uint8_t id_bits_[256];
56
+ uint8_t e_bits_[256];
57
+ FlatSHA256Witness::BlockWitness sha_bw_[2];
58
+
59
+ explicit MdocRevocationSpanWitness(const EC& ec, const ScalarField& Fn)
60
+ : ec_(ec), sig_(Fn, ec) {}
61
+
62
+ void fill_witness(DenseFiller<Field>& filler) const {
63
+ filler.push_back(r_);
64
+ filler.push_back(s_);
65
+ filler.push_back(e_);
66
+ sig_.fill_witness(filler);
67
+
68
+ // Write the span message.
69
+ for (size_t i = 0; i < 64 * 2; ++i) {
70
+ for (size_t j = 0; j < 8; ++j) {
71
+ filler.push_back((preimage_[i] >> j) & 0x1 ? ec_.f_.one()
72
+ : ec_.f_.zero());
73
+ }
74
+ }
75
+
76
+ for (size_t i = 0; i < 256; ++i) {
77
+ filler.push_back(id_bits_[i] ? ec_.f_.one() : ec_.f_.zero());
78
+ }
79
+ for (size_t i = 0; i < 256; ++i) {
80
+ filler.push_back(e_bits_[i] ? ec_.f_.one() : ec_.f_.zero());
81
+ }
82
+
83
+ for (size_t j = 0; j < 2; j++) {
84
+ fill_sha(filler, sha_bw_[j]);
85
+ }
86
+ }
87
+
88
+ void fill_sha(DenseFiller<Field>& filler,
89
+ const FlatSHA256Witness::BlockWitness& bw) const {
90
+ BitPluckerEncoder<Field, kSHARevocationPluckerBits> BPENC(ec_.f_);
91
+ for (size_t k = 0; k < 48; ++k) {
92
+ filler.push_back(BPENC.mkpacked_v32(bw.outw[k]));
93
+ }
94
+ for (size_t k = 0; k < 64; ++k) {
95
+ filler.push_back(BPENC.mkpacked_v32(bw.oute[k]));
96
+ filler.push_back(BPENC.mkpacked_v32(bw.outa[k]));
97
+ }
98
+ for (size_t k = 0; k < 8; ++k) {
99
+ filler.push_back(BPENC.mkpacked_v32(bw.h1[k]));
100
+ }
101
+ }
102
+
103
+ bool compute_witness(Elt pkX, Elt pkY, Nat ne, Nat nr, Nat ns, Nat id, Nat ll,
104
+ Nat rr, uint64_t epoch) {
105
+ e_ = ec_.f_.to_montgomery(ne);
106
+ r_ = ec_.f_.to_montgomery(nr);
107
+ s_ = ec_.f_.to_montgomery(ns);
108
+ sig_.compute_witness(pkX, pkY, ne, nr, ns);
109
+
110
+ std::vector<uint8_t> buf;
111
+ for (size_t i = 0; i < 8; ++i) {
112
+ buf.push_back(epoch & 0xff);
113
+ epoch >>= 8;
114
+ }
115
+ uint8_t tmp[Field::kBytes];
116
+ ll.to_bytes(tmp);
117
+ buf.insert(buf.end(), tmp, tmp + Field::kBytes);
118
+ rr.to_bytes(tmp);
119
+ buf.insert(buf.end(), tmp, tmp + Field::kBytes);
120
+
121
+ for (size_t i = 0; i < 256; ++i) {
122
+ id_bits_[i] = id.bit(i);
123
+ e_bits_[i] = ne.bit(i);
124
+ }
125
+
126
+ uint8_t numb = 0;
127
+ FlatSHA256Witness::transform_and_witness_message(buf.size(), buf.data(), 2,
128
+ numb, preimage_, sha_bw_);
129
+
130
+ return true;
131
+ }
132
+ };
133
+
134
+ } // namespace proofs
135
+
136
+ #endif // PRIVACY_PROOFS_ZK_LIB_CIRCUITS_TESTS_MDOC_MDOC_REVOCATION_WITNESS_H_