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,123 @@
|
|
|
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 "algebra/poly.h"
|
|
16
|
+
|
|
17
|
+
#include <cstddef>
|
|
18
|
+
|
|
19
|
+
#include "algebra/blas.h"
|
|
20
|
+
#include "algebra/bogorng.h"
|
|
21
|
+
#include "algebra/fp.h"
|
|
22
|
+
#include "algebra/static_string.h"
|
|
23
|
+
#include "gtest/gtest.h"
|
|
24
|
+
|
|
25
|
+
namespace proofs {
|
|
26
|
+
namespace {
|
|
27
|
+
static const StaticString primes[] = {
|
|
28
|
+
StaticString("18446744073709551557"),
|
|
29
|
+
StaticString("340282366920938463463374607431768211297"),
|
|
30
|
+
StaticString("6277101735386680763835789423207666416102355444464034512659"),
|
|
31
|
+
StaticString("1157920892373161954235709850086879078532699846656405640394575"
|
|
32
|
+
"84007913129639747"),
|
|
33
|
+
StaticString("2135987035920910082395021706169552114602704522356652769947041"
|
|
34
|
+
"607822219725780640550022962086936379"),
|
|
35
|
+
StaticString("3940200619639447921227904010014361380507973927046544666794829"
|
|
36
|
+
"3404245721771497210611414266254884915640806627990306499"),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
template <size_t N, size_t W>
|
|
40
|
+
void one_test_eval_lagrange() {
|
|
41
|
+
using Field = Fp<W>;
|
|
42
|
+
using T = Poly<N, Field>;
|
|
43
|
+
using Elt = typename Field::Elt;
|
|
44
|
+
const Field F(primes[W - 1]);
|
|
45
|
+
Bogorng<Field> rng(&F);
|
|
46
|
+
const typename T::dot_interpolation dot_interp(F);
|
|
47
|
+
|
|
48
|
+
T C, L;
|
|
49
|
+
for (size_t iter = 0; iter < 10; ++iter) {
|
|
50
|
+
for (size_t i = 0; i < N; ++i) {
|
|
51
|
+
C[i] = rng.next();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (size_t i = 0; i < N; ++i) {
|
|
55
|
+
// Lagrange basis
|
|
56
|
+
L[i] = C.eval_monomial(F.poly_evaluation_point(i), F);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (size_t iter1 = 0; iter1 < 10; iter1++) {
|
|
60
|
+
auto r = rng.next();
|
|
61
|
+
Elt got_val = L.eval_lagrange(r, F);
|
|
62
|
+
Elt want_val = C.eval_monomial(r, F);
|
|
63
|
+
EXPECT_EQ(got_val, want_val);
|
|
64
|
+
|
|
65
|
+
T coef = dot_interp.coef(r, F);
|
|
66
|
+
Elt got_dot = Blas<Field>::dot(N, &coef[0], 1, &L[0], 1, F);
|
|
67
|
+
EXPECT_EQ(got_dot, want_val);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
template <size_t N, size_t W>
|
|
73
|
+
void one_test_extend() {
|
|
74
|
+
using Field = Fp<W>;
|
|
75
|
+
using T2 = Poly<2, Field>;
|
|
76
|
+
using FT = Poly<N, Field>;
|
|
77
|
+
using Elt = typename Field::Elt;
|
|
78
|
+
const Field F(primes[W - 1]);
|
|
79
|
+
Bogorng<Field> rng(&F);
|
|
80
|
+
|
|
81
|
+
// Test the linear extension. Start with a polynomial
|
|
82
|
+
// L2 of degree <2, and extend it to a polynomial L
|
|
83
|
+
// of degree <N, then evaluate both at random points.
|
|
84
|
+
for (size_t iter = 0; iter < 10; ++iter) {
|
|
85
|
+
T2 L2;
|
|
86
|
+
L2[0] = rng.next();
|
|
87
|
+
L2[1] = rng.next();
|
|
88
|
+
|
|
89
|
+
FT L = FT::extend(L2, F);
|
|
90
|
+
|
|
91
|
+
for (size_t iter1 = 0; iter1 < 10; iter1++) {
|
|
92
|
+
auto r = rng.next();
|
|
93
|
+
Elt got = L.eval_lagrange(r, F);
|
|
94
|
+
Elt got2 = L2.eval_lagrange(r, F);
|
|
95
|
+
EXPECT_EQ(got, got2);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
template <size_t W>
|
|
101
|
+
void oneW() {
|
|
102
|
+
one_test_eval_lagrange<2, W>();
|
|
103
|
+
one_test_eval_lagrange<3, W>();
|
|
104
|
+
one_test_eval_lagrange<4, W>();
|
|
105
|
+
one_test_eval_lagrange<5, W>();
|
|
106
|
+
one_test_eval_lagrange<6, W>();
|
|
107
|
+
one_test_extend<2, W>();
|
|
108
|
+
one_test_extend<3, W>();
|
|
109
|
+
one_test_extend<4, W>();
|
|
110
|
+
one_test_extend<5, W>();
|
|
111
|
+
one_test_extend<6, W>();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
TEST(Poly, All) {
|
|
115
|
+
oneW<1>();
|
|
116
|
+
oneW<2>();
|
|
117
|
+
oneW<3>();
|
|
118
|
+
oneW<4>();
|
|
119
|
+
oneW<5>();
|
|
120
|
+
oneW<6>();
|
|
121
|
+
}
|
|
122
|
+
} // namespace
|
|
123
|
+
} // namespace proofs
|
|
@@ -0,0 +1,150 @@
|
|
|
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_ALGEBRA_REED_SOLOMON_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_ALGEBRA_REED_SOLOMON_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
#include <memory>
|
|
21
|
+
#include <vector>
|
|
22
|
+
|
|
23
|
+
#include "algebra/utility.h"
|
|
24
|
+
|
|
25
|
+
namespace proofs {
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
The ReedSolomon class interpolates a polynomial given as input in point-eval
|
|
29
|
+
form at a set of different points, thereby computing a form of RS encoding.
|
|
30
|
+
Specifically, the input polynomial of degree d=n-1 is given as evaluations
|
|
31
|
+
at 0, 1, 2, ..., n-1, and the output is the values at n, n+1, n+2, ..., n+m-1.
|
|
32
|
+
The algorithm uses the following relation:
|
|
33
|
+
|
|
34
|
+
p(k) = (-1)^d (k-d)(k choose d) sum_{j=0}^{d} (1/k-j)(-1)^j (d choose j)p(j)
|
|
35
|
+
|
|
36
|
+
which can be efficiently computed using a convolution, whose implementation
|
|
37
|
+
is provided by a ConvolutionFactory for the field.
|
|
38
|
+
|
|
39
|
+
The const Field& objects that are passed have lifetimes that exceed the call
|
|
40
|
+
durations and can be safely passed by const reference.
|
|
41
|
+
|
|
42
|
+
*/
|
|
43
|
+
template <class Field, class ConvolutionFactory>
|
|
44
|
+
class ReedSolomon {
|
|
45
|
+
using Elt = typename Field::Elt;
|
|
46
|
+
using Convolver = typename ConvolutionFactory::Convolver;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// n is the number of points provided
|
|
50
|
+
// m is the total number of points output (including the initial n points)
|
|
51
|
+
ReedSolomon(size_t n, size_t m, const Field& F,
|
|
52
|
+
const ConvolutionFactory& factory)
|
|
53
|
+
: f_(F), // could grab this from the factory
|
|
54
|
+
degree_bound_(n - 1),
|
|
55
|
+
m_(m),
|
|
56
|
+
leading_constant_(m - n + 1),
|
|
57
|
+
binom_i_(n) {
|
|
58
|
+
// inverses[i]: inverses[i] = 1/i from i = 1 to m-1 (inverses[0] = 0)
|
|
59
|
+
std::vector<Elt> inverses(m_);
|
|
60
|
+
AlgebraUtil<Field>::batch_inverse_arithmetic(m, &inverses[0], F);
|
|
61
|
+
c_ = factory.make(n, m, &inverses[0]);
|
|
62
|
+
leading_constant_[0] = F.one();
|
|
63
|
+
binom_i_[0] = F.one();
|
|
64
|
+
// Set leading_constant_[i] = (i+degree_bound_) choose degree_bound_
|
|
65
|
+
// (from i=0 to i=m)
|
|
66
|
+
for (size_t i = 1; i + degree_bound_ < m; ++i) {
|
|
67
|
+
leading_constant_[i] =
|
|
68
|
+
F.mulf(leading_constant_[i - 1],
|
|
69
|
+
F.mulf(F.of_scalar(degree_bound_ + i), inverses[i]));
|
|
70
|
+
}
|
|
71
|
+
// Finish computing the leading constants:
|
|
72
|
+
// (-1)^degree_bound_ (k-degree_bound_) \binom{k}{degree_bound_}
|
|
73
|
+
for (size_t k = degree_bound_; k < m; ++k) {
|
|
74
|
+
F.mul(leading_constant_[k - degree_bound_],
|
|
75
|
+
F.of_scalar(k - degree_bound_));
|
|
76
|
+
if (degree_bound_ % 2 == 1) {
|
|
77
|
+
F.neg(leading_constant_[k - degree_bound_]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (size_t i = 1; i < n; ++i) {
|
|
82
|
+
binom_i_[i] =
|
|
83
|
+
F.mulf(binom_i_[i - 1], F.mulf(F.of_scalar(n - i), inverses[i]));
|
|
84
|
+
}
|
|
85
|
+
for (size_t i = 1; i < n; i += 2) {
|
|
86
|
+
F.neg(binom_i_[i]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Given the values of a polynomial of degree at most n at 0, 1, 2, ..., n-1,
|
|
91
|
+
// this computes the values at n, n+1, n+2, ..., m-1.
|
|
92
|
+
// (n points go in, m points come out)
|
|
93
|
+
void interpolate(Elt y[/*m*/]) const {
|
|
94
|
+
// shorthands
|
|
95
|
+
const Field& F = f_;
|
|
96
|
+
size_t n = degree_bound_ + 1; // number of points input
|
|
97
|
+
|
|
98
|
+
// Define x[i] = (-1)^i \binom{n}{i} p(i) for i=0 through i=n
|
|
99
|
+
std::vector<Elt> x(n);
|
|
100
|
+
for (size_t i = 0; i < n; i++) {
|
|
101
|
+
x[i] = F.mulf(binom_i_[i], y[i]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
std::vector<Elt> T(m_);
|
|
105
|
+
c_->convolution(&x[0], &T[0]);
|
|
106
|
+
// Multiply the leading constants by the convolution
|
|
107
|
+
for (size_t i = n; i < m_; ++i) {
|
|
108
|
+
y[i] = F.mulf(leading_constant_[i - degree_bound_], T[i]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private:
|
|
113
|
+
const Field& f_;
|
|
114
|
+
|
|
115
|
+
// n is the number of points input, and degree_bound = n + 1.
|
|
116
|
+
// degree_bound_ is useful since the LaTeX math is written in terms of it
|
|
117
|
+
const size_t degree_bound_; // degree bound, i.e., n - 1
|
|
118
|
+
// total number of points output (points in + new points out)
|
|
119
|
+
const size_t m_;
|
|
120
|
+
|
|
121
|
+
std::unique_ptr<const Convolver> c_;
|
|
122
|
+
|
|
123
|
+
// leading_constant_[i] = \binom{i+degree_bound_}{degree_bound_} *
|
|
124
|
+
// (-1)^{degree_bound_} (i+degree_bound_ - degree_bound_) (from i=0 to i=m-n)
|
|
125
|
+
// i.e., the leading constant \binom{k}{degree_bound_} *
|
|
126
|
+
// (-1)^degree_bound_ (k - degree_bound_), shifted left by degree_bound_
|
|
127
|
+
std::vector<Elt> leading_constant_;
|
|
128
|
+
// (-1)^i (degree_bound_ choose i) from i=0 to i=degree_bound_
|
|
129
|
+
std::vector<Elt> binom_i_;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
template <class Field, class ConvolutionFactory>
|
|
133
|
+
class ReedSolomonFactory {
|
|
134
|
+
public:
|
|
135
|
+
ReedSolomonFactory(const ConvolutionFactory& factory, const Field& f)
|
|
136
|
+
: factory_(factory), f_(f) {}
|
|
137
|
+
|
|
138
|
+
std::unique_ptr<ReedSolomon<Field, ConvolutionFactory>> make(size_t n,
|
|
139
|
+
size_t m) const {
|
|
140
|
+
return std::make_unique<ReedSolomon<Field, ConvolutionFactory>>(n, m, f_,
|
|
141
|
+
factory_);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private:
|
|
145
|
+
const ConvolutionFactory& factory_;
|
|
146
|
+
const Field& f_;
|
|
147
|
+
};
|
|
148
|
+
} // namespace proofs
|
|
149
|
+
|
|
150
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_ALGEBRA_REED_SOLOMON_H_
|
|
@@ -0,0 +1,108 @@
|
|
|
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_ALGEBRA_REED_SOLOMON_EXTENSION_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_ALGEBRA_REED_SOLOMON_EXTENSION_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
|
|
20
|
+
#include <memory>
|
|
21
|
+
#include <utility>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
#include "algebra/crt.h"
|
|
25
|
+
#include "algebra/crt_convolution.h"
|
|
26
|
+
#include "algebra/fp24.h"
|
|
27
|
+
#include "algebra/fp24_6.h"
|
|
28
|
+
#include "algebra/reed_solomon.h"
|
|
29
|
+
|
|
30
|
+
namespace proofs {
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
The ReedSolomonExtension6 class implements a form of RS encoding when the
|
|
34
|
+
evaluation points belong to a base field, but the message is defined over
|
|
35
|
+
a degree 6 extension field. In this case, the RS encoding can be viewed as the
|
|
36
|
+
encoding each of the components of the message separately using the base
|
|
37
|
+
field, and then combining the results.
|
|
38
|
+
|
|
39
|
+
This implementation only works for Fp24_6.
|
|
40
|
+
*/
|
|
41
|
+
class ReedSolomonExtension6 {
|
|
42
|
+
using BaseField = Fp24;
|
|
43
|
+
using Elt = typename BaseField::Elt;
|
|
44
|
+
using ExtElt = typename Fp24_6::Elt;
|
|
45
|
+
|
|
46
|
+
CrtConvolutionFactory<CRT<1, Fp24>, Fp24> crt_convolution_factory_;
|
|
47
|
+
using RSF =
|
|
48
|
+
ReedSolomonFactory<Fp24, CrtConvolutionFactory<CRT<1, Fp24>, Fp24>>;
|
|
49
|
+
RSF rsf_;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// n is the number of points input
|
|
53
|
+
// m is the total number of points output (including the initial n points)
|
|
54
|
+
ReedSolomonExtension6(size_t n, size_t m, const BaseField& f)
|
|
55
|
+
: crt_convolution_factory_(f),
|
|
56
|
+
rsf_(crt_convolution_factory_, f),
|
|
57
|
+
rs_(rsf_.make(n, m)),
|
|
58
|
+
degree_bound_(n - 1),
|
|
59
|
+
m_(m) {}
|
|
60
|
+
|
|
61
|
+
// Given the values of a polynomial of degree at most n at 0, 1, 2, ..., n-1,
|
|
62
|
+
// this computes the values at n, n+1, n+2, ..., m-1.
|
|
63
|
+
// (n points go in, m points come out)
|
|
64
|
+
void interpolate(ExtElt y[/*m*/]) const {
|
|
65
|
+
// shorthands
|
|
66
|
+
size_t n = degree_bound_ + 1; // number of points input
|
|
67
|
+
|
|
68
|
+
// Compute the RS encoding of each of the components of the message
|
|
69
|
+
// separately.
|
|
70
|
+
std::vector<Elt> T(m_);
|
|
71
|
+
for (size_t d = 0; d < 6; ++d) {
|
|
72
|
+
// copy inputs to T
|
|
73
|
+
for (size_t i = 0; i < n; ++i) {
|
|
74
|
+
T[i] = y[i].e[d];
|
|
75
|
+
}
|
|
76
|
+
rs_->interpolate(&T[0]);
|
|
77
|
+
// copy output to y
|
|
78
|
+
for (size_t i = n; i < m_; ++i) {
|
|
79
|
+
y[i].e[d] = T[i];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
decltype(std::declval<const RSF&>().make(1, 1)) rs_;
|
|
86
|
+
|
|
87
|
+
const size_t degree_bound_; // degree bound, i.e., n - 1
|
|
88
|
+
// total number of points output (points in + new points out)
|
|
89
|
+
const size_t m_;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
class ReedSolomonExtensionFactory {
|
|
93
|
+
using BaseField = Fp24;
|
|
94
|
+
|
|
95
|
+
public:
|
|
96
|
+
explicit ReedSolomonExtensionFactory(const BaseField& f) : base_field_(f) {}
|
|
97
|
+
|
|
98
|
+
std::unique_ptr<ReedSolomonExtension6> make(size_t n, size_t m) const {
|
|
99
|
+
return std::make_unique<ReedSolomonExtension6>(n, m, base_field_);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private:
|
|
103
|
+
const BaseField& base_field_;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
} // namespace proofs
|
|
107
|
+
|
|
108
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_ALGEBRA_REED_SOLOMON_EXTENSION_H_
|
|
@@ -0,0 +1,76 @@
|
|
|
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 "algebra/reed_solomon_extension.h"
|
|
16
|
+
|
|
17
|
+
#include <cstddef>
|
|
18
|
+
#include <memory>
|
|
19
|
+
|
|
20
|
+
#include "algebra/fp24.h"
|
|
21
|
+
#include "algebra/fp24_6.h"
|
|
22
|
+
#include "algebra/interpolation.h"
|
|
23
|
+
#include "algebra/poly.h"
|
|
24
|
+
#include "gtest/gtest.h"
|
|
25
|
+
|
|
26
|
+
namespace proofs {
|
|
27
|
+
namespace {
|
|
28
|
+
|
|
29
|
+
static constexpr size_t N = 10;
|
|
30
|
+
static constexpr size_t M = 30;
|
|
31
|
+
|
|
32
|
+
TEST(ReedSolomonExtensionTest, Extension6) {
|
|
33
|
+
using BaseField = Fp24;
|
|
34
|
+
using ExtField = Fp24_6;
|
|
35
|
+
using BaseElt = BaseField::Elt;
|
|
36
|
+
using ExtElt = ExtField::Elt;
|
|
37
|
+
|
|
38
|
+
const BaseField base(8380417);
|
|
39
|
+
const ExtField ext(base, 7);
|
|
40
|
+
|
|
41
|
+
using Poly = Poly<N, BaseField>;
|
|
42
|
+
using Interpolation = Interpolation<N, BaseField>;
|
|
43
|
+
using RSExtFactory = ReedSolomonExtensionFactory;
|
|
44
|
+
|
|
45
|
+
Poly P[6];
|
|
46
|
+
for (size_t d = 0; d < 6; ++d) {
|
|
47
|
+
for (size_t i = 0; i < N; ++i) {
|
|
48
|
+
P[d][i] = base.of_scalar(i * i * i + d * i + (i ^ (i << 2)));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ExtElt L[M];
|
|
53
|
+
for (size_t i = 0; i < M; ++i) {
|
|
54
|
+
BaseElt x = base.of_scalar(i);
|
|
55
|
+
for (size_t d = 0; d < 6; ++d) {
|
|
56
|
+
L[i].e[d] = Interpolation::eval_monomial(P[d], x, base);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ExtElt L2[M];
|
|
61
|
+
for (size_t i = 0; i < N; ++i) {
|
|
62
|
+
L2[i] = L[i];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
RSExtFactory rs_ext_factory(base);
|
|
66
|
+
|
|
67
|
+
auto r = rs_ext_factory.make(N, M);
|
|
68
|
+
r->interpolate(L2);
|
|
69
|
+
|
|
70
|
+
for (size_t i = 0; i < M; ++i) {
|
|
71
|
+
EXPECT_EQ(L2[i], L[i]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
} // namespace
|
|
76
|
+
} // namespace proofs
|