Skip to content

Commit 8a1b0b4

Browse files
committed
Update readme
Signed-off-by: lovesh <[email protected]>
1 parent 9418406 commit 8a1b0b4

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

delg_cred_cdd/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Brief description of the API
66
1. [Groth1 and Groth2 signatures](src/groth_sig.rs).
7-
- Parameters can be generated by calling `GrothS1::setup` or `GrothS2::setup`. `setup` takes the maximum nuber of attributes that need to be supported. Keep it one more than the number you want to support to accomodate the public key.
7+
- Parameters can be generated by calling `GrothS1::setup` or `GrothS2::setup`. `setup` takes the maximum number of attributes that need to be supported. Keep it one more than the number you want to support to accomodate the public key.
88
- Signing keys can be generated by calling `GrothS1::keygen` or `GrothS2::keygen`. Takes the corresponding setup parameters.
99
- A new signature can be created by calling `Groth1Sig:new` or `Groth2Sig:new`. An existing signature can be randomized by calling `randomize` on the siganture.
1010
- 2 methods for signature verification, `verify` and `verify_fast`, both with the same API. `verify` computes several pairings to verify the signature whereas `verify_fast` does only 1 big multi-pairing. Applies this observation to pairings: if it needs to be cheched that a == b and c == d and e == f, then choose a random number `r` and check whether (a-b) + (c-d)*r + (e-f)*r<sup>2</sup> == 0. Refer the docs for the method for more details
@@ -43,4 +43,4 @@ RUST_TEST_THREADS=1 cargo test --release -- --nocapture
4343
```
4444

4545
### Pending
46-
1. Fix TODOs in code for more input validation and optimizations
46+
1. Add support for verifying the attribute token with a single multi-pairing as suggested in the TODO.

delg_cred_cdd/src/attribute_token.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ impl<'a> AttributeToken<'a> {
264264
let unrevealed_attr_count =
265265
link.attribute_count() - at.odd_level_revealed_attributes[i / 2].len() - 1;
266266

267-
/*assert_eq!(self.blindings_t[i - 1].len(), link.signature.T.len());
268-
assert_eq!(link.attribute_count(), link.signature.T.len());
269-
assert_eq!(self.blindings_a[i - 1].len(), unrevealed_attr_count);*/
270267
check_blindings_count!(self, i, link, unrevealed_attr_count)?;
271268

272269
let mut resp_t = G1Vector::with_capacity(link.attribute_count());
@@ -321,9 +318,6 @@ impl<'a> AttributeToken<'a> {
321318
- at.even_level_revealed_attributes[(i / 2) - 1].len()
322319
- 1;
323320

324-
/*assert_eq!(self.blindings_t[i - 1].len(), link.signature.T.len());
325-
assert_eq!(link.attribute_count(), link.signature.T.len());
326-
assert_eq!(self.blindings_a[i - 1].len(), unrevealed_attr_count);*/
327321
check_blindings_count!(self, i, link, unrevealed_attr_count)?;
328322

329323
let mut resp_t = G2Vector::with_capacity(link.attribute_count());
@@ -732,6 +726,13 @@ impl<'a> AttributeToken<'a> {
732726
GT::mul(&e_1, &e_2)
733727
};
734728

729+
if revealed[i - 1].len() > self.setup_params_1.y.len() {
730+
return Err(DelgError::MoreAttributesThanExpected {
731+
expected: self.setup_params_1.y.len(),
732+
given: revealed[i - 1].len(),
733+
});
734+
}
735+
735736
let unrevealed_attr_count = link.attribute_count() - revealed[i - 1].len();
736737
let mut r_t = FieldElementVector::with_capacity(link.attribute_count());
737738
let mut r_a = FieldElementVector::with_capacity(unrevealed_attr_count);
@@ -810,6 +811,13 @@ impl<'a> AttributeToken<'a> {
810811
);
811812
let com_i_s = GT::mul(&e_1, &e_2);
812813

814+
if revealed[i - 1].len() > self.setup_params_2.y.len() {
815+
return Err(DelgError::MoreAttributesThanExpected {
816+
expected: self.setup_params_2.y.len(),
817+
given: revealed[i - 1].len(),
818+
});
819+
}
820+
813821
let unrevealed_attr_count = link.attribute_count() - revealed[i - 1].len();
814822
let mut r_t = FieldElementVector::with_capacity(link.attribute_count());
815823
let mut r_a = FieldElementVector::with_capacity(unrevealed_attr_count);

delg_cred_cdd/src/groth_sig.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ impl GrothS1 {
9191
impl_GrothS_setup!(Groth1SetupParams, G1, G1Vector);
9292

9393
pub fn keygen(setup_params: &Groth1SetupParams) -> (Groth1Sigkey, Groth1Verkey) {
94-
// TODO: Take PRNG as argument
9594
let sk = FieldElement::random();
9695
let vk = &setup_params.g2 * &sk;
9796
(Groth1Sigkey(sk), Groth1Verkey(vk))
@@ -110,7 +109,6 @@ impl Groth1Sig {
110109
given: messages.len(),
111110
});
112111
}
113-
// TODO: Take PRNG as argument
114112
let r = FieldElement::random();
115113
let r_inv = r.inverse();
116114
let R = &setup_params.g2 * &r;
@@ -223,7 +221,6 @@ impl GrothS2 {
223221
impl_GrothS_setup!(Groth2SetupParams, G2, G2Vector);
224222

225223
pub fn keygen(setup_params: &Groth2SetupParams) -> (Groth2Sigkey, Groth2Verkey) {
226-
// TODO: Take PRNG as argument
227224
let sk = FieldElement::random();
228225
let vk = &setup_params.g1 * &sk;
229226
(Groth2Sigkey(sk), Groth2Verkey(vk))
@@ -242,7 +239,6 @@ impl Groth2Sig {
242239
given: messages.len(),
243240
});
244241
}
245-
// TODO: Take PRNG as argument
246242
let r = FieldElement::random();
247243
let r_inv = r.inverse();
248244
let R = &setup_params.g1 * &r;

delg_cred_cdd/src/issuer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use amcl_wrapper::group_elem::{GroupElement, GroupElementVector};
77
use amcl_wrapper::group_elem_g1::{G1LookupTable, G1Vector, G1};
88
use amcl_wrapper::group_elem_g2::{G2Vector, G2};
99

10-
// TODO: Think about making structs rather than type alias. The struct will also hold the level
1110
pub type EvenLevelSigkey = Groth1Sigkey;
1211
pub type EvenLevelVerkey = Groth1Verkey;
1312
pub type OddLevelSigkey = Groth2Sigkey;
@@ -107,7 +106,6 @@ impl CredLinkEven {
107106
}
108107

109108
impl CredChain {
110-
// TODO: Add an iterator that traverses the links in order of level by traversing both odd_links and even_links.
111109
pub fn new() -> Self {
112110
Self {
113111
odd_links: vec![],

0 commit comments

Comments
 (0)