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,435 @@
|
|
|
1
|
+
// Copyright 2026 Google LLC.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
#ifndef PRIVACY_PROOFS_ZK_LIB_CIRCUITS_COMPILER_SCHEDULE_H_
|
|
16
|
+
#define PRIVACY_PROOFS_ZK_LIB_CIRCUITS_COMPILER_SCHEDULE_H_
|
|
17
|
+
|
|
18
|
+
#include <stddef.h>
|
|
19
|
+
#include <stdint.h>
|
|
20
|
+
|
|
21
|
+
#include <algorithm>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
#include "algebra/compare.h"
|
|
26
|
+
#include "arrays/affine.h"
|
|
27
|
+
#include "circuits/compiler/node.h"
|
|
28
|
+
#include "sumcheck/circuit.h"
|
|
29
|
+
#include "sumcheck/equad.h"
|
|
30
|
+
#include "sumcheck/quad.h"
|
|
31
|
+
#include "sumcheck/quad_builder.h"
|
|
32
|
+
#include "util/ceildiv.h"
|
|
33
|
+
#include "util/panic.h"
|
|
34
|
+
|
|
35
|
+
namespace proofs {
|
|
36
|
+
template <class Field>
|
|
37
|
+
class Scheduler {
|
|
38
|
+
using Elt = typename Field::Elt;
|
|
39
|
+
using nodeinfo = NodeInfoF<Field>;
|
|
40
|
+
using node = NodeF<Field>;
|
|
41
|
+
using size_t_for_storage = term::size_t_for_storage;
|
|
42
|
+
using quad_corner_t = typename Quad<Field>::quad_corner_t;
|
|
43
|
+
|
|
44
|
+
const Field& f_;
|
|
45
|
+
const std::vector<node>& nodes_;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
size_t nwires_;
|
|
49
|
+
size_t nquad_terms_;
|
|
50
|
+
size_t nwires_overhead_;
|
|
51
|
+
|
|
52
|
+
Scheduler(const std::vector<node>& nodes, const Field& f)
|
|
53
|
+
: f_(f),
|
|
54
|
+
nodes_(nodes),
|
|
55
|
+
nwires_(0),
|
|
56
|
+
nquad_terms_(0),
|
|
57
|
+
nwires_overhead_(0) {}
|
|
58
|
+
|
|
59
|
+
std::unique_ptr<Circuit<Field>> mkcircuit(const std::vector<Elt>& constants,
|
|
60
|
+
size_t depth_ub, size_t nc) {
|
|
61
|
+
std::unique_ptr<Circuit<Field>> c = std::make_unique<Circuit<Field>>();
|
|
62
|
+
|
|
63
|
+
// number of layers and copies
|
|
64
|
+
c->nl = depth_ub - 1; // depth 0 = input nodes, not a "layer"
|
|
65
|
+
c->nc = nc;
|
|
66
|
+
c->logc = lg(nc);
|
|
67
|
+
|
|
68
|
+
auto lnodes = order_by_layer(constants, depth_ub);
|
|
69
|
+
|
|
70
|
+
// TODO [matteof 2025-03-12] ASSIGN_WIRE_IDS() renames LNODES in
|
|
71
|
+
// order to sort it and assign LNODES[].DESIRED_WIRE ID. Then it
|
|
72
|
+
// throws away the renamed LNODES. Then FILL_LAYERS() renames
|
|
73
|
+
// LNODES again in order to produce the final quad. It would be
|
|
74
|
+
// better to produce the quad directly in ASSIGN_WIRE_IDS(). Punt
|
|
75
|
+
// for now, this is just a performance optimization of the
|
|
76
|
+
// compiler anyway.
|
|
77
|
+
//
|
|
78
|
+
assign_wire_ids(lnodes);
|
|
79
|
+
fill_layers(c.get(), depth_ub, lnodes);
|
|
80
|
+
|
|
81
|
+
return c;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
// per-layer representation of nodes and terms
|
|
86
|
+
struct lterm {
|
|
87
|
+
Elt k;
|
|
88
|
+
quad_corner_t lop0, lop1;
|
|
89
|
+
};
|
|
90
|
+
struct lnode {
|
|
91
|
+
quad_corner_t desired_wire_id;
|
|
92
|
+
|
|
93
|
+
// Copy wires are forced to be distinct from wires in the
|
|
94
|
+
// original dag, in order to avoid ambiguity in renaming.
|
|
95
|
+
//
|
|
96
|
+
// Copy wires are always of the form 1*op, which doesn't
|
|
97
|
+
// normally appear in the dag because the algebraic simplifier
|
|
98
|
+
// reduces it to op. However, one can in theory create such
|
|
99
|
+
// a node by judicious use of linear(). Rather than
|
|
100
|
+
// trying to figure out which circuits one is not allowed
|
|
101
|
+
// to write, it seems simpler to just handle this case
|
|
102
|
+
// uniformly.
|
|
103
|
+
bool is_copy_wire;
|
|
104
|
+
|
|
105
|
+
std::vector<lterm> lterms;
|
|
106
|
+
|
|
107
|
+
lnode(quad_corner_t desired_wire_id, bool is_copy_wire,
|
|
108
|
+
const std::vector<lterm>& lterms)
|
|
109
|
+
: desired_wire_id(desired_wire_id),
|
|
110
|
+
is_copy_wire(is_copy_wire),
|
|
111
|
+
lterms(lterms) {}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
quad_corner_t lop_of_op_at_depth(
|
|
115
|
+
const std::vector<std::vector<quad_corner_t>>& lop, size_t op,
|
|
116
|
+
size_t d) const {
|
|
117
|
+
const node& n = nodes_.at(op);
|
|
118
|
+
return lop.at(op).at(d - n.info.depth);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Convert the DAG of nodes into a layered dag of lnodes.
|
|
122
|
+
std::vector<std::vector<lnode>> order_by_layer(
|
|
123
|
+
const std::vector<Elt>& constants, size_t depth_ub) {
|
|
124
|
+
// The source DAG is indexed by NODES_[OP].
|
|
125
|
+
// The destination dag uses a two-dimensional indexing
|
|
126
|
+
// scheme LNODES[D][LOP], where D is the depth.
|
|
127
|
+
|
|
128
|
+
// A single value NODES_[OP] may be replicated multiple times in
|
|
129
|
+
// LNODES. The mapping is maintained in array LOPS such that
|
|
130
|
+
// LOPS[OP][D - D0] contains the LOP index of node OP at depth D.
|
|
131
|
+
// D0 is the depth at which NODES_[OP] is first computed, and
|
|
132
|
+
// there is no point in storing LOPS[OP] for D < D0.
|
|
133
|
+
|
|
134
|
+
std::vector<std::vector<lnode>> lnodes(depth_ub);
|
|
135
|
+
std::vector<std::vector<quad_corner_t>> lops(nodes_.size());
|
|
136
|
+
|
|
137
|
+
nwires_overhead_ = 0;
|
|
138
|
+
|
|
139
|
+
for (size_t op = 0; op < nodes_.size(); ++op) {
|
|
140
|
+
const auto& n = nodes_[op];
|
|
141
|
+
const nodeinfo& nfo = n.info;
|
|
142
|
+
if (nfo.is_needed && !n.zero()) {
|
|
143
|
+
size_t d = nfo.depth;
|
|
144
|
+
|
|
145
|
+
// Allocate the LOP at depth D
|
|
146
|
+
quad_corner_t lop = quad_corner_t(lnodes.at(d).size());
|
|
147
|
+
lops.at(op).push_back(lop);
|
|
148
|
+
|
|
149
|
+
// create a LOPS entry for depth D
|
|
150
|
+
/*scope*/ {
|
|
151
|
+
std::vector<lterm> lterms;
|
|
152
|
+
for (const auto& t : n.terms) {
|
|
153
|
+
lterm lt = {
|
|
154
|
+
.k = constants.at(t.ki),
|
|
155
|
+
.lop0 = lop_of_op_at_depth(lops, t.op0, d - 1),
|
|
156
|
+
.lop1 = lop_of_op_at_depth(lops, t.op1, d - 1),
|
|
157
|
+
};
|
|
158
|
+
lterms.push_back(lt);
|
|
159
|
+
}
|
|
160
|
+
lnodes.at(d).push_back(lnode(nfo.desired_wire_id(d, depth_ub),
|
|
161
|
+
/*is_copy_wire=*/false, lterms));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// create copy wires
|
|
165
|
+
for (d = nfo.depth + 1; d < nfo.max_needed_depth; ++d) {
|
|
166
|
+
quad_corner_t lop_dm1 = lop;
|
|
167
|
+
|
|
168
|
+
// allocate the LOP at depth D
|
|
169
|
+
lop = quad_corner_t(lnodes.at(d).size());
|
|
170
|
+
lops.at(op).push_back(lop);
|
|
171
|
+
|
|
172
|
+
std::vector<lterm> lterms;
|
|
173
|
+
|
|
174
|
+
// Insert a multiplication by one of the layer
|
|
175
|
+
// at the previous layer.
|
|
176
|
+
lterm lt = {
|
|
177
|
+
.k = f_.one(),
|
|
178
|
+
.lop0 = quad_corner_t(0),
|
|
179
|
+
.lop1 = lop_dm1,
|
|
180
|
+
};
|
|
181
|
+
lterms.push_back(lt);
|
|
182
|
+
lnodes.at(d).push_back(lnode(nfo.desired_wire_id(d, depth_ub),
|
|
183
|
+
/*is_copy_wire=*/true, lterms));
|
|
184
|
+
++nwires_overhead_;
|
|
185
|
+
} // for copy wires
|
|
186
|
+
} // if needed
|
|
187
|
+
} // for OP
|
|
188
|
+
|
|
189
|
+
return lnodes;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//------------------------------------------------------------
|
|
193
|
+
// canonical assignment of wire ids
|
|
194
|
+
//------------------------------------------------------------
|
|
195
|
+
//
|
|
196
|
+
// The canonicalization order is a matter of convention.
|
|
197
|
+
// We make some arbitrary choices that appear to interact
|
|
198
|
+
// better with ZSTD compression. The label [ARBITRARY CHOICE]
|
|
199
|
+
// denotes all places in the code where this occurs.
|
|
200
|
+
//
|
|
201
|
+
class renamed_lterm {
|
|
202
|
+
public:
|
|
203
|
+
Elt k_;
|
|
204
|
+
quad_corner_t rlop0_, rlop1_;
|
|
205
|
+
|
|
206
|
+
// [ARBITRARY CHOICE] Consistent with corner::canonicalize() in
|
|
207
|
+
// sumcheck/quad.h
|
|
208
|
+
renamed_lterm(const Elt& k, quad_corner_t rlop0, quad_corner_t rlop1)
|
|
209
|
+
: k_(k),
|
|
210
|
+
rlop0_(std::min<quad_corner_t>(rlop0, rlop1)),
|
|
211
|
+
rlop1_(std::max<quad_corner_t>(rlop0, rlop1)) {}
|
|
212
|
+
|
|
213
|
+
bool operator==(const renamed_lterm& y) const {
|
|
214
|
+
return rlop0_ == y.rlop0_ && rlop1_ == y.rlop1_ && k_ == y.k_;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// canonical order
|
|
218
|
+
static bool compare(const renamed_lterm& a, const renamed_lterm& b,
|
|
219
|
+
const Field& F) {
|
|
220
|
+
if (a.rlop0_ < b.rlop0_) return true;
|
|
221
|
+
if (a.rlop0_ > b.rlop0_) return false;
|
|
222
|
+
if (a.rlop1_ < b.rlop1_) return true;
|
|
223
|
+
if (a.rlop1_ > b.rlop1_) return false;
|
|
224
|
+
return elt_less_than(a.k_, b.k_, F);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
class renamed_lnode {
|
|
229
|
+
public:
|
|
230
|
+
quad_corner_t desired_wire_id_;
|
|
231
|
+
quad_corner_t original_wire_index_;
|
|
232
|
+
bool is_copy_wire_;
|
|
233
|
+
std::vector<renamed_lterm> rlterms_;
|
|
234
|
+
|
|
235
|
+
renamed_lnode(quad_corner_t desired_wire_id,
|
|
236
|
+
quad_corner_t original_wire_index, bool is_copy_wire,
|
|
237
|
+
const std::vector<renamed_lterm>& rlterms)
|
|
238
|
+
: desired_wire_id_(desired_wire_id),
|
|
239
|
+
original_wire_index_(original_wire_index),
|
|
240
|
+
is_copy_wire_(is_copy_wire),
|
|
241
|
+
rlterms_(rlterms) {}
|
|
242
|
+
|
|
243
|
+
bool operator==(const renamed_lnode& y) const {
|
|
244
|
+
if (is_copy_wire_ != y.is_copy_wire_) return false;
|
|
245
|
+
if (rlterms_.size() != y.rlterms_.size()) return false;
|
|
246
|
+
size_t l = rlterms_.size();
|
|
247
|
+
for (size_t i = 0; i < l; ++i) {
|
|
248
|
+
if (!(rlterms_[i] == y.rlterms_[i])) return false;
|
|
249
|
+
}
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// canonical order
|
|
254
|
+
static bool compare(const renamed_lnode& ra, const renamed_lnode& rb,
|
|
255
|
+
const Field& F) {
|
|
256
|
+
// Defined before undefined. This choice is mandated by the
|
|
257
|
+
// fact that the range of defined wire id's starts at 0.
|
|
258
|
+
if (ra.desired_wire_id_ != nodeinfo::kWireIdUndefined) {
|
|
259
|
+
if (rb.desired_wire_id_ != nodeinfo::kWireIdUndefined) {
|
|
260
|
+
return ra.desired_wire_id_ < rb.desired_wire_id_;
|
|
261
|
+
} else {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
if (rb.desired_wire_id_ != nodeinfo::kWireIdUndefined) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
// else both undefined
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// [ARBITRARY CHOICE] Lexicographic order on the reverse of the
|
|
272
|
+
// terms array. This seems to compress much better than
|
|
273
|
+
// the normal lexicographic order.
|
|
274
|
+
for (size_t ia = ra.rlterms_.size(), ib = rb.rlterms_.size();
|
|
275
|
+
ia-- > 0 && ib-- > 0;) {
|
|
276
|
+
const renamed_lterm& rlta = ra.rlterms_[ia];
|
|
277
|
+
const renamed_lterm& rltb = rb.rlterms_[ib];
|
|
278
|
+
if (renamed_lterm::compare(rlta, rltb, F)) return true;
|
|
279
|
+
if (renamed_lterm::compare(rltb, rlta, F)) return false;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// [ARBITRARY CHOICE] If the common suffixes are the same, the
|
|
283
|
+
// shorter terms come first.
|
|
284
|
+
if (ra.rlterms_.size() < rb.rlterms_.size()) return true;
|
|
285
|
+
if (ra.rlterms_.size() > rb.rlterms_.size()) return false;
|
|
286
|
+
|
|
287
|
+
// Nodes that were in the original dag come first.
|
|
288
|
+
if (!ra.is_copy_wire_ && rb.is_copy_wire_) return true;
|
|
289
|
+
if (!rb.is_copy_wire_ && ra.is_copy_wire_) return false;
|
|
290
|
+
|
|
291
|
+
// equal, i.e., not less-than
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
template <class T>
|
|
297
|
+
bool uniq(const std::vector<T>& sorted) {
|
|
298
|
+
for (size_t i = 0; i + 1 < sorted.size(); ++i) {
|
|
299
|
+
if (sorted[i] == sorted[i + 1]) return false;
|
|
300
|
+
}
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void assign_wire_ids(std::vector<std::vector<lnode>>& lnodes) {
|
|
305
|
+
// all inputs are expected to be defined already
|
|
306
|
+
assert_all_desired_wire_id_defined(lnodes.at(0));
|
|
307
|
+
|
|
308
|
+
for (size_t d = 1; d < lnodes.size(); ++d) {
|
|
309
|
+
const std::vector<lnode>& lnodes_at_dm1 = lnodes.at(d - 1);
|
|
310
|
+
const std::vector<lnode>& lnodes_at_d = lnodes.at(d);
|
|
311
|
+
|
|
312
|
+
// Create a renamed clone of LNODES_AT_D, in which all
|
|
313
|
+
// the LOP's are mapped to their desired wire id's
|
|
314
|
+
// at the previous layer. We use different types
|
|
315
|
+
// to avoid any possibility of confusion.
|
|
316
|
+
std::vector<renamed_lnode> renamed_at_d;
|
|
317
|
+
|
|
318
|
+
quad_corner_t original_wire_index(0);
|
|
319
|
+
for (const lnode& ln : lnodes_at_d) {
|
|
320
|
+
std::vector<renamed_lterm> rlterms;
|
|
321
|
+
|
|
322
|
+
// rename all terms
|
|
323
|
+
rlterms.reserve(ln.lterms.size());
|
|
324
|
+
for (const lterm& lt : ln.lterms) {
|
|
325
|
+
rlterms.push_back(renamed_lterm(
|
|
326
|
+
lt.k,
|
|
327
|
+
lnodes_at_dm1.at(static_cast<size_t>(lt.lop0)).desired_wire_id,
|
|
328
|
+
lnodes_at_dm1.at(static_cast<size_t>(lt.lop1)).desired_wire_id));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// canonicalize the terms order
|
|
332
|
+
std::sort(rlterms.begin(), rlterms.end(),
|
|
333
|
+
[&](const renamed_lterm& a, const renamed_lterm& b) {
|
|
334
|
+
return renamed_lterm::compare(a, b, f_);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// Terms must be unique, otherwise the canonicalization is
|
|
338
|
+
// ill-defined. Uniqueness is guaranteed by the algebraic
|
|
339
|
+
// simplifier, but assert it for good measure.
|
|
340
|
+
check(uniq(rlterms), "rlterms not unique");
|
|
341
|
+
|
|
342
|
+
renamed_at_d.push_back(renamed_lnode(
|
|
343
|
+
ln.desired_wire_id, original_wire_index, ln.is_copy_wire, rlterms));
|
|
344
|
+
++original_wire_index;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
check(renamed_at_d.size() == lnodes_at_d.size(),
|
|
348
|
+
"renamed_at_d.size() == lnodes_at_d.size()");
|
|
349
|
+
|
|
350
|
+
std::sort(renamed_at_d.begin(), renamed_at_d.end(),
|
|
351
|
+
[&](const renamed_lnode& a, const renamed_lnode& b) {
|
|
352
|
+
return renamed_lnode::compare(a, b, f_);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Nodes must be unique, otherwise the canonicalization is
|
|
356
|
+
// ill-defined.
|
|
357
|
+
check(uniq(renamed_at_d), "renamed_at_d not unique");
|
|
358
|
+
|
|
359
|
+
quad_corner_t wid(0);
|
|
360
|
+
std::vector<lnode>& wlnodes_at_d = lnodes.at(d);
|
|
361
|
+
|
|
362
|
+
for (const renamed_lnode& ln : renamed_at_d) {
|
|
363
|
+
lnode& lnpi =
|
|
364
|
+
wlnodes_at_d.at(static_cast<size_t>(ln.original_wire_index_));
|
|
365
|
+
if (lnpi.desired_wire_id != nodeinfo::kWireIdUndefined) {
|
|
366
|
+
// We must have computed the same wire id
|
|
367
|
+
check(wid == lnpi.desired_wire_id, "wid == lnpi.desired_wire_id");
|
|
368
|
+
} else {
|
|
369
|
+
lnpi.desired_wire_id = wid;
|
|
370
|
+
}
|
|
371
|
+
wid++;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
void assert_all_desired_wire_id_defined(const std::vector<lnode>& layer) {
|
|
377
|
+
for (const auto& ln : layer) {
|
|
378
|
+
check(ln.desired_wire_id != nodeinfo::kWireIdUndefined,
|
|
379
|
+
"ln.desired_wire_id != kWireIdUndefined");
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
void fill_layers(Circuit<Field>* c, size_t depth_ub,
|
|
384
|
+
const std::vector<std::vector<lnode>>& lnodes) {
|
|
385
|
+
check(depth_ub == lnodes.size(), "depth_ub == lnodes.size()");
|
|
386
|
+
|
|
387
|
+
corner_t nv = corner_t(lnodes.at(depth_ub - 1).size());
|
|
388
|
+
|
|
389
|
+
nwires_ = nv;
|
|
390
|
+
c->nv = nv;
|
|
391
|
+
c->logv = lg(nv);
|
|
392
|
+
|
|
393
|
+
// d-- > 1 (not 0) because depth 0 denotes input nodes, not a layer.
|
|
394
|
+
// Sumcheck counts layers starting from the output, hence the loop
|
|
395
|
+
// counts downwards.
|
|
396
|
+
for (size_t d = depth_ub; d-- > 1;) {
|
|
397
|
+
corner_t nw =
|
|
398
|
+
corner_t(lnodes.at(d - 1).size()); // inputs[d] == outputs[d-1]
|
|
399
|
+
nwires_ += nw;
|
|
400
|
+
c->l.push_back(
|
|
401
|
+
Layer<Field>{.nw = nw,
|
|
402
|
+
.logw = lg(nw),
|
|
403
|
+
.quad = mkquad(lnodes.at(d), lnodes.at(d - 1))});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
std::unique_ptr<const Quad<Field>> mkquad(
|
|
408
|
+
const std::vector<lnode>& lnodes0, // wires at this layer
|
|
409
|
+
const std::vector<lnode>& lnodes1 // wires at the previous layer
|
|
410
|
+
) {
|
|
411
|
+
size_t nterms0 = 0;
|
|
412
|
+
for (const auto& ln0 : lnodes0) {
|
|
413
|
+
nterms0 += ln0.lterms.size();
|
|
414
|
+
}
|
|
415
|
+
nquad_terms_ += nterms0;
|
|
416
|
+
|
|
417
|
+
auto S = std::make_unique<EQuad<Field>>(nterms0);
|
|
418
|
+
size_t i = 0;
|
|
419
|
+
for (const auto& ln0 : lnodes0) {
|
|
420
|
+
for (const auto& lt : ln0.lterms) {
|
|
421
|
+
S->ec_[i++] = typename EQuad<Field>::ecorner{
|
|
422
|
+
.g = ln0.desired_wire_id,
|
|
423
|
+
.h = {lnodes1.at(static_cast<size_t>(lt.lop0)).desired_wire_id,
|
|
424
|
+
lnodes1.at(static_cast<size_t>(lt.lop1)).desired_wire_id},
|
|
425
|
+
.v = lt.k};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
S->canonicalize(f_);
|
|
429
|
+
return QuadBuilder<Field>::compress(S.get(), f_);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
} // namespace proofs
|
|
434
|
+
|
|
435
|
+
#endif // PRIVACY_PROOFS_ZK_LIB_CIRCUITS_COMPILER_SCHEDULE_H_
|