-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathmod.rs
62 lines (54 loc) · 1.64 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Implements a FRI polynomial commitment scheme.
//!
//! This is a protocol where the prover can commit on a set of polynomials and then prove their
//! opening on a set of points.
//! Note: This implementation is not really a polynomial commitment scheme, because we are not in
//! the unique decoding regime. This is enough for a STARK proof though, where we only want to imply
//! the existence of such polynomials, and are ok with having a small decoding list.
//! Note: Opened points cannot come from the commitment domain.
mod prover;
pub mod quotients;
mod utils;
mod verifier;
use serde::{Deserialize, Serialize};
pub use self::prover::{
CommitmentSchemeProof, CommitmentSchemeProver, CommitmentTreeProver, TreeBuilder,
};
pub use self::utils::TreeVec;
pub use self::verifier::CommitmentSchemeVerifier;
use super::fri::FriConfig;
#[derive(Copy, Debug, Clone, PartialEq, Eq)]
pub struct TreeSubspan {
pub tree_index: usize,
pub col_start: usize,
pub col_end: usize,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct PcsConfig {
pub pow_bits: u32,
pub fri_config: FriConfig,
}
impl Default for PcsConfig {
fn default() -> Self {
Self {
pow_bits: 5,
fri_config: FriConfig::new(0, 1, 3),
}
}
}
impl PcsConfig {
pub const fn security_bits(&self) -> u32 {
self.pow_bits + self.fri_config.security_bits()
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_security_bits() {
let config = super::PcsConfig {
pow_bits: 26,
fri_config: super::FriConfig::new(1, 1, 70),
};
assert!(config.security_bits() == 96);
}
}