Skip to content

Commit 6f6ddb6

Browse files
committed
Fixed the GroupMorphismPreimage structure to match the one in the sage implementation
1 parent 317dccc commit 6f6ddb6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/toolbox/sigma/group_morphism.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ where
5353
G: Group + GroupEncoding,
5454
{
5555
pub morphism: Morphism<G>,
56-
pub image: Vec<G>,
56+
pub image: Vec<usize>,
5757
_marker: PhantomData<G>,
5858
}
5959

@@ -76,7 +76,7 @@ where
7676
self.morphism.num_statements() * repr_len // total size of a commit
7777
}
7878

79-
pub fn append_equation(&mut self, lhs: G, rhs: &[(usize, usize)]) {
79+
pub fn append_equation(&mut self, lhs: usize, rhs: &[(usize, usize)]) {
8080
let lc = LinearCombinaison {
8181
scalar_indices: rhs.iter().map(|&(s, _)| s).collect(),
8282
element_indices: rhs.iter().map(|&(_, e)| e).collect(),
@@ -112,8 +112,8 @@ where
112112

113113
pub fn image(&self) -> Vec<G> {
114114
let mut result = Vec::new();
115-
for g in &(self.image) {
116-
result.push(g.clone());
115+
for i in &self.image {
116+
result.push(self.morphism.group_elements[*i].clone());
117117
}
118118
result
119119
}

src/toolbox/sigma/schnorr_proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ where
6060
let lhs = self.morphismp.morphism.evaluate(&response);
6161
let mut rhs = Vec::new();
6262
for i in 0..self.morphismp.morphism.num_scalars {
63-
rhs.push(commitment[i] + self.morphismp.image[i] * *challenge);
63+
rhs.push(commitment[i] + self.morphismp.morphism.group_elements[self.morphismp.image[i]] * *challenge);
6464
}
6565
lhs == rhs
6666
}

tests/non_interactive_protocol.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ fn fiat_shamir_schnorr_proof_ristretto() {
2525

2626
// Scalars and Points bases settings
2727
morphismp.allocate_scalars(1);
28-
morphismp.allocate_elements(1);
29-
morphismp.set_elements(&[(0, G)]);
28+
morphismp.allocate_elements(2);
29+
morphismp.set_elements(&[(0, G), (1, H)]);
3030

3131
// Set the witness Vec
3232
let mut witness = Vec::new();
3333
witness.push(w.clone());
3434

3535
// The H = z * G equeation where z is the unique scalar variable
36-
morphismp.append_equation(H, &[(0, 0)]);
36+
morphismp.append_equation(1, &[(0, 0)]);
3737

3838
// The SigmaProtocol induced by morphismp
3939
let protocol = SchnorrProof { morphismp };

0 commit comments

Comments
 (0)