Skip to content

Commit

Permalink
add public keys into signature aggregation APIs (#238)
Browse files Browse the repository at this point in the history
* refactor aggregate APIs

* update changelog
  • Loading branch information
chancharles92 authored Apr 18, 2023
1 parent 3967921 commit e8e4644
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and follow [semantic versioning](https://semver.org/) for our releases.

### Changed

- [#238](https://github.com/EspressoSystems/jellyfish/pull/238) add public keys into signature aggregation APIs

### Removed

### Deprecated
Expand Down
4 changes: 4 additions & 0 deletions primitives/src/signatures/bls_over_bn254.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ impl SignatureScheme for BLSOverBN254CurveSignatureScheme {

impl AggregateableSignatureSchemes for BLSOverBN254CurveSignatureScheme {
/// Aggregate multiple signatures into a single signature
/// Follow the instantiation from <https://www.ietf.org/archive/id/draft-irtf-cfrg-bls-signature-05.html#name-aggregate>
fn aggregate(
_pp: &Self::PublicParameter,
_vks: &[Self::VerificationKey],
sigs: &[Self::Signature],
) -> Result<Self::Signature, PrimitivesError> {
if sigs.is_empty() {
Expand All @@ -144,6 +146,7 @@ impl AggregateableSignatureSchemes for BLSOverBN254CurveSignatureScheme {
/// Verify an aggregate signature w.r.t. a list of messages and public keys.
/// It is user's responsibility to ensure that the public keys are
/// validated.
/// Follow the instantiation from <https://www.ietf.org/archive/id/draft-irtf-cfrg-bls-signature-05.html#name-coreaggregateverify>
fn aggregate_verify<M: AsRef<[Self::MessageUnit]>>(
_pp: &Self::PublicParameter,
vks: &[Self::VerificationKey],
Expand Down Expand Up @@ -194,6 +197,7 @@ impl AggregateableSignatureSchemes for BLSOverBN254CurveSignatureScheme {
/// Verify a multisignature w.r.t. a single message and a list of public
/// keys. It is user's responsibility to ensure that the public keys are
/// validated.
/// Follow the instantiation from <https://www.ietf.org/archive/id/draft-irtf-cfrg-bls-signature-05.html#name-fastaggregateverify>
fn multi_sig_verify(
pp: &Self::PublicParameter,
vks: &[Self::VerificationKey],
Expand Down
7 changes: 5 additions & 2 deletions primitives/src/signatures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ pub trait SignatureScheme {
/// TODO: generic over hash functions
pub trait AggregateableSignatureSchemes: SignatureScheme {
/// Aggregate multiple signatures into a single signature
/// The list of public keys is also in the input as some aggregate signature
/// schemes might also use pks for aggregation
fn aggregate(
pp: &Self::PublicParameter,
vks: &[Self::VerificationKey],
sigs: &[Self::Signature],
) -> Result<Self::Signature, PrimitivesError>;

Expand Down Expand Up @@ -158,8 +161,8 @@ mod tests {
partial_sigs.push(partial_sig);
}
// happy paths
let agg_sig = S::aggregate(&parameters, &sigs).unwrap();
let multi_sig = S::aggregate(&parameters, &partial_sigs).unwrap();
let agg_sig = S::aggregate(&parameters, &pks, &sigs).unwrap();
let multi_sig = S::aggregate(&parameters, &pks, &partial_sigs).unwrap();
assert!(S::aggregate_verify(&parameters, &pks, messages, &agg_sig).is_ok());
assert!(S::multi_sig_verify(&parameters, &pks, message_for_msig, &multi_sig).is_ok());
// wrong messages length
Expand Down

0 comments on commit e8e4644

Please sign in to comment.