1#include <gtest/gtest.h>
33 auto commitment = Commitment::one();
36 for (
auto& eval : evaluations) {
42 prover_transcript.send_to_verifier(
"data",
data);
43 prover_transcript.template get_challenge<FF>(
"alpha");
46 prover_transcript.send_to_verifier(
"scalar", scalar);
47 prover_transcript.send_to_verifier(
"commitment", commitment);
48 prover_transcript.template get_challenges<FF>(
"beta, gamma");
51 prover_transcript.send_to_verifier(
"univariate", univariate);
52 prover_transcript.template get_challenges<FF>(
"gamma",
"delta");
54 return prover_transcript.export_proof();
73 transcript.template receive_from_prover<FF>(
"data");
74 transcript.template get_challenge<FF>(
"alpha");
77 transcript.template receive_from_prover<FF>(
"scalar");
78 transcript.template receive_from_prover<Commitment>(
"commitment");
79 transcript.template get_challenges<FF>(
"beta, gamma");
82 transcript.template receive_from_prover<Univariate>(
"univariate");
83 transcript.template get_challenges<FF>(
"gamma",
"delta");
91TEST(RecursiveHonkTranscript, InterfacesMatch)
97 constexpr size_t LENGTH = 8;
101 auto proof_data = generate_mock_proof_data<NativeCurve, LENGTH>(prover_transcript);
105 native_transcript.load_proof(proof_data);
106 perform_mock_verifier_transcript_operations<NativeCurve, LENGTH>(native_transcript);
109 EXPECT_EQ(prover_transcript.get_manifest(), native_transcript.get_manifest());
115 perform_mock_verifier_transcript_operations<StdlibCurve, LENGTH>(transcript);
118 EXPECT_EQ(transcript.
get_manifest(), native_transcript.get_manifest());
129TEST(RecursiveHonkTranscript, ReturnValuesMatch)
144 const size_t LENGTH = 10;
146 for (
auto& eval : evaluations) {
152 prover_transcript.send_to_verifier(
"scalar", scalar);
153 prover_transcript.send_to_verifier(
"commitment", commitment);
154 prover_transcript.send_to_verifier(
"evaluations", evaluations);
155 prover_transcript.template get_challenges<FF>(
"alpha, beta");
156 auto proof_data = prover_transcript.export_proof();
160 native_transcript.load_proof(proof_data);
161 auto native_scalar = native_transcript.template receive_from_prover<FF>(
"scalar");
162 auto native_commitment = native_transcript.template receive_from_prover<Commitment>(
"commitment");
163 auto native_evaluations = native_transcript.template receive_from_prover<std::array<FF, LENGTH>>(
"evaluations");
164 auto [native_alpha, native_beta] = native_transcript.template get_challenges<FF>(
"alpha",
"beta");
170 auto stdlib_scalar = stdlib_transcript.template receive_from_prover<field_ct>(
"scalar");
171 auto stdlib_commitment = stdlib_transcript.template receive_from_prover<element_ct>(
"commitment");
172 auto stdlib_evaluations =
173 stdlib_transcript.template receive_from_prover<std::array<field_ct, LENGTH>>(
"evaluations");
174 auto [stdlib_alpha, stdlib_beta] = stdlib_transcript.template get_challenges<field_ct>(
"alpha",
"beta");
177 EXPECT_EQ(native_scalar, stdlib_scalar.get_value());
178 EXPECT_EQ(native_commitment, stdlib_commitment.get_value());
179 for (
size_t i = 0; i < LENGTH; ++i) {
180 EXPECT_EQ(native_evaluations[i], stdlib_evaluations[i].get_value());
183 EXPECT_EQ(
static_cast<FF>(native_alpha), stdlib_alpha.get_value());
184 EXPECT_EQ(
static_cast<FF>(native_beta), stdlib_beta.get_value());
192TEST(RecursiveTranscript, InfinityConsistencyGrumpkin)
195 using NativeCommitment =
typename NativeCurve::AffineElement;
196 using NativeFF = NativeCurve::ScalarField;
203 NativeCommitment infinity = NativeCommitment::infinity();
206 prover_transcript.send_to_verifier(
"infinity", infinity);
207 NativeFF challenge = prover_transcript.get_challenge<NativeFF>(
"challenge");
208 auto proof_data = prover_transcript.export_proof();
211 verifier_transcript.load_proof(proof_data);
212 verifier_transcript.receive_from_prover<NativeCommitment>(
"infinity");
213 auto verifier_challenge = verifier_transcript.get_challenge<NativeFF>(
"challenge");
219 EXPECT_TRUE(stdlib_infinity.is_point_at_infinity().get_value());
220 auto stdlib_challenge = stdlib_transcript.
get_challenge<
FF>(
"challenge");
222 EXPECT_EQ(challenge, verifier_challenge);
223 EXPECT_EQ(verifier_challenge, NativeFF(stdlib_challenge.get_value() %
FF::modulus));
231TEST(RecursiveTranscript, InfinityConsistencyBN254)
234 using NativeCommitment =
typename NativeCurve::AffineElement;
235 using NativeFF = NativeCurve::ScalarField;
243 NativeCommitment infinity = NativeCommitment::infinity();
246 prover_transcript.send_to_verifier(
"infinity", infinity);
247 NativeFF challenge = prover_transcript.get_challenge<NativeFF>(
"challenge");
248 auto proof_data = prover_transcript.export_proof();
251 verifier_transcript.load_proof(proof_data);
252 verifier_transcript.receive_from_prover<NativeCommitment>(
"infinity");
253 auto verifier_challenge = verifier_transcript.get_challenge<NativeFF>(
"challenge");
259 EXPECT_TRUE(stdlib_commitment.is_point_at_infinity().get_value());
260 auto stdlib_challenge = stdlib_transcript.
get_challenge<
FF>(
"challenge");
262 EXPECT_EQ(challenge, verifier_challenge);
263 EXPECT_EQ(verifier_challenge, stdlib_challenge.get_value());
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
TranscriptManifest get_manifest() const
ChallengeType get_challenge(const std::string &label)
T receive_from_prover(const std::string &label)
Reads the next element of type T from the transcript, with a predefined label, only used by verifier.
void load_proof(const std::vector< DataType > &proof)
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
typename Group::affine_element AffineElement
group_elements::affine_element< Fq, Fr, Params > affine_element
A simple wrapper around a vector of stdlib field elements representing a proof.
cycle_group represents a group Element of the proving system's embedded curve, i.e....
const std::vector< FF > data
auto generate_mock_proof_data(auto prover_transcript)
Create some mock data; add it to the provided prover transcript in various mock rounds.
void perform_mock_verifier_transcript_operations(auto transcript)
Perform series of verifier transcript operations.
TEST(RecursiveHonkTranscript, InterfacesMatch)
Test basic transcript functionality and check circuit.
NativeTranscript NativeTranscript
std::conditional_t< IsGoblinBigGroup< C, Fq, Fr, G >, element_goblin::goblin_element< C, goblin_field< C >, Fr, G >, element_default::element< C, Fq, Fr, G > > element
element wraps either element_default::element or element_goblin::goblin_element depending on parametr...
field< Bn254FrParams > fr
BaseTranscript< stdlib::StdlibCodec< stdlib::field_t< UltraCircuitBuilder > >, stdlib::poseidon2< UltraCircuitBuilder > > UltraStdlibTranscript
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static constexpr uint256_t modulus
static field random_element(numeric::RNG *engine=nullptr) noexcept