-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update with latest ic packages
- Loading branch information
Showing
13 changed files
with
219 additions
and
860 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,22 +40,38 @@ pub fn secp256k1_verify_any( | |
} | ||
} | ||
|
||
// wait for [email protected] | ||
// pub fn schnorr_secp256k1_verify_any( | ||
// public_keys: &[schnorr::VerifyingKey], | ||
// message: &[u8], | ||
// signature: &[u8], | ||
// ) -> Result<(), String> { | ||
// let sig = schnorr::Signature::try_from(signature).map_err(format_error)?; | ||
// let digest = sha256(message); | ||
// match public_keys | ||
// .iter() | ||
// .any(|key| key.verify_raw(&digest, &sig).is_ok()) | ||
// { | ||
// true => Ok(()), | ||
// false => Err("schnorr secp256k1 signature verification failed".to_string()), | ||
// } | ||
// } | ||
pub fn schnorr_secp256k1_verify( | ||
public_key: &[u8], | ||
message: &[u8], | ||
signature: &[u8], | ||
) -> Result<(), String> { | ||
let key = schnorr::VerifyingKey::from_bytes(if public_key.len() == 33 { | ||
&public_key[1..] | ||
} else { | ||
public_key | ||
}) | ||
.map_err(format_error)?; | ||
let sig = schnorr::Signature::try_from(signature).map_err(format_error)?; | ||
match key.verify_raw(message, &sig).is_ok() { | ||
true => Ok(()), | ||
false => Err("schnorr secp256k1 signature verification failed".to_string()), | ||
} | ||
} | ||
|
||
pub fn schnorr_secp256k1_verify_any( | ||
public_keys: &[schnorr::VerifyingKey], | ||
message: &[u8], | ||
signature: &[u8], | ||
) -> Result<(), String> { | ||
let sig = schnorr::Signature::try_from(signature).map_err(format_error)?; | ||
match public_keys | ||
.iter() | ||
.any(|key| key.verify_raw(message, &sig).is_ok()) | ||
{ | ||
true => Ok(()), | ||
false => Err("schnorr secp256k1 signature verification failed".to_string()), | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters