-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sp1): add rust binding for sp1 variant
TwoAdicFriPCS
initially
- Loading branch information
Showing
12 changed files
with
571 additions
and
134 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,42 @@ | ||
#ifndef VENDORS_SP1_INCLUDE_BABY_BEAR_POSEIDON2_PROVER_DATA_H_ | ||
#define VENDORS_SP1_INCLUDE_BABY_BEAR_POSEIDON2_PROVER_DATA_H_ | ||
|
||
#include <memory> | ||
|
||
#include "rust/cxx.h" | ||
|
||
#include "tachyon/c/math/finite_fields/baby_bear/baby_bear.h" | ||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_constants.h" | ||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_field_merkle_tree.h" | ||
|
||
namespace tachyon::sp1_api::baby_bear_poseidon2 { | ||
|
||
struct TachyonBabyBear; | ||
|
||
class ProverData { | ||
public: | ||
ProverData() = default; | ||
ProverData(tachyon_sp1_baby_bear_poseidon2_field_merkle_tree* tree, | ||
bool owned_tree) | ||
: tree_(tree), owned_tree_(owned_tree) {} | ||
ProverData(const ProverData& other) = delete; | ||
ProverData& operator=(const ProverData& other) = delete; | ||
~ProverData(); | ||
|
||
tachyon_baby_bear* commitment() { return commitment_; } | ||
tachyon_sp1_baby_bear_poseidon2_field_merkle_tree** tree_ptr() { | ||
return &tree_; | ||
} | ||
|
||
void write_commit(rust::Slice<TachyonBabyBear> values) const; | ||
std::unique_ptr<ProverData> clone() const; | ||
|
||
private: | ||
tachyon_baby_bear commitment_[TACHYON_PLONKY3_BABY_BEAR_POSEIDON2_CHUNK]; | ||
tachyon_sp1_baby_bear_poseidon2_field_merkle_tree* tree_ = nullptr; | ||
bool owned_tree_ = false; | ||
}; | ||
|
||
} // namespace tachyon::sp1_api::baby_bear_poseidon2 | ||
|
||
#endif // VENDORS_SP1_INCLUDE_BABY_BEAR_POSEIDON2_PROVER_DATA_H_ |
43 changes: 43 additions & 0 deletions
43
vendors/sp1/include/baby_bear_poseidon2_two_adic_fri_pcs.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,43 @@ | ||
#ifndef VENDORS_SP1_INCLUDE_BABY_BEAR_POSEIDON2_TWO_ADIC_FRI_PCS_H_ | ||
#define VENDORS_SP1_INCLUDE_BABY_BEAR_POSEIDON2_TWO_ADIC_FRI_PCS_H_ | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include <memory> | ||
|
||
#include "rust/cxx.h" | ||
|
||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_two_adic_fri_pcs.h" | ||
|
||
namespace tachyon::sp1_api::baby_bear_poseidon2 { | ||
|
||
class CommitResult; | ||
class ProverData; | ||
struct TachyonBabyBear; | ||
|
||
class TwoAdicFriPcs { | ||
public: | ||
TwoAdicFriPcs(size_t log_blowup, size_t num_queries, | ||
size_t proof_of_work_bits); | ||
TwoAdicFriPcs(const TwoAdicFriPcs& other) = delete; | ||
TwoAdicFriPcs& operator=(const TwoAdicFriPcs& other) = delete; | ||
~TwoAdicFriPcs(); | ||
|
||
void allocate_ldes(size_t size) const; | ||
rust::Slice<TachyonBabyBear> coset_lde_batch( | ||
rust::Slice<TachyonBabyBear> values, size_t cols, | ||
const TachyonBabyBear& shift) const; | ||
std::unique_ptr<ProverData> commit() const; | ||
|
||
private: | ||
tachyon_sp1_baby_bear_poseidon2_two_adic_fri_pcs* pcs_; | ||
}; | ||
|
||
std::unique_ptr<TwoAdicFriPcs> new_two_adic_fri_pcs(size_t log_blowup, | ||
size_t num_queries, | ||
size_t proof_of_work_bits); | ||
|
||
} // namespace tachyon::sp1_api::baby_bear_poseidon2 | ||
|
||
#endif // VENDORS_SP1_INCLUDE_BABY_BEAR_POSEIDON2_TWO_ADIC_FRI_PCS_H_ |
Oops, something went wrong.