[WIP] Companion PR for sr25519 fallible constructor (#4861)

* Manage new `sr25519::Signature::from_slice` fallible constructor

Constructor now returns an `Option`

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Davide Galassi
2022-02-26 22:51:44 +01:00
committed by GitHub
parent fc919376ba
commit 00ce69aae8
2 changed files with 185 additions and 165 deletions
+182 -163
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -411,8 +411,9 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
fn verify_signature(who: &T::AccountId, signature: &[u8]) -> Result<(), DispatchError> {
// sr25519 always expects a 64 byte signature.
ensure!(signature.len() == 64, Error::<T>::InvalidSignature);
let signature: AnySignature = sr25519::Signature::from_slice(signature).into();
let signature: AnySignature = sr25519::Signature::from_slice(signature)
.ok_or(Error::<T>::InvalidSignature)?
.into();
// In Polkadot, the AccountId is always the same as the 32 byte public key.
let account_bytes: [u8; 32] = account_to_bytes(who)?;