-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- don't expose BFieldElement - include only a program's digest in the Claim, not the program itself - implement hashing of programs
- Loading branch information
1 parent
e687c16
commit dda05e4
Showing
10 changed files
with
169 additions
and
124 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
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 |
---|---|---|
@@ -1,21 +1,45 @@ | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use twenty_first::shared_math::b_field_element::BFieldElement; | ||
use twenty_first::shared_math::tip5::Digest; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct Proof(pub Vec<BFieldElement>); | ||
|
||
/// Contains the necessary cryptographic information to verify a computation. | ||
impl Proof { | ||
pub fn padded_height(&self) -> usize { | ||
// FIXME: This is very brittle. | ||
self.0[1].value() as usize | ||
} | ||
} | ||
|
||
/// Contains all the public information of a verifiably correct computation. | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct Claim { | ||
pub input: Vec<BFieldElement>, | ||
pub program: Vec<BFieldElement>, | ||
pub output: Vec<BFieldElement>, | ||
/// The public input to the computation. | ||
pub input: Vec<u64>, | ||
|
||
/// The hash digest of the program that was executed. The hash function in use is Tip5. | ||
pub program_digest: Digest, | ||
|
||
/// The public output of the computation. | ||
pub output: Vec<u64>, | ||
|
||
/// An upper bound on the length of the computation. | ||
pub padded_height: usize, | ||
} | ||
|
||
impl Claim { | ||
/// The public input as `BFieldElements`. | ||
/// If u64s are needed, use field `input`. | ||
pub fn public_input(&self) -> Vec<BFieldElement> { | ||
self.input.iter().map(|&x| BFieldElement::new(x)).collect() | ||
} | ||
|
||
/// The public output as `BFieldElements`. | ||
/// If u64s are needed, use field `output`. | ||
pub fn public_output(&self) -> Vec<BFieldElement> { | ||
self.output.iter().map(|&x| BFieldElement::new(x)).collect() | ||
} | ||
} |
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
Oops, something went wrong.