Skip to content

Commit 8ab5b2d

Browse files
committed
refactor: change Signature to AggregateSignature, regular indexes and tags as ScalarField
Signed-off-by: pedro bufulin <pedro@semiotic.ai>
1 parent c54ac50 commit 8ab5b2d

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

h2s2/src/holographic_homomorphic_signature_scheme.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ pub trait HolographicHomomorphicSignatureScheme<P: Pairing, D: Digest + Send + S
1010
type Signature;
1111
type Message;
1212
type Weight;
13+
type AggregateSignature;
1314

1415
/// Generate one G2 element and `n` G1 elements
1516
fn setup<R: Rng>(rng: &mut R, n: usize) -> Result<Self::Parameters, Box<dyn Error>>;
1617

17-
/// Generate hash aggregate (H_a) with `tag` and `n` lanes
18-
/// the `tag` is supposed to be the allocation_id
19-
/// We can also generate the allocation_id with a scalar field:
20-
fn precompute(pp: &Self::Parameters, tag: &[u8], n: usize) -> Result<P::G1, Box<dyn Error>>;
18+
/// Generate hash aggregate (H_a) with `tag` and `n` lanes, and a
19+
/// allocation_id as a ScalarField
20+
fn precompute<R: Rng>(
21+
pp: &Self::Parameters,
22+
rng: &mut R,
23+
n: usize,
24+
) -> Result<(P::G1, P::ScalarField), Box<dyn Error>>;
2125

2226
/// Generate private and public receipt keys using `pp` parameters from `setup`
2327
fn keygen<R: Rng>(
@@ -28,36 +32,34 @@ pub trait HolographicHomomorphicSignatureScheme<P: Pairing, D: Digest + Send + S
2832
/// Sign `message` with `tag` at `index`
2933
fn sign(
3034
pp: &Self::Parameters,
31-
sk: &Self::SecretKey,
32-
tag: &[u8],
33-
index: &[u8],
34-
message: &[Self::Message],
35+
tag: P::ScalarField,
36+
index: usize,
37+
message: Self::Message,
3538
) -> Result<Self::Signature, Box<dyn Error>>;
3639

3740
/// Verify a single `signature` matches `message` with `tag` at `index` using `pp` parameter and `pk` public key
3841
/// TODO: index should be restricted to a number from 1 to N (max number of lanes)
3942
fn verify(
4043
pp: &Self::Parameters,
41-
pk: &Self::PublicKey,
42-
tag: &[u8],
43-
index: &[u8],
44-
message: &[Self::Message],
44+
tag: P::ScalarField,
45+
index: usize,
46+
message: &Self::Message,
4547
signature: &Self::Signature,
4648
) -> Result<bool, Box<dyn Error>>;
4749

48-
/// Verify aggregate `signature` matches `message_aggregate` with `tag` and `hash_aggregate` using `pp` parameter and `pk` public key
50+
// Verify aggregate `signature` matches `message_aggregate` with `tag` and `hash_aggregate` using `pp` parameter and `pk` public key
4951
fn verify_aggregate(
5052
pp: &Self::Parameters,
5153
pk: &Self::PublicKey,
5254
// tag: &[u8],
5355
message_aggregate: &[Self::Message],
5456
hash_aggregate: &P::G1,
55-
signature: &Self::Signature,
57+
signature: &Self::AggregateSignature,
5658
) -> Result<bool, Box<dyn Error>>;
5759

5860
/// Aggregate `signatures` with `weights`
5961
fn evaluate(
6062
signatures: &[Self::Signature],
6163
weights: &[Self::Weight],
62-
) -> Result<Self::Signature, Box<dyn Error>>;
64+
) -> Result<Self::AggregateSignature, Box<dyn Error>>;
6365
}

0 commit comments

Comments
 (0)