Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generalize transcript #202

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tachyon/crypto/commitments/kzg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ tachyon_cc_unittest(
deps = [
":shplonk",
"//tachyon/base/buffer:vector_buffer",
"//tachyon/crypto/transcripts:poseidon_transcript",
"//tachyon/math/elliptic_curves/bn/bn254:g1",
"//tachyon/math/elliptic_curves/bn/bn254:g2",
"//tachyon/math/polynomials/univariate:univariate_evaluation_domain_factory",
"//tachyon/zk/plonk/halo2:poseidon_transcript",
],
)
6 changes: 3 additions & 3 deletions tachyon/crypto/commitments/kzg/shplonk.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SHPlonk : public UnivariatePolynomialCommitmentScheme<
const absl::btree_set<PointDeepRef>& super_point_set =
grouper.super_point_set();

Field y = writer->SqueezeChallengeAsScalar();
Field y = writer->SqueezeChallenge();

// Create [H₀(X), H₁(X), H₂(X)].
// clang-format off
Expand All @@ -107,7 +107,7 @@ class SHPlonk : public UnivariatePolynomialCommitmentScheme<
y, low_degree_extensions_vec[i]);
});

Field v = writer->SqueezeChallengeAsScalar();
Field v = writer->SqueezeChallenge();

// Create a linear combination of polynomials [H₀(X), H₁(X), H₂(X)] with
// with |v|.
Expand All @@ -119,7 +119,7 @@ class SHPlonk : public UnivariatePolynomialCommitmentScheme<
if (!this->Commit(h_poly, &h)) return false;

CHECK(writer->WriteToProof(h));
Field u = writer->SqueezeChallengeAsScalar();
Field u = writer->SqueezeChallenge();

// Create [L₀(X), L₁(X), L₂(X)].
// L₀(X) = z₀ * ((P₀(X) - R₀(u)) + y(P₁(X) - R₁(u)) + y²(P₂(X) - R₂(u)))
Expand Down
6 changes: 3 additions & 3 deletions tachyon/crypto/commitments/kzg/shplonk_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "gtest/gtest.h"

#include "tachyon/crypto/transcripts/poseidon_transcript.h"
#include "tachyon/math/elliptic_curves/bn/bn254/g1.h"
#include "tachyon/math/elliptic_curves/bn/bn254/g2.h"
#include "tachyon/math/polynomials/univariate/univariate_evaluation_domain_factory.h"
#include "tachyon/zk/plonk/halo2/poseidon_transcript.h"

namespace tachyon::crypto {

Expand All @@ -33,7 +33,7 @@ class SHPlonkTest : public testing::Test {
void SetUp() override {
KZG<math::bn254::G1AffinePoint, kMaxDegree, math::bn254::G1AffinePoint> kzg;
base::VectorBuffer write_buf;
writer_ = PoseidonWriter<math::bn254::G1Curve>(std::move(write_buf));
writer_ = zk::halo2::PoseidonWriter<Commitment>(std::move(write_buf));
pcs_ = PCS(std::move(kzg), &writer_);
ASSERT_TRUE(pcs_.UnsafeSetup(N));

Expand Down Expand Up @@ -79,7 +79,7 @@ class SHPlonkTest : public testing::Test {
std::vector<Poly> polys_;
std::vector<F> points_;
std::vector<PolynomialOpening<Poly>> poly_openings_;
PoseidonWriter<math::bn254::G1Curve> writer_;
zk::halo2::PoseidonWriter<Commitment> writer_;
};

} // namespace
Expand Down
9 changes: 0 additions & 9 deletions tachyon/crypto/hashes/sponge/poseidon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ tachyon_cc_library(
],
)

tachyon_cc_library(
name = "halo2_poseidon",
hdrs = ["halo2_poseidon.h"],
deps = [
":poseidon",
"@local_config_gmp//:gmp",
],
)

tachyon_cc_library(
name = "poseidon_config",
hdrs = ["poseidon_config.h"],
Expand Down
51 changes: 7 additions & 44 deletions tachyon/crypto/transcripts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,59 +1,22 @@
load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")
load("//bazel:tachyon_cc.bzl", "tachyon_cc_library")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
name = "blake2b_transcript",
hdrs = ["blake2b_transcript.h"],
deps = [
":transcript",
"//tachyon/math/elliptic_curves:points",
"@com_google_boringssl//:crypto",
],
)

tachyon_cc_library(
name = "poseidon_transcript",
hdrs = ["poseidon_transcript.h"],
deps = [
":transcript",
"//tachyon/crypto/hashes/sponge/poseidon:halo2_poseidon",
"//tachyon/math/elliptic_curves:points",
],
)

tachyon_cc_library(
name = "sha256_transcript",
hdrs = ["sha256_transcript.h"],
deps = [
":transcript",
"//tachyon/base/ranges:algorithm",
"//tachyon/base/types:always_false",
"//tachyon/math/elliptic_curves:points",
"@com_google_boringssl//:crypto",
],
)

tachyon_cc_library(
name = "transcript",
hdrs = ["transcript.h"],
deps = [
":transcript_traits",
"//tachyon/base/buffer:vector_buffer",
"//tachyon/math/base:big_int",
],
)

tachyon_cc_unittest(
name = "transcript_unittests",
srcs = [
"blake2b_transcript_unittest.cc",
"poseidon_transcript_unittest.cc",
"sha256_transcript_unittest.cc",
],
tachyon_cc_library(
name = "transcript_traits",
hdrs = ["transcript_traits.h"],
deps = [
":blake2b_transcript",
":poseidon_transcript",
":sha256_transcript",
"//tachyon/math/elliptic_curves/bn/bn254:g1",
"//tachyon/math/elliptic_curves:points",
"//tachyon/math/finite_fields:prime_field_base",
],
)
79 changes: 0 additions & 79 deletions tachyon/crypto/transcripts/blake2b_transcript_unittest.cc

This file was deleted.

Loading