-
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(c/zk): add c API for
crypto::FRIProof
- Loading branch information
Showing
4 changed files
with
109 additions
and
1 deletion.
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,23 @@ | ||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_fri_proof.h" | ||
|
||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_fri_proof_type_traits.h" | ||
|
||
using namespace tachyon; | ||
|
||
using Proof = crypto::FRIProof<c::zk::air::plonky3::baby_bear::PCS::Base>; | ||
|
||
tachyon_sp1_baby_bear_poseidon2_fri_proof* | ||
tachyon_sp1_baby_bear_poseidon2_fri_proof_create() { | ||
return c::base::c_cast(new Proof()); | ||
} | ||
|
||
tachyon_sp1_baby_bear_poseidon2_fri_proof* | ||
tachyon_sp1_baby_bear_poseidon2_fri_proof_clone( | ||
const tachyon_sp1_baby_bear_poseidon2_fri_proof* fri_proof) { | ||
return c::base::c_cast(new Proof(c::base::native_cast(*fri_proof))); | ||
} | ||
|
||
void tachyon_sp1_baby_bear_poseidon2_fri_proof_destroy( | ||
tachyon_sp1_baby_bear_poseidon2_fri_proof* fri_proof) { | ||
delete c::base::native_cast(fri_proof); | ||
} |
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,54 @@ | ||
/** | ||
* @file baby_bear_poseidon2_fri_proof.h | ||
* @brief Defines the interface for the fri proof used within the | ||
* SP1(BabyBear + Poseidon2) proof system. | ||
*/ | ||
|
||
#ifndef TACHYON_C_ZK_AIR_SP1_BABY_BEAR_POSEIDON2_FRI_PROOF_H_ | ||
#define TACHYON_C_ZK_AIR_SP1_BABY_BEAR_POSEIDON2_FRI_PROOF_H_ | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include "tachyon/c/export.h" | ||
|
||
struct tachyon_sp1_baby_bear_poseidon2_fri_proof {}; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Creates a new fri proof. | ||
* | ||
* @return A pointer to the newly created fri proof. | ||
*/ | ||
TACHYON_C_EXPORT tachyon_sp1_baby_bear_poseidon2_fri_proof* | ||
tachyon_sp1_baby_bear_poseidon2_fri_proof_create(); | ||
|
||
/** | ||
* @brief Clones an existing fri proof. | ||
* | ||
* Creates a deep copy of the given fri proof. | ||
* | ||
* @param fri_proof A const pointer to the fri proof to | ||
* clone. | ||
* @return A pointer to the cloned fri proof. | ||
*/ | ||
TACHYON_C_EXPORT tachyon_sp1_baby_bear_poseidon2_fri_proof* | ||
tachyon_sp1_baby_bear_poseidon2_fri_proof_clone( | ||
const tachyon_sp1_baby_bear_poseidon2_fri_proof* fri_proof); | ||
|
||
/** | ||
* @brief Destroys a fri proof, freeing its resources. | ||
* | ||
* @param proof A pointer to the fri proof to destroy. | ||
*/ | ||
TACHYON_C_EXPORT void tachyon_sp1_baby_bear_poseidon2_fri_proof_destroy( | ||
tachyon_sp1_baby_bear_poseidon2_fri_proof* proof); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // TACHYON_C_ZK_AIR_SP1_BABY_BEAR_POSEIDON2_FRI_PROOF_H_ |
25 changes: 25 additions & 0 deletions
25
tachyon/c/zk/air/sp1/baby_bear_poseidon2_fri_proof_type_traits.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,25 @@ | ||
#ifndef TACHYON_C_ZK_AIR_SP1_BABY_BEAR_POSEIDON2_FRI_PROOF_TYPE_TRAITS_H_ | ||
#define TACHYON_C_ZK_AIR_SP1_BABY_BEAR_POSEIDON2_FRI_PROOF_TYPE_TRAITS_H_ | ||
|
||
#include "tachyon/c/base/type_traits_forward.h" | ||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_fri_proof.h" | ||
#include "tachyon/c/zk/air/sp1/baby_bear_poseidon2_two_adic_fri_type_traits.h" | ||
#include "tachyon/crypto/commitments/fri/fri_proof.h" | ||
|
||
namespace tachyon::c::base { | ||
|
||
template <> | ||
struct TypeTraits< | ||
tachyon::crypto::FRIProof<zk::air::plonky3::baby_bear::PCS::Base>> { | ||
using CType = tachyon_sp1_baby_bear_poseidon2_fri_proof; | ||
}; | ||
|
||
template <> | ||
struct TypeTraits<tachyon_sp1_baby_bear_poseidon2_fri_proof> { | ||
using NativeType = | ||
tachyon::crypto::FRIProof<zk::air::plonky3::baby_bear::PCS::Base>; | ||
}; | ||
|
||
} // namespace tachyon::c::base | ||
|
||
#endif // TACHYON_C_ZK_AIR_SP1_BABY_BEAR_POSEIDON2_FRI_PROOF_TYPE_TRAITS_H_ |