10template <
typename Codec,
typename HashFn>
21 this->test_scalar_send_receive();
26 this->test_basefield_send_receive();
31 this->test_bn254_commitment_send_receive();
36 this->test_grumpkin_commitment_send_receive();
41 this->
template test_array_send_receive<8>();
46 this->
template test_grumpkin_field_array_send_receive<7>();
51 this->
template test_univariate_send_receive<8>();
56 this->
template test_grumpkin_univariate_send_receive<3>();
65 this->test_bn254_infinity_handling();
70 this->test_grumpkin_infinity_handling();
79 this->test_multi_round_protocol();
84 this->test_manifest_consistency();
93 this->test_challenges_are_nonzero();
102 this->test_hash_buffer_consistency();
111 this->test_prover_to_verifier_conversion();
116 this->test_tampering_detection();
128 using FF =
typename TestFixture::FF;
134 auto [p_alpha, p_beta, p_gamma] = prover.template get_challenges<bb::fr>(labels);
136 typename TestFixture::Transcript verifier(this->export_proof(prover));
137 verifier.template receive_from_prover<FF>(
"data");
139 auto [v_alpha, v_beta, v_gamma] = verifier.template get_challenges<FF>(labels);
141 EXPECT_EQ(p_alpha, this->to_native(v_alpha));
142 EXPECT_EQ(p_beta, this->to_native(v_beta));
143 EXPECT_EQ(p_gamma, this->to_native(v_gamma));
145 this->check_circuit();
153 using FF =
typename TestFixture::FF;
158 std::vector<std::string> labels = {
"c1",
"c2",
"c3",
"c4",
"c5" };
159 auto prover_challenges = prover.template get_challenges<bb::fr>(labels);
161 typename TestFixture::Transcript verifier(this->export_proof(prover));
162 verifier.template receive_from_prover<FF>(
"init");
163 auto verifier_challenges = verifier.template get_challenges<FF>(labels);
165 ASSERT_EQ(prover_challenges.size(), verifier_challenges.size());
166 for (
size_t i = 0; i < prover_challenges.size(); ++i) {
167 EXPECT_EQ(prover_challenges[i], this->to_native(verifier_challenges[i]));
170 this->check_circuit();
178 using FF =
typename TestFixture::FF;
183 auto [p_alpha, p_beta, p_gamma] = prover.template get_short_challenges<bb::fr>(labels);
184 auto p_single = prover.template get_short_challenge<bb::fr>(
"delta");
186 typename TestFixture::Transcript verifier(this->export_proof(prover));
187 verifier.template receive_from_prover<FF>(
"data");
188 auto [v_alpha, v_beta, v_gamma] = verifier.template get_short_challenges<FF>(labels);
189 auto v_single = verifier.template get_short_challenge<FF>(
"delta");
191 EXPECT_EQ(p_alpha, this->to_native(v_alpha));
192 EXPECT_EQ(p_beta, this->to_native(v_beta));
193 EXPECT_EQ(p_gamma, this->to_native(v_gamma));
194 EXPECT_EQ(p_single, this->to_native(v_single));
196 this->check_circuit();
203TEST(TranscriptShortVsFull, ShortIsLowLimbOfFull)
215 EXPECT_EQ(short_challenge, NativeTranscript::Codec::split_challenge(full)[0]);
216 EXPECT_NE(short_challenge, full);
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
ChallengeType get_short_challenge(const std::string &label)
Generate a single short (127-bit) challenge for label. See get_short_challenges.
ChallengeType get_challenge(const std::string &label)
Generate a single full-width (~254-bit) challenge for label (the default). See get_challenges.
void send_to_verifier(const std::string &label, const T &element)
Adds a prover message to the transcript, only intended to be used by the prover.
constexpr T get_msb(const T in)
TYPED_TEST_SUITE(TranscriptTests, TranscriptTypes)
TEST(TranscriptShortVsFull, ShortIsLowLimbOfFull)
The full challenge is the raw hash; the matching short challenge is its low 127-bit limb....
TYPED_TEST(TranscriptTests, ScalarSendReceive)
::testing::Types< std::pair< NativeCodec, NativeHash >, std::pair< UltraCodec, UltraHash >, std::pair< MegaCodec, MegaHash > > TranscriptTypes
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept