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,71 @@
|
|
|
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_SUMCHECK_CIRCUIT_ID_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_SUMCHECK_CIRCUIT_ID_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
#include <cstdint>
|
|
21
|
+
|
|
22
|
+
#include "sumcheck/circuit.h"
|
|
23
|
+
#include "util/crypto.h"
|
|
24
|
+
|
|
25
|
+
namespace proofs {
|
|
26
|
+
|
|
27
|
+
// This method produces a unique name for a circuit. It does not match
|
|
28
|
+
// the serialization method for the circuit.
|
|
29
|
+
template <class Field>
|
|
30
|
+
void circuit_id(uint8_t id[/*32*/], const Circuit<Field>& c, const Field& F) {
|
|
31
|
+
const uint64_t CHAR2 = 0x2;
|
|
32
|
+
const uint64_t ODD = 0x1;
|
|
33
|
+
SHA256 sha;
|
|
34
|
+
uint8_t tmp[Field::kBytes];
|
|
35
|
+
if (F.kCharacteristicTwo) {
|
|
36
|
+
// Characteristic two fields are uniquely determined by their length
|
|
37
|
+
// in our codebase.
|
|
38
|
+
sha.Update8(CHAR2); // Indicates binary field.
|
|
39
|
+
sha.Update8(F.kBits);
|
|
40
|
+
} else {
|
|
41
|
+
// Prime fields are determined by -1.
|
|
42
|
+
sha.Update8(ODD); // Indicates odd prime field.
|
|
43
|
+
F.to_bytes_field(tmp, F.mone());
|
|
44
|
+
sha.Update(tmp, sizeof(tmp));
|
|
45
|
+
}
|
|
46
|
+
sha.Update8(c.nv);
|
|
47
|
+
sha.Update8(c.logv);
|
|
48
|
+
sha.Update8(c.nc);
|
|
49
|
+
sha.Update8(c.logc);
|
|
50
|
+
sha.Update8(c.nl);
|
|
51
|
+
sha.Update8(c.ninputs);
|
|
52
|
+
sha.Update8(c.npub_in);
|
|
53
|
+
sha.Update8(c.subfield_boundary);
|
|
54
|
+
for (const auto& layer : c.l) {
|
|
55
|
+
sha.Update8(layer.nw);
|
|
56
|
+
sha.Update8(layer.logw);
|
|
57
|
+
sha.Update8(layer.quad->size());
|
|
58
|
+
for (const auto& ec : *layer.quad) {
|
|
59
|
+
sha.Update8(static_cast<uint64_t>(ec.g));
|
|
60
|
+
sha.Update8(static_cast<uint64_t>(ec.h[0]));
|
|
61
|
+
sha.Update8(static_cast<uint64_t>(ec.h[1]));
|
|
62
|
+
F.to_bytes_field(tmp, ec.v);
|
|
63
|
+
sha.Update(tmp, sizeof(tmp));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
sha.DigestData(id);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
} // namespace proofs
|
|
70
|
+
|
|
71
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_SUMCHECK_CIRCUIT_ID_H_
|
|
@@ -0,0 +1,126 @@
|
|
|
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_SUMCHECK_EQUAD_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_SUMCHECK_EQUAD_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <cstdint>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
#include "algebra/compare.h"
|
|
25
|
+
#include "util/ceildiv.h"
|
|
26
|
+
#define DEFINE_STRONG_INT_TYPE(a, b) using a = b
|
|
27
|
+
|
|
28
|
+
// ------------------------------------------------------------
|
|
29
|
+
// Expanded representation of the Quad
|
|
30
|
+
namespace proofs {
|
|
31
|
+
template <class Field>
|
|
32
|
+
class EQuad {
|
|
33
|
+
using Elt = typename Field::Elt;
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
// To save space when representing large circuits, quad_corner_t
|
|
37
|
+
// is defined as uint32_t. (Note that Elt probably imposes uint64_t
|
|
38
|
+
// alignment, so struct corner has holes.)
|
|
39
|
+
//
|
|
40
|
+
// To make the narrowing explicit, define corner_t as a
|
|
41
|
+
// Google-specific strong int. Outside of Google, replace
|
|
42
|
+
// this definition with a typedef.
|
|
43
|
+
DEFINE_STRONG_INT_TYPE(quad_corner_t, uint32_t);
|
|
44
|
+
|
|
45
|
+
struct ecorner {
|
|
46
|
+
quad_corner_t g; // "gate" variable
|
|
47
|
+
quad_corner_t h[2]; // two "hand" variables
|
|
48
|
+
Elt v;
|
|
49
|
+
|
|
50
|
+
// equality of indices
|
|
51
|
+
bool eqndx(const ecorner& y) const {
|
|
52
|
+
return (g == y.g && h[0] == y.h[0] && h[1] == y.h[1]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool eq_hands(const ecorner& y) const {
|
|
56
|
+
return (h[0] == y.h[0] && h[1] == y.h[1]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void canonicalize() {
|
|
60
|
+
quad_corner_t h0 = h[0], h1 = h[1];
|
|
61
|
+
h[0] = std::min<quad_corner_t>(h0, h1);
|
|
62
|
+
h[1] = std::max<quad_corner_t>(h0, h1);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
using index_t = size_t;
|
|
67
|
+
index_t n_;
|
|
68
|
+
std::vector<ecorner> ec_;
|
|
69
|
+
|
|
70
|
+
explicit EQuad(index_t n) : n_(n), ec_(n) {}
|
|
71
|
+
|
|
72
|
+
// no copies
|
|
73
|
+
EQuad(const EQuad& y) = delete;
|
|
74
|
+
EQuad(EQuad&& y) = delete;
|
|
75
|
+
EQuad& operator=(const EQuad& y) = delete;
|
|
76
|
+
EQuad& operator=(EQuad&& y) = delete;
|
|
77
|
+
|
|
78
|
+
void canonicalize(const Field& F) {
|
|
79
|
+
for (index_t i = 0; i < n_; ++i) {
|
|
80
|
+
ec_[i].canonicalize();
|
|
81
|
+
}
|
|
82
|
+
// Sort only the first n_ elements, as n_ may have been reduced by
|
|
83
|
+
// coalescing.
|
|
84
|
+
std::sort(ec_.begin(), ec_.begin() + n_,
|
|
85
|
+
[&F](const ecorner& x, const ecorner& y) {
|
|
86
|
+
return compare_ecorner(x, y, F);
|
|
87
|
+
});
|
|
88
|
+
coalesce(F);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private:
|
|
92
|
+
static bool compare_ecorner(const ecorner& x, const ecorner& y,
|
|
93
|
+
const Field& F) {
|
|
94
|
+
if (morton::lt(size_t(x.h[0]), size_t(x.h[1]), size_t(y.h[0]),
|
|
95
|
+
size_t(y.h[1]))) {
|
|
96
|
+
return true;
|
|
97
|
+
} else if (morton::eq(size_t(x.h[0]), size_t(x.h[1]), size_t(y.h[0]),
|
|
98
|
+
size_t(y.h[1]))) {
|
|
99
|
+
if (x.g < y.g) return true;
|
|
100
|
+
if (x.g > y.g) return false;
|
|
101
|
+
return elt_less_than(x.v, y.v, F);
|
|
102
|
+
} else {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void coalesce(const Field& F) {
|
|
108
|
+
// Coalesce duplicates.
|
|
109
|
+
// The (rd,wr)=(0,0) iteration executes the else{} branch and
|
|
110
|
+
// continues with (1,1), so we start at (1,1) and avoid the
|
|
111
|
+
// special case for wr-1 at wr=0.
|
|
112
|
+
index_t wr = 1;
|
|
113
|
+
for (index_t rd = 1; rd < n_; ++rd) {
|
|
114
|
+
if (ec_[rd].eqndx(ec_[wr - 1])) {
|
|
115
|
+
F.add(ec_[wr - 1].v, ec_[rd].v);
|
|
116
|
+
} else {
|
|
117
|
+
ec_[wr] = ec_[rd];
|
|
118
|
+
wr++;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
n_ = wr;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
} // namespace proofs
|
|
125
|
+
|
|
126
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_SUMCHECK_EQUAD_H_
|
|
@@ -0,0 +1,115 @@
|
|
|
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_SUMCHECK_HQUAD_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_SUMCHECK_HQUAD_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
#include "arrays/affine.h"
|
|
23
|
+
#include "sumcheck/equad.h"
|
|
24
|
+
#include "util/panic.h"
|
|
25
|
+
|
|
26
|
+
// ------------------------------------------------------------
|
|
27
|
+
// Representation of the quad after bind_g, in which case g = 0
|
|
28
|
+
// and we don't need to store it.
|
|
29
|
+
namespace proofs {
|
|
30
|
+
template <class Field>
|
|
31
|
+
class HQuad {
|
|
32
|
+
using Elt = typename Field::Elt;
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
using quad_corner_t = typename EQuad<Field>::quad_corner_t;
|
|
36
|
+
using index_t = typename EQuad<Field>::index_t;
|
|
37
|
+
|
|
38
|
+
// Ideally we would write
|
|
39
|
+
//
|
|
40
|
+
// struct hcorner {
|
|
41
|
+
// quad_corner_t h[2];
|
|
42
|
+
// Elt v;
|
|
43
|
+
// };
|
|
44
|
+
//
|
|
45
|
+
// However, Elt may be 128-bit aligned, causing holes in the struct.
|
|
46
|
+
// Thus we store an array of H and an array of V.
|
|
47
|
+
|
|
48
|
+
struct hcorner {
|
|
49
|
+
quad_corner_t h[2]; // two "hand" variables
|
|
50
|
+
|
|
51
|
+
bool eq_hands(const hcorner& y) const {
|
|
52
|
+
return (h[0] == y.h[0] && h[1] == y.h[1]);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
struct vcorner {
|
|
56
|
+
Elt v;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
index_t n_;
|
|
60
|
+
std::vector<hcorner> hc_;
|
|
61
|
+
std::vector<vcorner> vc_;
|
|
62
|
+
|
|
63
|
+
explicit HQuad(index_t n) : n_(n), hc_(n), vc_(n) {}
|
|
64
|
+
|
|
65
|
+
// no copies
|
|
66
|
+
HQuad(const HQuad& y) = delete;
|
|
67
|
+
HQuad(HQuad&& y) = delete;
|
|
68
|
+
HQuad& operator=(const HQuad& y) = delete;
|
|
69
|
+
HQuad& operator=(HQuad&& y) = delete;
|
|
70
|
+
|
|
71
|
+
void bind_h(const Elt& r, size_t hand, const Field& F) {
|
|
72
|
+
index_t rd = 0, wr = 0;
|
|
73
|
+
while (rd < n_) {
|
|
74
|
+
hcorner hcc;
|
|
75
|
+
vcorner vcc;
|
|
76
|
+
hcc.h[hand] = hc_[rd].h[hand] >> 1;
|
|
77
|
+
hcc.h[1 - hand] = hc_[rd].h[1 - hand];
|
|
78
|
+
|
|
79
|
+
size_t rd1 = rd + 1;
|
|
80
|
+
if (rd1 < n_ && //
|
|
81
|
+
hc_[rd].h[1 - hand] == hc_[rd1].h[1 - hand] && //
|
|
82
|
+
(hc_[rd].h[hand] >> 1) == (hc_[rd1].h[hand] >> 1) && //
|
|
83
|
+
hc_[rd1].h[hand] == hc_[rd].h[hand] + quad_corner_t(1)) {
|
|
84
|
+
// we have two corners.
|
|
85
|
+
vcc.v = affine_interpolation(r, vc_[rd].v, vc_[rd1].v, F);
|
|
86
|
+
rd += 2;
|
|
87
|
+
} else {
|
|
88
|
+
// we have one corner and the other one is zero.
|
|
89
|
+
if ((hc_[rd].h[hand] & quad_corner_t(1)) == quad_corner_t(0)) {
|
|
90
|
+
vcc.v = affine_interpolation_nz_z(r, vc_[rd].v, F);
|
|
91
|
+
} else {
|
|
92
|
+
vcc.v = affine_interpolation_z_nz(r, vc_[rd].v, F);
|
|
93
|
+
}
|
|
94
|
+
rd = rd1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
hc_[wr] = hcc;
|
|
98
|
+
vc_[wr] = vcc;
|
|
99
|
+
++wr;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// shrink the array
|
|
103
|
+
n_ = wr;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
Elt scalar() const {
|
|
107
|
+
check(n_ == 1, "n_ == 1");
|
|
108
|
+
check(hc_[0].h[0] == quad_corner_t(0), "hc_[0].h[0] == 0");
|
|
109
|
+
check(hc_[0].h[1] == quad_corner_t(0), "hc_[0].h[1] == 0");
|
|
110
|
+
return vc_[0].v;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
} // namespace proofs
|
|
114
|
+
|
|
115
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_SUMCHECK_HQUAD_H_
|
|
@@ -0,0 +1,59 @@
|
|
|
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_SUMCHECK_PROVER_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_SUMCHECK_PROVER_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
#include "random/transcript.h"
|
|
21
|
+
#include "sumcheck/circuit.h"
|
|
22
|
+
#include "sumcheck/prover_layers.h"
|
|
23
|
+
#include "sumcheck/transcript_sumcheck.h"
|
|
24
|
+
|
|
25
|
+
namespace proofs {
|
|
26
|
+
|
|
27
|
+
// A high level idea is partially described in chapter 4.6.7 "Leveraging Data
|
|
28
|
+
// Parallelism for Further Speedups" in the book "Proofs, Arguments, and
|
|
29
|
+
// Zero-Knowledge" by Justin Thaler.
|
|
30
|
+
template <class Field>
|
|
31
|
+
class Prover : public ProverLayers<Field> {
|
|
32
|
+
using super = ProverLayers<Field>;
|
|
33
|
+
using typename super::bindings;
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
using typename super::inputs;
|
|
37
|
+
|
|
38
|
+
explicit Prover(const Field& f) : ProverLayers<Field>(f) {}
|
|
39
|
+
|
|
40
|
+
// Generate proof for circuit. pad can be nullptr if the caller does not
|
|
41
|
+
// want to add any pad to the proof. Caller must ensure in, t, and F remain
|
|
42
|
+
// valid during call duration.
|
|
43
|
+
// This method always succeeds, but may not produce a verifying proof if
|
|
44
|
+
// the inputs do not satisfy the circuit.
|
|
45
|
+
void prove(Proof<Field>* proof, const Proof<Field>* pad,
|
|
46
|
+
const Circuit<Field>* circ, const inputs& in, Transcript& t) {
|
|
47
|
+
if (proof == nullptr || circ == nullptr) return;
|
|
48
|
+
|
|
49
|
+
TranscriptSumcheck<Field> ts(t, super::f_);
|
|
50
|
+
// The input X is stored at in's layer nl - 1.
|
|
51
|
+
ts.write_input(in.at(circ->nl - 1).get());
|
|
52
|
+
bindings bnd;
|
|
53
|
+
super::prove(proof, pad, circ, in, /*aux=*/nullptr, bnd, ts, super::f_);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace proofs
|
|
58
|
+
|
|
59
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_SUMCHECK_PROVER_H_
|