From 6fdee7166798046438dda8603b76d05809f8b905 Mon Sep 17 00:00:00 2001 From: therealyingtong Date: Mon, 21 Jun 2021 23:27:13 +0800 Subject: [PATCH] Adjustments to APIs in sinsemilla::chip and sinsemilla::message. --- src/circuit/gadget/sinsemilla/chip.rs | 12 +++++++++--- src/circuit/gadget/sinsemilla/message.rs | 22 +++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/circuit/gadget/sinsemilla/chip.rs b/src/circuit/gadget/sinsemilla/chip.rs index ae70da58..1f3be1fc 100644 --- a/src/circuit/gadget/sinsemilla/chip.rs +++ b/src/circuit/gadget/sinsemilla/chip.rs @@ -60,13 +60,19 @@ pub struct SinsemillaConfig { lambda_2: Column, /// The lookup table where $(\mathsf{idx}, x_p, y_p)$ are loaded for the $2^K$ /// generators of the Sinsemilla hash. - generator_table: GeneratorTableConfig, + pub(super) generator_table: GeneratorTableConfig, /// Fixed column shared by the whole circuit. This is used to load the /// x-coordinate of the domain $Q$, which is then constrained to equal the /// initial $x_a$. constants: Column, - /// Permutation over all advice columns and the `constants` fixed column. - perm: Permutation, + // Permutation over all advice columns and the `constants` fixed column. + pub(super) perm: Permutation, +} + +impl SinsemillaConfig { + pub fn advices(&self) -> [Column; 5] { + [self.bits, self.lambda_1, self.lambda_2, self.x_a, self.x_p] + } } #[derive(Eq, PartialEq, Clone, Debug)] diff --git a/src/circuit/gadget/sinsemilla/message.rs b/src/circuit/gadget/sinsemilla/message.rs index 20616123..ac2926d9 100644 --- a/src/circuit/gadget/sinsemilla/message.rs +++ b/src/circuit/gadget/sinsemilla/message.rs @@ -34,25 +34,17 @@ impl std:: /// cannot exceed the base field's `NUM_BITS`. #[derive(Copy, Clone, Debug)] pub struct MessagePiece { - cell: Cell, - field_elem: Option, + cell_value: CellValue, /// The number of K-bit words in this message piece. num_words: usize, } -#[allow(clippy::from_over_into)] -impl Into> for MessagePiece { - fn into(self) -> CellValue { - CellValue::new(self.cell(), self.field_elem()) - } -} - impl MessagePiece { pub fn new(cell: Cell, field_elem: Option, num_words: usize) -> Self { assert!(num_words * K < F::NUM_BITS as usize); + let cell_value = CellValue::new(cell, field_elem); Self { - cell, - field_elem, + cell_value, num_words, } } @@ -62,10 +54,14 @@ impl MessagePiece { } pub fn cell(&self) -> Cell { - self.cell + self.cell_value.cell() } pub fn field_elem(&self) -> Option { - self.field_elem + self.cell_value.value() + } + + pub fn cell_value(&self) -> CellValue { + self.cell_value } }