forked from kroma-network/tachyon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kroma-network#419 from kroma-network/feat/enable-c…
…ircom-proof-generation-without-compilation feat(circom): enable circom proof generation without compilation
- Loading branch information
Showing
60 changed files
with
1,544 additions
and
844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2011 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef TACHYON_BASE_AUTO_RESET_H_ | ||
#define TACHYON_BASE_AUTO_RESET_H_ | ||
|
||
#include <utility> | ||
|
||
#include "tachyon/base/logging.h" | ||
// #include "base/memory/raw_ptr_exclusion.h" | ||
|
||
// base::AutoReset<> is useful for setting a variable to a new value only within | ||
// a particular scope. An base::AutoReset<> object resets a variable to its | ||
// original value upon destruction, making it an alternative to writing | ||
// "var = false;" or "var = old_val;" at all of a block's exit points. | ||
// | ||
// This should be obvious, but note that an base::AutoReset<> instance should | ||
// have a shorter lifetime than its scoped_variable, to prevent invalid memory | ||
// writes when the base::AutoReset<> object is destroyed. | ||
|
||
namespace tachyon::base { | ||
|
||
template <typename T> | ||
class [[maybe_unused, nodiscard]] AutoReset { | ||
public: | ||
template <typename U> | ||
AutoReset(T* scoped_variable, U&& new_value) | ||
: scoped_variable_(scoped_variable), | ||
original_value_( | ||
std::exchange(*scoped_variable_, std::forward<U>(new_value))) {} | ||
|
||
// A constructor that's useful for asserting the old value of | ||
// `scoped_variable`, especially when it's inconvenient to check this before | ||
// constructing the AutoReset object (e.g. in a class member initializer | ||
// list). | ||
template <typename U> | ||
AutoReset(T* scoped_variable, U&& new_value, const T& expected_old_value) | ||
: AutoReset(scoped_variable, new_value) { | ||
DCHECK_EQ(original_value_, expected_old_value); | ||
} | ||
|
||
AutoReset(AutoReset&& other) | ||
: scoped_variable_(std::exchange(other.scoped_variable_, nullptr)), | ||
original_value_(std::move(other.original_value_)) {} | ||
|
||
AutoReset& operator=(AutoReset&& rhs) { | ||
scoped_variable_ = std::exchange(rhs.scoped_variable_, nullptr); | ||
original_value_ = std::move(rhs.original_value_); | ||
return *this; | ||
} | ||
|
||
~AutoReset() { | ||
if (scoped_variable_) *scoped_variable_ = std::move(original_value_); | ||
} | ||
|
||
private: | ||
// `scoped_variable_` is not a raw_ptr<T> for performance reasons: Large | ||
// number of non-PartitionAlloc pointees + AutoReset is typically short-lived | ||
// (e.g. allocated on the stack). | ||
// RAW_PTR_EXCLUSION T* scoped_variable_; | ||
T* scoped_variable_; | ||
|
||
T original_value_; | ||
}; | ||
|
||
} // namespace tachyon::base | ||
|
||
#endif // TACHYON_BASE_AUTO_RESET_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2019 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "tachyon/base/auto_reset.h" | ||
|
||
#include <utility> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace tachyon::base { | ||
|
||
TEST(AutoReset, Move) { | ||
int value = 10; | ||
{ | ||
AutoReset<int> resetter1{&value, 20}; | ||
EXPECT_EQ(20, value); | ||
{ | ||
value = 15; | ||
AutoReset<int> resetter2 = std::move(resetter1); | ||
// Moving to a new resetter does not change the value; | ||
EXPECT_EQ(15, value); | ||
} | ||
// Moved-to `resetter2` is out of scoped, and resets to the original value | ||
// that was in moved-from `resetter1`. | ||
EXPECT_EQ(10, value); | ||
value = 105; | ||
} | ||
// Moved-from `resetter1` does not reset to anything. | ||
EXPECT_EQ(105, value); | ||
} | ||
|
||
} // namespace tachyon::base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
load("@kroma_network_tachyon//bazel:tachyon_cc.bzl", "tachyon_cc_binary") | ||
|
||
tachyon_cc_binary( | ||
name = "prover_main", | ||
srcs = ["prover_main.cc"], | ||
deps = [ | ||
"//circomlib/circuit:quadratic_arithmetic_program", | ||
"//circomlib/json", | ||
"//circomlib/json:groth16_proof", | ||
"//circomlib/json:prime_field", | ||
"//circomlib/wtns", | ||
"//circomlib/zkey", | ||
"@kroma_network_tachyon//tachyon/base/console", | ||
"@kroma_network_tachyon//tachyon/base/files:file_path_flag", | ||
"@kroma_network_tachyon//tachyon/base/flag:flag_parser", | ||
"@kroma_network_tachyon//tachyon/math/elliptic_curves/bls12/bls12_381", | ||
"@kroma_network_tachyon//tachyon/math/elliptic_curves/bn/bn254", | ||
"@kroma_network_tachyon//tachyon/math/polynomials/univariate:univariate_evaluation_domain_factory", | ||
"@kroma_network_tachyon//tachyon/zk/r1cs/groth16:prove", | ||
"@kroma_network_tachyon//tachyon/zk/r1cs/groth16:verify", | ||
], | ||
) |
Oops, something went wrong.