Skip to content

Commit

Permalink
fix: passing bls pubkey by value
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-londhe committed Jan 15, 2025
1 parent 64fa085 commit 0f1efc7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions bls/bls-blst/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl SignatureTrait for Signature {
type PublicKey = PublicKey;

#[must_use]
fn verify(&self, message: impl AsRef<[u8]>, public_key: &Self::PublicKey) -> bool {
fn verify(&self, message: impl AsRef<[u8]>, public_key: Self::PublicKey) -> bool {
let result = self.as_raw().verify(
true,
message.as_ref(),
Expand Down Expand Up @@ -149,7 +149,7 @@ mod tests {
let public_key = SecretKey::to_public_key(&secret_key);
let signature = SecretKey::sign(&secret_key, MESSAGE);

assert!(Signature::verify(&signature, MESSAGE, &public_key));
assert!(Signature::verify(&signature, MESSAGE, public_key));
}

#[test]
Expand All @@ -158,7 +158,7 @@ mod tests {
let public_key = PublicKey::default();
let signature = SecretKey::sign(&secret_key, MESSAGE);

assert!(!Signature::verify(&signature, MESSAGE, &public_key));
assert!(!Signature::verify(&signature, MESSAGE, public_key));
}

#[test]
Expand All @@ -167,7 +167,7 @@ mod tests {
let public_key = SecretKey::to_public_key(&secret_key);
let signature = Signature::default();

assert!(!Signature::verify(&signature, MESSAGE, &public_key));
assert!(!Signature::verify(&signature, MESSAGE, public_key));
}

fn secret_key() -> SecretKey {
Expand Down
2 changes: 1 addition & 1 deletion bls/bls-core/src/traits/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ where
type SignatureBytes: SignatureBytesTrait;
type PublicKey: PublicKeyTrait;

fn verify(&self, message: impl AsRef<[u8]>, public_key: &Self::PublicKey) -> bool;
fn verify(&self, message: impl AsRef<[u8]>, public_key: Self::PublicKey) -> bool;

#[must_use]
fn aggregate(mut self, other: Self) -> Self {
Expand Down
8 changes: 4 additions & 4 deletions bls/bls-zkcrypto/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl SignatureTrait for Signature {
type PublicKey = PublicKey;

#[must_use]
fn verify(&self, message: impl AsRef<[u8]>, public_key: &Self::PublicKey) -> bool {
fn verify(&self, message: impl AsRef<[u8]>, public_key: Self::PublicKey) -> bool {
let h = <G2Projective as HashToCurve<ExpandMsgXmd<Sha256>>>::hash_to_curve(
&[message.as_ref()],
DOMAIN_SEPARATION_TAG,
Expand Down Expand Up @@ -145,7 +145,7 @@ mod tests {
let public_key = SecretKey::to_public_key(&secret_key);
let signature = SecretKey::sign(&secret_key, MESSAGE);

assert!(Signature::verify(&signature, MESSAGE, &public_key));
assert!(Signature::verify(&signature, MESSAGE, public_key));
}

#[test]
Expand All @@ -154,7 +154,7 @@ mod tests {
let public_key = PublicKey::default();
let signature = SecretKey::sign(&secret_key, MESSAGE);

assert!(!Signature::verify(&signature, MESSAGE, &public_key));
assert!(!Signature::verify(&signature, MESSAGE, public_key));
}

#[test]
Expand All @@ -163,7 +163,7 @@ mod tests {
let public_key = SecretKey::to_public_key(&secret_key);
let signature = Signature::default();

assert!(!Signature::verify(&signature, MESSAGE, &public_key));
assert!(!Signature::verify(&signature, MESSAGE, public_key));
}

fn secret_key() -> SecretKey {
Expand Down
2 changes: 1 addition & 1 deletion helper_functions/src/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn verify(case: Case) {
let run = || -> Result<_, Error> {
let public_key = PublicKey::try_from(pubkey)?;
let signature = Signature::try_from(signature)?;
Ok(signature.verify(message, &public_key))
Ok(signature.verify(message, public_key))
};

if output {
Expand Down
2 changes: 1 addition & 1 deletion helper_functions/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Verifier for SingleVerifier {
let signature = Signature::try_from(signature_bytes)?;

ensure!(
signature.verify(message, &public_key),
signature.verify(message, public_key),
Error::SignatureInvalid(signature_kind),
);
}
Expand Down

0 comments on commit 0f1efc7

Please sign in to comment.