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,323 @@
|
|
|
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_CBOR_HOST_DECODER_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_CBOR_HOST_DECODER_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
#include <string.h>
|
|
20
|
+
|
|
21
|
+
#include <cstdint>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
#include "util/panic.h"
|
|
25
|
+
|
|
26
|
+
namespace proofs {
|
|
27
|
+
|
|
28
|
+
enum CborTag { UNSIGNED, NEGATIVE, BYTES, TEXT, ARRAY, MAP, TAG, PRIMITIVE };
|
|
29
|
+
enum CborPrimitive { CFALSE, CTRUE, CNULL };
|
|
30
|
+
|
|
31
|
+
// CBOR decoder for a subset of CBOR used in MDOC.
|
|
32
|
+
//
|
|
33
|
+
// The main advantage of this decoder is that it keeps
|
|
34
|
+
// offsets into the input, which is useful because we need to
|
|
35
|
+
// generate circuits that depend on input offsets.
|
|
36
|
+
//
|
|
37
|
+
// The other security advantage is the smaller codebase, versus
|
|
38
|
+
// relying on an imported CBOR parser that handles a larger subset of CBOR
|
|
39
|
+
// that may introduce issues.
|
|
40
|
+
//
|
|
41
|
+
// The decode function is used to process an untrusted array of bytes.
|
|
42
|
+
// The method returns false if the input is not processed exactly per the
|
|
43
|
+
// MDOC spec with only attributes in the org.iso.18013.5.1 namespace.
|
|
44
|
+
// The resulting CborDoc object is static, and it is assumed that neither the
|
|
45
|
+
// input doc, nor the tree structure changes. All of the lookup and index
|
|
46
|
+
// methods return const pointers to attempt to maintain this property.
|
|
47
|
+
class CborDoc {
|
|
48
|
+
public:
|
|
49
|
+
size_t header_pos_;
|
|
50
|
+
enum CborTag t_;
|
|
51
|
+
|
|
52
|
+
// A union is used to store the attributes for either singleton objects (i.e.,
|
|
53
|
+
// UNSIGNED, NEGATIVE, PRIMITIVE), the start position and len of TEXT and
|
|
54
|
+
// BYTES array, and the children information for ARRAY or MAP objects.
|
|
55
|
+
// len of strings and byte arrays
|
|
56
|
+
union U {
|
|
57
|
+
uint64_t u64; /* UNSIGNED */
|
|
58
|
+
int64_t i64; /* NEGATIVE */
|
|
59
|
+
enum CborPrimitive p; /* PRIMITIVE */
|
|
60
|
+
|
|
61
|
+
// BYTES + TEXT, represented as offset in input + length
|
|
62
|
+
struct {
|
|
63
|
+
size_t pos;
|
|
64
|
+
size_t len;
|
|
65
|
+
} string;
|
|
66
|
+
|
|
67
|
+
// arrays, maps, and tags: an array of children nodes.
|
|
68
|
+
struct {
|
|
69
|
+
// The original count in the source document. For tags,
|
|
70
|
+
// the tag itself.
|
|
71
|
+
size_t n;
|
|
72
|
+
|
|
73
|
+
// The actual number of children (e.g. 2*n for maps).
|
|
74
|
+
size_t nchildren;
|
|
75
|
+
} items;
|
|
76
|
+
} u_;
|
|
77
|
+
|
|
78
|
+
// This field only applies to ARRAY, MAP nodes, but it has been moved
|
|
79
|
+
// out of the union to avoid including components with non-default
|
|
80
|
+
// constructors. It holds the children objects of an array or map. For a map,
|
|
81
|
+
// even positions are the keys, and the odd positions are the values.
|
|
82
|
+
std::vector<CborDoc> children_;
|
|
83
|
+
|
|
84
|
+
// Parse a byte sequence into a CborDoc structure.
|
|
85
|
+
//
|
|
86
|
+
// Caller passes in the input sequence, the length of the
|
|
87
|
+
// input, and pos and offset values. The offset value handles the case when
|
|
88
|
+
// the input sequence is a sub-sequence of another string, as it is in
|
|
89
|
+
// the MDOC and MSO parsing.
|
|
90
|
+
//
|
|
91
|
+
// This function can handle adversarial inputs, and returns false when the
|
|
92
|
+
// input cannot be parsed.
|
|
93
|
+
bool decode(const uint8_t in[], size_t len, size_t &pos, size_t offset) {
|
|
94
|
+
/* invariant: pos is always compared with len before it is referenced. */
|
|
95
|
+
header_pos_ = pos + offset;
|
|
96
|
+
|
|
97
|
+
if (pos >= len) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
uint8_t b = in[pos++];
|
|
101
|
+
|
|
102
|
+
size_t type = (b >> 5) & 0x7u;
|
|
103
|
+
size_t count0 = b & 0x1Fu;
|
|
104
|
+
|
|
105
|
+
// variable-length count
|
|
106
|
+
size_t count = 0;
|
|
107
|
+
if (count0 < 24) {
|
|
108
|
+
count = count0;
|
|
109
|
+
} else if (count0 == 24) {
|
|
110
|
+
if (pos >= len) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
count = in[pos++];
|
|
114
|
+
} else if (count0 == 25) {
|
|
115
|
+
if (pos + 1 >= len) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
count = in[pos] * 256 + in[pos + 1];
|
|
119
|
+
pos += 2;
|
|
120
|
+
} else if (count0 == 26) {
|
|
121
|
+
if (pos + 3 >= len) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
for (size_t i = 0; i < 4; ++i) {
|
|
125
|
+
count *= 256;
|
|
126
|
+
count += in[pos++];
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
switch (type) { /* type \in [0,7] by construction */
|
|
133
|
+
case 0:
|
|
134
|
+
t_ = UNSIGNED;
|
|
135
|
+
u_.u64 = count;
|
|
136
|
+
break;
|
|
137
|
+
case 1:
|
|
138
|
+
t_ = NEGATIVE;
|
|
139
|
+
u_.i64 = -(int64_t)count;
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
case 2: /* BYTES */
|
|
143
|
+
case 3: /* TEXT */
|
|
144
|
+
if (pos + count > len) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
t_ = (type == 2) ? BYTES : TEXT;
|
|
148
|
+
u_.string.pos = pos;
|
|
149
|
+
u_.string.len = count;
|
|
150
|
+
pos += count;
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case 4: /* ARRAY */
|
|
154
|
+
if (pos + count > len) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return decode_items(ARRAY, count, count, in, len, pos, offset);
|
|
158
|
+
|
|
159
|
+
case 5: /* MAP, (key,val) pairs are stored as 2*children */
|
|
160
|
+
if (pos + 2 * count > len) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return decode_items(MAP, 2 * count, count, in, len, pos, offset);
|
|
164
|
+
|
|
165
|
+
case 6: /* TAG */
|
|
166
|
+
// Special cases for TAG
|
|
167
|
+
if (count == 1004) { // date in the form YYYY-MM-DD
|
|
168
|
+
if (pos + 1 + 10 > len) { // 0xDA for str length + 10 characters
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return decode_items(TAG, 1, count, in, len, pos, offset);
|
|
173
|
+
|
|
174
|
+
case 7: /* PRIMITIVE */
|
|
175
|
+
t_ = PRIMITIVE;
|
|
176
|
+
switch (count) {
|
|
177
|
+
case 20:
|
|
178
|
+
u_.p = CFALSE;
|
|
179
|
+
break;
|
|
180
|
+
case 21:
|
|
181
|
+
u_.p = CTRUE;
|
|
182
|
+
break;
|
|
183
|
+
case 22:
|
|
184
|
+
u_.p = CNULL;
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Lookup a child node in an array. Returns null if the query is invalid.
|
|
196
|
+
const CborDoc *index(size_t index) const {
|
|
197
|
+
if (t_ == ARRAY && index < u_.items.nchildren) {
|
|
198
|
+
return &children_[index];
|
|
199
|
+
}
|
|
200
|
+
return nullptr;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Lookup a key in a map of type {bytes->elements}.
|
|
204
|
+
// Returns null if the query is invalid.
|
|
205
|
+
// The key is given as bytes with a length.
|
|
206
|
+
// ndx is set to the child index of the located key.
|
|
207
|
+
// The return pointer references the key, and the next object refers to
|
|
208
|
+
// the value and is guaranteed to exist.
|
|
209
|
+
const CborDoc *lookup(const uint8_t *const in, size_t len,
|
|
210
|
+
const uint8_t bytes[/*len*/], size_t &ndx) const {
|
|
211
|
+
if (t_ == MAP) {
|
|
212
|
+
for (size_t i = 0; i < u_.items.n; ++i) {
|
|
213
|
+
if (children_[2 * i].eq(in, len, bytes)) {
|
|
214
|
+
ndx = i;
|
|
215
|
+
return &children_[2 * i];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return nullptr;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Lookup a key in a map of type {unsigned->object}.
|
|
223
|
+
// Returns null if the query is invalid.
|
|
224
|
+
const CborDoc *lookup_unsigned(uint64_t k, size_t &ndx) const {
|
|
225
|
+
if (t_ == MAP) {
|
|
226
|
+
for (size_t i = 0; i < u_.items.n; ++i) {
|
|
227
|
+
const CborDoc *key = &children_[2 * i];
|
|
228
|
+
if (key->t_ == UNSIGNED && key->u_.u64 == k) {
|
|
229
|
+
ndx = i;
|
|
230
|
+
return key;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return nullptr;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Lookup a key in a map of type {negative->object}.
|
|
238
|
+
// Returns null if the query is invalid.
|
|
239
|
+
const CborDoc *lookup_negative(int64_t k, size_t &ndx) const {
|
|
240
|
+
if (t_ == MAP) {
|
|
241
|
+
for (size_t i = 0; i < u_.items.n; ++i) {
|
|
242
|
+
const CborDoc *key = &children_[2 * i];
|
|
243
|
+
if (key->t_ == NEGATIVE && key->u_.i64 == k) {
|
|
244
|
+
ndx = i;
|
|
245
|
+
return key;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return nullptr;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Returns the index of the item with respect to the document bytes.
|
|
253
|
+
size_t position() const {
|
|
254
|
+
switch (t_) {
|
|
255
|
+
case UNSIGNED:
|
|
256
|
+
return header_pos_;
|
|
257
|
+
case BYTES:
|
|
258
|
+
case TEXT:
|
|
259
|
+
return u_.string.pos;
|
|
260
|
+
case TAG:
|
|
261
|
+
return children_[0].u_.string.pos;
|
|
262
|
+
case PRIMITIVE:
|
|
263
|
+
return header_pos_;
|
|
264
|
+
default:
|
|
265
|
+
check(false, "valueIndex called on non-value type");
|
|
266
|
+
}
|
|
267
|
+
return 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Returns the length of the item's value in bytes.
|
|
271
|
+
// According to ISO 18013-5 7.2.1, the mDL data elements shall be encoded
|
|
272
|
+
// as tstr, uint, bstr, bool, or tdate, so this function only handles those
|
|
273
|
+
// cases.
|
|
274
|
+
size_t length() const {
|
|
275
|
+
switch (t_) {
|
|
276
|
+
case UNSIGNED:
|
|
277
|
+
if (u_.u64 < 24) {
|
|
278
|
+
return 1;
|
|
279
|
+
} else if (u_.u64 < 256) {
|
|
280
|
+
return 2;
|
|
281
|
+
} else if (u_.u64 < 65536) {
|
|
282
|
+
return 3;
|
|
283
|
+
}
|
|
284
|
+
return 5;
|
|
285
|
+
case BYTES:
|
|
286
|
+
case TEXT:
|
|
287
|
+
return u_.string.len;
|
|
288
|
+
case TAG:
|
|
289
|
+
return children_[0].u_.string.len; // full-date #6.1004(tstr) format
|
|
290
|
+
case PRIMITIVE:
|
|
291
|
+
return 1;
|
|
292
|
+
default:
|
|
293
|
+
check(false, "valueLength called on non-value type");
|
|
294
|
+
}
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private:
|
|
299
|
+
// Decodes a sequence of children nodes.
|
|
300
|
+
bool decode_items(CborTag t, size_t nchildren, size_t items_n,
|
|
301
|
+
const uint8_t in[], size_t len, size_t &pos,
|
|
302
|
+
size_t offset) {
|
|
303
|
+
t_ = t;
|
|
304
|
+
u_.items.n = items_n;
|
|
305
|
+
u_.items.nchildren = nchildren;
|
|
306
|
+
children_.resize(nchildren);
|
|
307
|
+
for (size_t i = 0; i < nchildren; ++i) {
|
|
308
|
+
if (!children_[i].decode(in, len, pos, offset)) return false;
|
|
309
|
+
}
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Compares a text node to a given string of bytes.
|
|
314
|
+
bool eq(const uint8_t *const in, size_t len,
|
|
315
|
+
const uint8_t bytes[/*len*/]) const {
|
|
316
|
+
return t_ == TEXT && u_.string.len == len &&
|
|
317
|
+
memcmp(bytes, &in[u_.string.pos], len) == 0;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
} // namespace proofs
|
|
322
|
+
|
|
323
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_CBOR_HOST_DECODER_H_
|