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.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +152 -0
- data/ext/longfellow/CMakeLists.txt +76 -0
- data/ext/longfellow/extconf.rb +77 -0
- data/lib/longfellow/attribute.rb +65 -0
- data/lib/longfellow/c.rb +105 -0
- data/lib/longfellow/errors.rb +78 -0
- data/lib/longfellow/version.rb +5 -0
- data/lib/longfellow/zk_spec.rb +40 -0
- data/lib/longfellow.rb +162 -0
- data/sig/longfellow.rbs +74 -0
- data/vendor/longfellow-zk/LICENSE +203 -0
- data/vendor/longfellow-zk/lib/algebra/blas.h +121 -0
- data/vendor/longfellow-zk/lib/algebra/bogorng.h +68 -0
- data/vendor/longfellow-zk/lib/algebra/compare.h +40 -0
- data/vendor/longfellow-zk/lib/algebra/convolution.h +219 -0
- data/vendor/longfellow-zk/lib/algebra/crt.cc +42 -0
- data/vendor/longfellow-zk/lib/algebra/crt.h +299 -0
- data/vendor/longfellow-zk/lib/algebra/crt_convolution.h +114 -0
- data/vendor/longfellow-zk/lib/algebra/crt_test.cc +371 -0
- data/vendor/longfellow-zk/lib/algebra/fft.h +104 -0
- data/vendor/longfellow-zk/lib/algebra/fft_interpolation.h +304 -0
- data/vendor/longfellow-zk/lib/algebra/fft_interpolation_test.cc +168 -0
- data/vendor/longfellow-zk/lib/algebra/fft_test.cc +257 -0
- data/vendor/longfellow-zk/lib/algebra/fp.h +59 -0
- data/vendor/longfellow-zk/lib/algebra/fp2.h +240 -0
- data/vendor/longfellow-zk/lib/algebra/fp24.h +342 -0
- data/vendor/longfellow-zk/lib/algebra/fp24_6.h +305 -0
- data/vendor/longfellow-zk/lib/algebra/fp24_6_test.cc +197 -0
- data/vendor/longfellow-zk/lib/algebra/fp2_test.cc +280 -0
- data/vendor/longfellow-zk/lib/algebra/fp_generic.h +533 -0
- data/vendor/longfellow-zk/lib/algebra/fp_p128.h +91 -0
- data/vendor/longfellow-zk/lib/algebra/fp_p256.h +68 -0
- data/vendor/longfellow-zk/lib/algebra/fp_p256k1.h +123 -0
- data/vendor/longfellow-zk/lib/algebra/fp_p384.h +65 -0
- data/vendor/longfellow-zk/lib/algebra/fp_p521.h +62 -0
- data/vendor/longfellow-zk/lib/algebra/fp_test.cc +522 -0
- data/vendor/longfellow-zk/lib/algebra/hash.h +39 -0
- data/vendor/longfellow-zk/lib/algebra/interpolation.h +117 -0
- data/vendor/longfellow-zk/lib/algebra/interpolation_test.cc +74 -0
- data/vendor/longfellow-zk/lib/algebra/limb.h +153 -0
- data/vendor/longfellow-zk/lib/algebra/limb_test.cc +75 -0
- data/vendor/longfellow-zk/lib/algebra/nat.cc +32 -0
- data/vendor/longfellow-zk/lib/algebra/nat.h +212 -0
- data/vendor/longfellow-zk/lib/algebra/nat_test.cc +183 -0
- data/vendor/longfellow-zk/lib/algebra/nussbaumer.h +400 -0
- data/vendor/longfellow-zk/lib/algebra/nussbaumer_test.cc +138 -0
- data/vendor/longfellow-zk/lib/algebra/nussbaumerfp2_test.cc +139 -0
- data/vendor/longfellow-zk/lib/algebra/permutations.h +79 -0
- data/vendor/longfellow-zk/lib/algebra/poly.h +240 -0
- data/vendor/longfellow-zk/lib/algebra/poly_test.cc +123 -0
- data/vendor/longfellow-zk/lib/algebra/reed_solomon.h +150 -0
- data/vendor/longfellow-zk/lib/algebra/reed_solomon_extension.h +108 -0
- data/vendor/longfellow-zk/lib/algebra/reed_solomon_extension_test.cc +76 -0
- data/vendor/longfellow-zk/lib/algebra/reed_solomon_test.cc +473 -0
- data/vendor/longfellow-zk/lib/algebra/rfft.h +400 -0
- data/vendor/longfellow-zk/lib/algebra/rfft_test.cc +102 -0
- data/vendor/longfellow-zk/lib/algebra/static_string.h +29 -0
- data/vendor/longfellow-zk/lib/algebra/sysdep.h +495 -0
- data/vendor/longfellow-zk/lib/algebra/sysdep_test.cc +41 -0
- data/vendor/longfellow-zk/lib/algebra/twiddle.h +59 -0
- data/vendor/longfellow-zk/lib/algebra/utility.h +86 -0
- data/vendor/longfellow-zk/lib/algebra/utility_test.cc +86 -0
- data/vendor/longfellow-zk/lib/arrays/affine.h +56 -0
- data/vendor/longfellow-zk/lib/arrays/affine_test.cc +220 -0
- data/vendor/longfellow-zk/lib/arrays/dense.h +210 -0
- data/vendor/longfellow-zk/lib/arrays/eq.h +75 -0
- data/vendor/longfellow-zk/lib/arrays/eqs.h +137 -0
- data/vendor/longfellow-zk/lib/arrays/eqs_test.cc +151 -0
- data/vendor/longfellow-zk/lib/arrays/sparse.h +192 -0
- data/vendor/longfellow-zk/lib/cbor/host_decoder.h +323 -0
- data/vendor/longfellow-zk/lib/cbor/host_decoder_test.cc +541 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor.h +594 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_byte_decoder.h +150 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_byte_decoder_test.cc +147 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_constants.h +27 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_pluck.h +110 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_pluck_test.cc +55 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_test.cc +174 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_testing.h +98 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/cbor_witness.h +312 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/mso2_test.cc +662 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/mso_test.cc +485 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/scan.h +104 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser/scan_test.cc +137 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor.h +640 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_byte_decoder.h +150 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_byte_decoder_test.cc +147 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_constants.h +27 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_testing.h +99 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/cbor_witness.h +319 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/lexer_test.cc +120 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/mdoc_examples_test.cc +89 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/parser_circuit_test.cc +506 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/parser_size_test.cc +79 -0
- data/vendor/longfellow-zk/lib/circuits/cbor_parser_v2/parser_test.cc +473 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/canonicalization_test.cc +185 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/circuit_dump.h +65 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/compiler.h +471 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/compiler_test.cc +110 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/node.h +176 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/pdqhash.h +127 -0
- data/vendor/longfellow-zk/lib/circuits/compiler/schedule.h +435 -0
- data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_circuit.h +371 -0
- data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_external_test.cc +246 -0
- data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_test.cc +587 -0
- data/vendor/longfellow-zk/lib/circuits/ecdsa/verify_witness.h +201 -0
- data/vendor/longfellow-zk/lib/circuits/logic/bit_adder.h +140 -0
- data/vendor/longfellow-zk/lib/circuits/logic/bit_adder_test.cc +64 -0
- data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker.h +247 -0
- data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker_constants.h +35 -0
- data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker_encoder.h +72 -0
- data/vendor/longfellow-zk/lib/circuits/logic/bit_plucker_test.cc +183 -0
- data/vendor/longfellow-zk/lib/circuits/logic/compiler_backend.h +62 -0
- data/vendor/longfellow-zk/lib/circuits/logic/counter.h +171 -0
- data/vendor/longfellow-zk/lib/circuits/logic/counter_test.cc +102 -0
- data/vendor/longfellow-zk/lib/circuits/logic/evaluation_backend.h +94 -0
- data/vendor/longfellow-zk/lib/circuits/logic/logic.h +1232 -0
- data/vendor/longfellow-zk/lib/circuits/logic/logic_circuit_test.cc +310 -0
- data/vendor/longfellow-zk/lib/circuits/logic/logic_test.cc +521 -0
- data/vendor/longfellow-zk/lib/circuits/logic/memcmp.h +68 -0
- data/vendor/longfellow-zk/lib/circuits/logic/memcmp_test.cc +148 -0
- data/vendor/longfellow-zk/lib/circuits/logic/polynomial.h +94 -0
- data/vendor/longfellow-zk/lib/circuits/logic/polynomial_test.cc +62 -0
- data/vendor/longfellow-zk/lib/circuits/logic/routing.h +445 -0
- data/vendor/longfellow-zk/lib/circuits/logic/routing_test.cc +241 -0
- data/vendor/longfellow-zk/lib/circuits/logic/unary.h +55 -0
- data/vendor/longfellow-zk/lib/circuits/logic/unary_plucker.h +77 -0
- data/vendor/longfellow-zk/lib/circuits/logic/unary_plucker_constants.h +37 -0
- data/vendor/longfellow-zk/lib/circuits/logic/unary_plucker_test.cc +53 -0
- data/vendor/longfellow-zk/lib/circuits/logic/unary_size_test.cc +69 -0
- data/vendor/longfellow-zk/lib/circuits/logic/unary_test.cc +62 -0
- data/vendor/longfellow-zk/lib/circuits/mac/mac_circuit.h +193 -0
- data/vendor/longfellow-zk/lib/circuits/mac/mac_circuit_test.cc +223 -0
- data/vendor/longfellow-zk/lib/circuits/mac/mac_reference.h +72 -0
- data/vendor/longfellow-zk/lib/circuits/mac/mac_witness.h +94 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/circuit_maker.cc +242 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_attribute_ids.h +311 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_attribute_test.cc +64 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_circuit_id.cc +85 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_constants.h +85 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_decompress.cc +41 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_decompress.h +27 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_examples.h +5232 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_generate_circuit.cc +199 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_hash.h +554 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_signature.h +143 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_signature_test.cc +444 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_test_attributes.h +157 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_witness.h +863 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_zk.cc +693 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_zk.h +216 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/mdoc_zk_test.cc +724 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/zk_spec.cc +100 -0
- data/vendor/longfellow-zk/lib/circuits/mdoc/zk_spec_test.cc +155 -0
- data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_circuit.h +330 -0
- data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_circuit_test.cc +607 -0
- data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_io.h +26 -0
- data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_witness.cc +163 -0
- data/vendor/longfellow-zk/lib/circuits/sha/flatsha256_witness.h +47 -0
- data/vendor/longfellow-zk/lib/circuits/sha/sha256_constants.cc +34 -0
- data/vendor/longfellow-zk/lib/circuits/sha/sha256_constants.h +27 -0
- data/vendor/longfellow-zk/lib/circuits/sha/sha256_test_values.h +389 -0
- data/vendor/longfellow-zk/lib/circuits/tests/anoncred/ptrcred.h +171 -0
- data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small.h +218 -0
- data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_examples.h +118 -0
- data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_io.h +25 -0
- data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_test.cc +208 -0
- data/vendor/longfellow-zk/lib/circuits/tests/anoncred/small_witness.h +130 -0
- data/vendor/longfellow-zk/lib/circuits/tests/base64/decode.h +508 -0
- data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_circuit_test.cc +95 -0
- data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_test.cc +119 -0
- data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_util.cc +47 -0
- data/vendor/longfellow-zk/lib/circuits/tests/base64/decode_util.h +29 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ec/pk_circuit.h +231 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ec/pk_circuit_test.cc +428 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ec/pk_witness.h +102 -0
- data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt.h +190 -0
- data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt_constants.h +26 -0
- data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt_test.cc +559 -0
- data/vendor/longfellow-zk/lib/circuits/tests/jwt/jwt_witness.h +315 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f.h +411 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f_io.h +32 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f_test.cc +364 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_1f_witness.h +278 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation.h +146 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation_constants.h +25 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation_test.cc +315 -0
- data/vendor/longfellow-zk/lib/circuits/tests/mdoc/mdoc_revocation_witness.h +136 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/bitaddr/bitaddr.h +250 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/bitaddr/bitaddr_test.cc +333 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/bitaddr/bitaddr_witness.h +152 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44.h +903 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_circuit_test.cc +274 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_eval_test.cc +440 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_examples.cc +8851 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_examples.h +93 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_types.cc +24 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_types.h +118 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_witness.h +453 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_44_witness_test.cc +49 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref.cc +458 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref.h +150 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test.cc +398 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test_vectors.inc +3618 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test_vectors_pkdecode.inc +689 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/ml_dsa_ref_test_vectors_sigdecode.inc +1501 -0
- data/vendor/longfellow-zk/lib/circuits/tests/pq/ml_dsa/sigdecode_test_vectors.inc +540 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_circuit.h +394 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_circuit_test.cc +577 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_constants.h +90 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_witness.cc +174 -0
- data/vendor/longfellow-zk/lib/circuits/tests/ripemd/ripemd_witness.h +140 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_circuit.h +351 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_circuit_test.cc +466 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_reference.cc +207 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_reference.h +59 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_reference_test.cc +153 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_round_constants.cc +39 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_round_constants.h +29 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_slicing.h +31 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_witness.cc +83 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/sha3_witness.h +72 -0
- data/vendor/longfellow-zk/lib/circuits/tests/sha3/shake_test_vectors.h +477 -0
- data/vendor/longfellow-zk/lib/ec/elliptic_curve.h +596 -0
- data/vendor/longfellow-zk/lib/ec/elliptic_curve_test.cc +548 -0
- data/vendor/longfellow-zk/lib/ec/p256.cc +36 -0
- data/vendor/longfellow-zk/lib/ec/p256.h +60 -0
- data/vendor/longfellow-zk/lib/ec/p256k1.cc +34 -0
- data/vendor/longfellow-zk/lib/ec/p256k1.h +60 -0
- data/vendor/longfellow-zk/lib/gf2k/gf2_128.h +503 -0
- data/vendor/longfellow-zk/lib/gf2k/gf2_128_bench.cc +48 -0
- data/vendor/longfellow-zk/lib/gf2k/gf2_128_test.cc +416 -0
- data/vendor/longfellow-zk/lib/gf2k/gf2poly.h +74 -0
- data/vendor/longfellow-zk/lib/gf2k/lch14.h +242 -0
- data/vendor/longfellow-zk/lib/gf2k/lch14_bench.cc +75 -0
- data/vendor/longfellow-zk/lib/gf2k/lch14_reed_solomon.h +127 -0
- data/vendor/longfellow-zk/lib/gf2k/lch14_reed_solomon_test.cc +110 -0
- data/vendor/longfellow-zk/lib/gf2k/lch14_test.cc +246 -0
- data/vendor/longfellow-zk/lib/gf2k/sysdep.h +329 -0
- data/vendor/longfellow-zk/lib/ligero/ligero_param.h +449 -0
- data/vendor/longfellow-zk/lib/ligero/ligero_prover.h +354 -0
- data/vendor/longfellow-zk/lib/ligero/ligero_test.cc +136 -0
- data/vendor/longfellow-zk/lib/ligero/ligero_transcript.h +67 -0
- data/vendor/longfellow-zk/lib/ligero/ligero_verifier.h +272 -0
- data/vendor/longfellow-zk/lib/merkle/merkle_commitment.h +104 -0
- data/vendor/longfellow-zk/lib/merkle/merkle_tree.h +216 -0
- data/vendor/longfellow-zk/lib/merkle/merkle_tree_test.cc +240 -0
- data/vendor/longfellow-zk/lib/proto/circuit.h +354 -0
- data/vendor/longfellow-zk/lib/proto/circuit_test.cc +202 -0
- data/vendor/longfellow-zk/lib/random/random.h +119 -0
- data/vendor/longfellow-zk/lib/random/random_test.cc +189 -0
- data/vendor/longfellow-zk/lib/random/secure_random_engine.h +37 -0
- data/vendor/longfellow-zk/lib/random/transcript.h +193 -0
- data/vendor/longfellow-zk/lib/random/transcript_test.cc +344 -0
- data/vendor/longfellow-zk/lib/sumcheck/circuit.h +148 -0
- data/vendor/longfellow-zk/lib/sumcheck/circuit_id.h +71 -0
- data/vendor/longfellow-zk/lib/sumcheck/equad.h +126 -0
- data/vendor/longfellow-zk/lib/sumcheck/hquad.h +115 -0
- data/vendor/longfellow-zk/lib/sumcheck/prover.h +59 -0
- data/vendor/longfellow-zk/lib/sumcheck/prover_layers.h +362 -0
- data/vendor/longfellow-zk/lib/sumcheck/quad.h +227 -0
- data/vendor/longfellow-zk/lib/sumcheck/quad_builder.h +211 -0
- data/vendor/longfellow-zk/lib/sumcheck/quad_test.cc +169 -0
- data/vendor/longfellow-zk/lib/sumcheck/sumcheck_test.cc +324 -0
- data/vendor/longfellow-zk/lib/sumcheck/testing.h +69 -0
- data/vendor/longfellow-zk/lib/sumcheck/transcript_sumcheck.h +85 -0
- data/vendor/longfellow-zk/lib/sumcheck/verifier.h +84 -0
- data/vendor/longfellow-zk/lib/sumcheck/verifier_layers.h +221 -0
- data/vendor/longfellow-zk/lib/testing/test_main.cc +50 -0
- data/vendor/longfellow-zk/lib/util/ceildiv.h +164 -0
- data/vendor/longfellow-zk/lib/util/ceildiv_test.cc +152 -0
- data/vendor/longfellow-zk/lib/util/crc64.h +45 -0
- data/vendor/longfellow-zk/lib/util/crypto.cc +39 -0
- data/vendor/longfellow-zk/lib/util/crypto.h +108 -0
- data/vendor/longfellow-zk/lib/util/log.cc +110 -0
- data/vendor/longfellow-zk/lib/util/log.h +33 -0
- data/vendor/longfellow-zk/lib/util/panic.h +40 -0
- data/vendor/longfellow-zk/lib/util/readbuffer.h +67 -0
- data/vendor/longfellow-zk/lib/util/serialization.h +54 -0
- data/vendor/longfellow-zk/lib/zk/zk_common.h +455 -0
- data/vendor/longfellow-zk/lib/zk/zk_proof.h +378 -0
- data/vendor/longfellow-zk/lib/zk/zk_prover.h +202 -0
- data/vendor/longfellow-zk/lib/zk/zk_test.cc +340 -0
- data/vendor/longfellow-zk/lib/zk/zk_testing.h +154 -0
- data/vendor/longfellow-zk/lib/zk/zk_verifier.h +109 -0
- metadata +347 -0
|
@@ -0,0 +1,319 @@
|
|
|
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_CBOR_PARSER_V2_CBOR_WITNESS_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_CIRCUITS_CBOR_PARSER_V2_CBOR_WITNESS_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
#include <stdint.h>
|
|
20
|
+
|
|
21
|
+
#include <array>
|
|
22
|
+
|
|
23
|
+
#include "arrays/dense.h"
|
|
24
|
+
#include "circuits/cbor_parser_v2/cbor_constants.h"
|
|
25
|
+
#include "circuits/logic/bit_plucker_encoder.h"
|
|
26
|
+
#include "circuits/logic/unary_plucker_constants.h"
|
|
27
|
+
#include "util/panic.h"
|
|
28
|
+
|
|
29
|
+
namespace proofs {
|
|
30
|
+
template <class Field>
|
|
31
|
+
class CborWitness {
|
|
32
|
+
public:
|
|
33
|
+
using Elt = typename Field::Elt;
|
|
34
|
+
using CElt = typename Field::CElt;
|
|
35
|
+
static constexpr size_t kNCounters = CborConstants::kNCounters;
|
|
36
|
+
static constexpr size_t kIndexBits = CborConstants::kIndexBits;
|
|
37
|
+
using counters = std::array<size_t, kNCounters>;
|
|
38
|
+
using vindex = std::array<Elt, kIndexBits>;
|
|
39
|
+
|
|
40
|
+
struct position_witness {
|
|
41
|
+
Elt encoded_header;
|
|
42
|
+
Elt encoded_sel;
|
|
43
|
+
size_t slen_next;
|
|
44
|
+
counters cc_next;
|
|
45
|
+
Elt invprod_decode;
|
|
46
|
+
Elt invprod_parse;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
using v8 = std::array<Elt, 8>;
|
|
50
|
+
|
|
51
|
+
explicit CborWitness(const Field& F) : f_(F) {}
|
|
52
|
+
|
|
53
|
+
void push_witnesses(DenseFiller<Field>& filler, size_t n,
|
|
54
|
+
const position_witness pw[/*n*/]) const {
|
|
55
|
+
for (size_t i = 0; i < n; ++i) {
|
|
56
|
+
filler.push_back(pw[i].encoded_header);
|
|
57
|
+
filler.push_back(pw[i].encoded_sel);
|
|
58
|
+
filler.push_back(f_.as_counter(pw[i].slen_next));
|
|
59
|
+
for (size_t l = 0; l < kNCounters; ++l) {
|
|
60
|
+
filler.push_back(f_.as_counter(pw[i].cc_next[l]));
|
|
61
|
+
}
|
|
62
|
+
if (i > 0) {
|
|
63
|
+
filler.push_back(pw[i].invprod_decode);
|
|
64
|
+
filler.push_back(pw[i].invprod_parse);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Return an index as an array of Elt, which can be stored into W[]
|
|
70
|
+
vindex index(size_t j) const {
|
|
71
|
+
const Field& F = f_; // shorthand
|
|
72
|
+
vindex r;
|
|
73
|
+
for (size_t i = 0; i < kIndexBits; ++i) {
|
|
74
|
+
r[i] = F.of_scalar((j >> i) & 1);
|
|
75
|
+
}
|
|
76
|
+
return r;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// N: maximum input length (in bytes)
|
|
80
|
+
// INPUT_LEN: actual input length
|
|
81
|
+
void compute_witnesses(size_t n, size_t input_len, const uint8_t bytes[/*n*/],
|
|
82
|
+
v8 in[/*n*/], position_witness pw[/*n*/]) const {
|
|
83
|
+
const Field& F = f_; // shorthand
|
|
84
|
+
BitPluckerEncoder<Field, 1> BPENC(F);
|
|
85
|
+
|
|
86
|
+
proofs::check(input_len <= n, "input_len <= n");
|
|
87
|
+
|
|
88
|
+
// First pass to compute the number of top-level items. In the
|
|
89
|
+
// second pass, we will use this value to that all counters are 0
|
|
90
|
+
// at the end of the input.
|
|
91
|
+
size_t top_level_items;
|
|
92
|
+
{
|
|
93
|
+
// start with a value of cc[0] guaranteed not to
|
|
94
|
+
// underflow counter 0.
|
|
95
|
+
counters cc{{n + 1}};
|
|
96
|
+
|
|
97
|
+
size_t slen = 1;
|
|
98
|
+
for (size_t i = 0; i < n; ++i) {
|
|
99
|
+
bool overflow;
|
|
100
|
+
bool header = (slen == 1);
|
|
101
|
+
cc = counters_next(bytes[i], header,
|
|
102
|
+
/*have_nextb=*/(i + 1) < n,
|
|
103
|
+
/*nextb=*/(i + 1) < n ? bytes[i + 1] : 0, cc,
|
|
104
|
+
&overflow);
|
|
105
|
+
proofs::check(!overflow, "!overflow");
|
|
106
|
+
slen = next_slen(slen, n, bytes, i);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
top_level_items = (n + 1) - cc[0];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// second pass starting with the correct counter values
|
|
113
|
+
{
|
|
114
|
+
counters cc{{top_level_items}};
|
|
115
|
+
|
|
116
|
+
size_t slen = 1;
|
|
117
|
+
for (size_t i = 0; i < n; ++i) {
|
|
118
|
+
bool overflow;
|
|
119
|
+
bool header = (slen == 1);
|
|
120
|
+
bool in_input = (i >= n - input_len);
|
|
121
|
+
|
|
122
|
+
// Require all bytes not in the input to be 0.
|
|
123
|
+
if (!in_input) {
|
|
124
|
+
proofs::check(bytes[i] == 0, "bytes[i] == 0");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// set up input
|
|
128
|
+
for (size_t j = 0; j < 8; ++j) {
|
|
129
|
+
in[i][j] = F.of_scalar((bytes[i] >> j) & 1);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// decode witness
|
|
133
|
+
Elt prod_decode =
|
|
134
|
+
header ? F.one() : F.znz_indicator(F.as_counter(slen - 1));
|
|
135
|
+
|
|
136
|
+
// set up parse witness
|
|
137
|
+
Elt prod_parse = F.one();
|
|
138
|
+
size_t isel = kNCounters;
|
|
139
|
+
for (size_t l = kNCounters; l-- > 0;) {
|
|
140
|
+
if (cc[l] != 0) {
|
|
141
|
+
if (i > 0) {
|
|
142
|
+
F.mul(prod_parse, F.znz_indicator(F.as_counter(cc[l])));
|
|
143
|
+
}
|
|
144
|
+
isel = l;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
counters cc_next = counters_next(
|
|
150
|
+
bytes[i], header,
|
|
151
|
+
/*have_nextb=*/(i + 1) < n,
|
|
152
|
+
/*nextb=*/(i + 1) < n ? bytes[i + 1] : 0, cc, &overflow);
|
|
153
|
+
proofs::check(!overflow, "!overflow");
|
|
154
|
+
pw[i].cc_next = cc_next;
|
|
155
|
+
|
|
156
|
+
// set up decode witness
|
|
157
|
+
size_t slen_next = next_slen(slen, n, bytes, i);
|
|
158
|
+
pw[i].slen_next = slen_next;
|
|
159
|
+
|
|
160
|
+
// encode witnesses
|
|
161
|
+
pw[i].encoded_header = BPENC.encode(header);
|
|
162
|
+
pw[i].encoded_sel = unary_plucker_point<Field, kNCounters>()(isel, F);
|
|
163
|
+
pw[i].invprod_decode = F.invertf(prod_decode);
|
|
164
|
+
pw[i].invprod_parse = F.invertf(prod_parse);
|
|
165
|
+
|
|
166
|
+
slen = slen_next;
|
|
167
|
+
cc = cc_next;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private:
|
|
173
|
+
static size_t next_slen(size_t slen, size_t n, const uint8_t bytes[/*n*/],
|
|
174
|
+
size_t i) {
|
|
175
|
+
size_t slenm1 = slen - 1;
|
|
176
|
+
bool header = (slenm1 == 0);
|
|
177
|
+
if (header) {
|
|
178
|
+
if (i + 1 < n) {
|
|
179
|
+
return item_length(bytes[i], true, bytes[i + 1]);
|
|
180
|
+
} else {
|
|
181
|
+
return item_length(bytes[i], false, 0);
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
return slenm1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// TODO [matteof 2023-11-03] Should not panic() here.
|
|
189
|
+
static size_t item_length(uint8_t b, bool valid_nextb, uint8_t nextb) {
|
|
190
|
+
size_t type = (b >> 5) & 0x7u;
|
|
191
|
+
size_t count = b & 0x1Fu;
|
|
192
|
+
bool count0_23 = (count < 24);
|
|
193
|
+
bool count24 = (count == 24);
|
|
194
|
+
bool count25 = (count == 25);
|
|
195
|
+
bool count26 = (count == 26);
|
|
196
|
+
bool count27 = (count == 27);
|
|
197
|
+
|
|
198
|
+
switch (type) {
|
|
199
|
+
case 0: /* unsigned */
|
|
200
|
+
case 1: /* negative integer */
|
|
201
|
+
case 6: /* tag */
|
|
202
|
+
if (count0_23) {
|
|
203
|
+
return 1;
|
|
204
|
+
} else if (count24) {
|
|
205
|
+
return 2;
|
|
206
|
+
} else if (count25) {
|
|
207
|
+
return 3;
|
|
208
|
+
} else if (count26) {
|
|
209
|
+
return 5;
|
|
210
|
+
} else if (count27) {
|
|
211
|
+
return 9;
|
|
212
|
+
} else {
|
|
213
|
+
check(false, "unwitnessed count (atom)");
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
case 4: /* array */
|
|
218
|
+
case 5: /* map */
|
|
219
|
+
if (count0_23) {
|
|
220
|
+
return 1;
|
|
221
|
+
} else if (count24) {
|
|
222
|
+
return 2;
|
|
223
|
+
} else {
|
|
224
|
+
check(false, "unwitnessed count (item)");
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
case 2: /* bytes */
|
|
229
|
+
case 3: /* text */
|
|
230
|
+
if (count0_23) {
|
|
231
|
+
return 1 + count;
|
|
232
|
+
} else if (count24) {
|
|
233
|
+
if (valid_nextb) {
|
|
234
|
+
return 2 + nextb;
|
|
235
|
+
} else {
|
|
236
|
+
check(false, "invalid nextb");
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
check(false, "unwitnessed count (bytes)");
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
case 7: /* special */
|
|
245
|
+
check(false, "unwitnessed special");
|
|
246
|
+
return 0;
|
|
247
|
+
|
|
248
|
+
default:
|
|
249
|
+
check(false, "can't happen");
|
|
250
|
+
return 0;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
static size_t decode_count(size_t count_in_header, bool have_nextb,
|
|
255
|
+
uint8_t nextb) {
|
|
256
|
+
if (count_in_header < 24) {
|
|
257
|
+
return count_in_header;
|
|
258
|
+
} else if (count_in_header == 24) {
|
|
259
|
+
if (have_nextb) {
|
|
260
|
+
return nextb;
|
|
261
|
+
} else {
|
|
262
|
+
check(false, "!have_nextb");
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
check(false, "count > 24");
|
|
266
|
+
}
|
|
267
|
+
return 0xdeadbeef;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
static counters counters_next(uint8_t b, bool header, bool have_nextb,
|
|
271
|
+
uint8_t nextb, const counters& c,
|
|
272
|
+
bool* overflow) {
|
|
273
|
+
size_t type = (b >> 5) & 0x7u;
|
|
274
|
+
size_t count_in_header = b & 0x1Fu;
|
|
275
|
+
bool tagp = (type == 6);
|
|
276
|
+
bool arrayp = (type == 4);
|
|
277
|
+
bool mapp = (type == 5);
|
|
278
|
+
|
|
279
|
+
counters c1 = c;
|
|
280
|
+
*overflow = false;
|
|
281
|
+
|
|
282
|
+
for (size_t l = kNCounters; l-- > 0;) {
|
|
283
|
+
if (c[l] != 0) {
|
|
284
|
+
if (header) {
|
|
285
|
+
c1[l] = c[l] - 1;
|
|
286
|
+
|
|
287
|
+
if (tagp) {
|
|
288
|
+
if (l + 1 < kNCounters) {
|
|
289
|
+
c1[l + 1] = 1;
|
|
290
|
+
} else {
|
|
291
|
+
*overflow = true;
|
|
292
|
+
}
|
|
293
|
+
} else if (arrayp) {
|
|
294
|
+
if (l + 1 < kNCounters) {
|
|
295
|
+
c1[l + 1] = decode_count(count_in_header, have_nextb, nextb);
|
|
296
|
+
} else {
|
|
297
|
+
*overflow = true;
|
|
298
|
+
}
|
|
299
|
+
} else if (mapp) {
|
|
300
|
+
if (l + 1 < kNCounters) {
|
|
301
|
+
c1[l + 1] = 2 * decode_count(count_in_header, have_nextb, nextb);
|
|
302
|
+
} else {
|
|
303
|
+
*overflow = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return c1;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
private:
|
|
315
|
+
const Field& f_;
|
|
316
|
+
};
|
|
317
|
+
} // namespace proofs
|
|
318
|
+
|
|
319
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_CIRCUITS_CBOR_PARSER_V2_CBOR_WITNESS_H_
|
|
@@ -0,0 +1,120 @@
|
|
|
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 <stddef.h>
|
|
16
|
+
|
|
17
|
+
#include <cstdint>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
#include "algebra/fp.h"
|
|
21
|
+
#include "circuits/cbor_parser_v2/cbor.h"
|
|
22
|
+
#include "circuits/cbor_parser_v2/cbor_testing.h"
|
|
23
|
+
#include "circuits/cbor_parser_v2/cbor_witness.h"
|
|
24
|
+
#include "circuits/logic/evaluation_backend.h"
|
|
25
|
+
#include "circuits/logic/logic.h"
|
|
26
|
+
#include "gf2k/gf2_128.h"
|
|
27
|
+
#include "gtest/gtest.h"
|
|
28
|
+
|
|
29
|
+
namespace proofs {
|
|
30
|
+
namespace {
|
|
31
|
+
|
|
32
|
+
// encoder of input bytes
|
|
33
|
+
static inline uint8_t H(uint8_t type, uint8_t count) {
|
|
34
|
+
return (type << 5) | count;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
uint8_t testcase[] = {
|
|
38
|
+
// Atoms of various size
|
|
39
|
+
H(0, 23),
|
|
40
|
+
|
|
41
|
+
H(0, 24),
|
|
42
|
+
33,
|
|
43
|
+
|
|
44
|
+
H(0, 25),
|
|
45
|
+
33,
|
|
46
|
+
34,
|
|
47
|
+
|
|
48
|
+
H(0, 26),
|
|
49
|
+
33,
|
|
50
|
+
34,
|
|
51
|
+
35,
|
|
52
|
+
36,
|
|
53
|
+
|
|
54
|
+
H(0, 27),
|
|
55
|
+
33,
|
|
56
|
+
34,
|
|
57
|
+
35,
|
|
58
|
+
36,
|
|
59
|
+
37,
|
|
60
|
+
38,
|
|
61
|
+
39,
|
|
62
|
+
40,
|
|
63
|
+
|
|
64
|
+
// a short string
|
|
65
|
+
H(2, 3),
|
|
66
|
+
'f',
|
|
67
|
+
'o',
|
|
68
|
+
'o',
|
|
69
|
+
|
|
70
|
+
// a long string
|
|
71
|
+
H(2, 24), // header + next byte + string
|
|
72
|
+
/*length of the string*/ 3,
|
|
73
|
+
0xff,
|
|
74
|
+
25,
|
|
75
|
+
31,
|
|
76
|
+
|
|
77
|
+
// another small atom
|
|
78
|
+
H(0, 22),
|
|
79
|
+
|
|
80
|
+
// a long string
|
|
81
|
+
H(2, 24), // header + next byte + string
|
|
82
|
+
/*length of the string*/ 4,
|
|
83
|
+
'q',
|
|
84
|
+
'u',
|
|
85
|
+
'u',
|
|
86
|
+
'x',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
template <class Field>
|
|
90
|
+
void test_lexer(const Field& F) {
|
|
91
|
+
using EvalBackend = EvaluationBackend<Field>;
|
|
92
|
+
using Logic = Logic<Field, EvalBackend>;
|
|
93
|
+
const EvalBackend ebk(F);
|
|
94
|
+
const Logic L(&ebk, F);
|
|
95
|
+
using Cbor = Cbor<Logic>;
|
|
96
|
+
using CborWitness = CborWitness<Field>;
|
|
97
|
+
const Cbor CBOR(L);
|
|
98
|
+
const CborTesting<Field> CT(F);
|
|
99
|
+
|
|
100
|
+
constexpr size_t n = sizeof(testcase) / sizeof(testcase[0]);
|
|
101
|
+
CborWitness CW(F);
|
|
102
|
+
|
|
103
|
+
std::vector<typename CborWitness::v8> inS(n);
|
|
104
|
+
std::vector<typename CborWitness::position_witness> pwS(n);
|
|
105
|
+
CW.compute_witnesses(n, n, testcase, inS.data(), pwS.data());
|
|
106
|
+
|
|
107
|
+
std::vector<typename Cbor::v8> in(n);
|
|
108
|
+
std::vector<typename Cbor::position_witness> pw(n);
|
|
109
|
+
CT.convert_witnesses(n, in.data(), pw.data(), inS.data(), pwS.data());
|
|
110
|
+
|
|
111
|
+
std::vector<typename Cbor::decode> ds(n);
|
|
112
|
+
CBOR.decode_and_assert_decode(n, ds.data(), in.data(), pw.data());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
TEST(CborLexer, PrimeField) { test_lexer(Fp<1>("18446744073709551557")); }
|
|
116
|
+
|
|
117
|
+
TEST(CborLexer, BinaryField) { test_lexer(GF2_128<>()); }
|
|
118
|
+
|
|
119
|
+
} // namespace
|
|
120
|
+
} // namespace proofs
|
|
@@ -0,0 +1,89 @@
|
|
|
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/mdoc/mdoc_examples.h"
|
|
16
|
+
|
|
17
|
+
#include <stddef.h>
|
|
18
|
+
|
|
19
|
+
#include <cstdint>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
#include "algebra/fp.h"
|
|
23
|
+
#include "circuits/cbor_parser_v2/cbor.h"
|
|
24
|
+
#include "circuits/cbor_parser_v2/cbor_testing.h"
|
|
25
|
+
#include "circuits/cbor_parser_v2/cbor_witness.h"
|
|
26
|
+
#include "circuits/logic/evaluation_backend.h"
|
|
27
|
+
#include "circuits/logic/logic.h"
|
|
28
|
+
#include "circuits/mdoc/mdoc_witness.h"
|
|
29
|
+
#include "circuits/mdoc/mdoc_zk.h"
|
|
30
|
+
#include "gf2k/gf2_128.h"
|
|
31
|
+
#include "gtest/gtest.h"
|
|
32
|
+
|
|
33
|
+
// Make sure we can parse all the mdoc examples
|
|
34
|
+
//
|
|
35
|
+
// TODO [matteof 2025-08-25] This file includes circuits/mdoc/
|
|
36
|
+
// which includes the cbor parser, creating a circular dependency.
|
|
37
|
+
// Punt for now, but mdoc examples should be in a separate
|
|
38
|
+
// directory included by everybody else.
|
|
39
|
+
//
|
|
40
|
+
namespace proofs {
|
|
41
|
+
namespace {
|
|
42
|
+
template <class Field>
|
|
43
|
+
void test_examples(const Field& F) {
|
|
44
|
+
using CborWitness = CborWitness<Field>;
|
|
45
|
+
using CborTesting = CborTesting<Field>;
|
|
46
|
+
|
|
47
|
+
using EvalBackend = EvaluationBackend<Field>;
|
|
48
|
+
using Logic = Logic<Field, EvalBackend>;
|
|
49
|
+
using CborL = Cbor<Logic>;
|
|
50
|
+
|
|
51
|
+
const EvalBackend ebk(F);
|
|
52
|
+
const Logic L(&ebk, F);
|
|
53
|
+
const CborL CBOR(L);
|
|
54
|
+
const CborTesting CT(F);
|
|
55
|
+
const CborWitness CW(F);
|
|
56
|
+
|
|
57
|
+
for (const MdocTests& test : mdoc_tests) {
|
|
58
|
+
ParsedMdoc pm;
|
|
59
|
+
MdocProverErrorCode ok =
|
|
60
|
+
pm.parse_device_response(test.mdoc_size, test.mdoc);
|
|
61
|
+
EXPECT_TRUE(ok == MDOC_PROVER_SUCCESS);
|
|
62
|
+
|
|
63
|
+
size_t n = pm.t_mso_.len - 5;
|
|
64
|
+
const uint8_t* mso = test.mdoc + pm.t_mso_.pos + 5;
|
|
65
|
+
|
|
66
|
+
// sanity check
|
|
67
|
+
EXPECT_GT(n, 0);
|
|
68
|
+
EXPECT_EQ(mso[0], 0xa6);
|
|
69
|
+
|
|
70
|
+
std::vector<typename CborWitness::v8> inS(n);
|
|
71
|
+
std::vector<typename CborWitness::position_witness> pwS(n);
|
|
72
|
+
CW.compute_witnesses(n, n, mso, inS.data(), pwS.data());
|
|
73
|
+
|
|
74
|
+
std::vector<typename CborL::v8> in(n);
|
|
75
|
+
std::vector<typename CborL::position_witness> pw(n);
|
|
76
|
+
CT.convert_witnesses(n, in.data(), pw.data(), inS.data(), pwS.data());
|
|
77
|
+
|
|
78
|
+
std::vector<typename CborL::decode> ds(n);
|
|
79
|
+
std::vector<typename CborL::parse_output> ps(n);
|
|
80
|
+
CBOR.decode_and_assert_decode_and_parse(n, ds.data(), ps.data(), in.data(),
|
|
81
|
+
pw.data());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
TEST(MdocExamples, PrimeField) { test_examples(Fp<1>("18446744073709551557")); }
|
|
86
|
+
|
|
87
|
+
TEST(MdocExamples, BinaryField) { test_examples(GF2_128<>()); }
|
|
88
|
+
} // namespace
|
|
89
|
+
} // namespace proofs
|