Skip to content

Commit d529716

Browse files
committed
template out methods for orion pcs
1 parent d559a0d commit d529716

File tree

1 file changed

+66
-6
lines changed

1 file changed

+66
-6
lines changed

gkr/src/poly_commit/orion.rs

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ pub struct OrionCode {
182182
pub g1s: Vec<OrionExpanderGraphPositioned>,
183183
}
184184

185+
pub type OrionCodeword<F> = Vec<F>;
186+
185187
impl OrionCode {
186188
pub fn new(params: OrionCodeParameter, mut rng: impl rand::RngCore) -> Self {
187189
let mut recursive_code_msg_code_starts: Vec<(usize, usize)> = Vec::new();
@@ -241,7 +243,7 @@ impl OrionCode {
241243
}
242244

243245
#[inline(always)]
244-
pub fn encode<F: Field>(&self, msg: &[F]) -> OrionResult<Vec<F>> {
246+
pub fn encode<F: Field>(&self, msg: &[F]) -> OrionResult<OrionCodeword<F>> {
245247
if msg.len() != self.msg_len() {
246248
return Err(OrionPCSError::ParameterUnmatchError);
247249
}
@@ -264,8 +266,66 @@ impl OrionCode {
264266
* IMPLEMENTATIONS FOR ORION POLYNOMIAL COMMITMENT SCHEME *
265267
**********************************************************/
266268

267-
// TODO multilinear polynomial
268-
// TODO write to matrix, encode each row (k x k matrix)
269-
// TODO need a merkle tree to commit each column (k x n matrix)
270-
// - TODO need a cache friendly transpose
271-
// TODO need a merkle tree to commit against all merkle tree roots
269+
#[derive(Clone)]
270+
pub struct OrionPCSImpl {
271+
pub num_variables: usize,
272+
273+
pub code_instance: OrionCode,
274+
}
275+
276+
// TODO use interleaved codeword and commit against interleaved alphabets
277+
#[allow(unused)]
278+
type InterleavedOrionCodeword<F> = Vec<OrionCodeword<F>>;
279+
280+
impl OrionPCSImpl {
281+
// TODO: check num_variables ~ code_params.msg_len()
282+
pub fn new(num_variables: usize, code_instance: OrionCode) -> Self {
283+
// NOTE: we just move the instance of code,
284+
// don't think the instance of expander code will be used elsewhere
285+
Self {
286+
num_variables,
287+
code_instance,
288+
}
289+
}
290+
291+
// TODO: check num_variables ~ code_params.msg_len()
292+
pub fn from_random(
293+
num_variables: usize,
294+
code_params: OrionCodeParameter,
295+
mut rng: impl rand::RngCore,
296+
) -> Self {
297+
Self {
298+
num_variables,
299+
code_instance: OrionCode::new(code_params, &mut rng),
300+
}
301+
}
302+
303+
// TODO query complexity for how many queries one need for interleaved codeword
304+
pub fn query_complexity(#[allow(unused)] soundness_bits: usize) -> usize {
305+
todo!()
306+
}
307+
308+
// TODO multilinear polynomial
309+
// TODO write to matrix, encode each row (k x k matrix)
310+
// TODO need a merkle tree to commit each column (k x n matrix)
311+
// - TODO need a cache friendly transpose
312+
// TODO need a merkle tree to commit against all merkle tree roots
313+
// TODO commitment with data
314+
pub fn commit() {
315+
todo!()
316+
}
317+
318+
// TODO fiat-shamir challenge
319+
// TODO random evaluation point
320+
// TODO define orion proof structure
321+
pub fn open() {
322+
todo!()
323+
}
324+
325+
// TODO after open gets implemented
326+
pub fn verify() {
327+
todo!()
328+
}
329+
}
330+
331+
// TODO waiting on a unified multilinear PCS trait - align OrionPCSImpl against PCS trait

0 commit comments

Comments
 (0)