From 22d0f8543677dadf44247fcb970cde8a31593d97 Mon Sep 17 00:00:00 2001 From: ftheirs Date: Wed, 29 Nov 2023 14:34:46 -0300 Subject: [PATCH] update Rust dependencies --- rs/Cargo.toml | 2 +- rs/src/lib.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rs/Cargo.toml b/rs/Cargo.toml index 094da46b..1d9c61ee 100644 --- a/rs/Cargo.toml +++ b/rs/Cargo.toml @@ -28,7 +28,7 @@ prost-types = "0.11.6" leb128 = "0.2.5" sha2 = "0.10.6" -ed25519-dalek = "1.0.1" +ed25519-dalek = "2.1.0" bincode = "1.3.3" [dev-dependencies] diff --git a/rs/src/lib.rs b/rs/src/lib.rs index ed29a676..a06d2be2 100644 --- a/rs/src/lib.rs +++ b/rs/src/lib.rs @@ -255,13 +255,15 @@ where section_hashes: HashMap>, pubkey: &[u8], ) -> bool { - use ed25519_dalek::{PublicKey, Signature}; + use ed25519_dalek::{Signature, VerifyingKey}; if pubkey != &signature.pubkey { return false; } - let public_key = PublicKey::from_bytes(&signature.pubkey[1..]).unwrap(); + let mut public_key_bytes = [0u8; 32]; + public_key_bytes.copy_from_slice(&signature.pubkey[1..33]); + let public_key = VerifyingKey::from_bytes(&public_key_bytes).unwrap(); let unsigned_raw_sig_hash = self.hash_signature_sec( vec![], §ion_hashes, @@ -269,7 +271,9 @@ where None, None, ); - let raw_signature = Signature::from_bytes(&signature.raw_signature[1..]).unwrap(); + let mut raw_signature_bytes = [0u8; 64]; + raw_signature_bytes.copy_from_slice(&signature.raw_signature[1..65]); + let raw_signature = Signature::from_bytes(&raw_signature_bytes); let raw_sig = public_key .verify(&unsigned_raw_sig_hash, &raw_signature) .is_ok(); @@ -295,7 +299,9 @@ where None, ); - let wrapper_signature = Signature::from_bytes(&signature.wrapper_signature[1..]).unwrap(); + let mut wrapper_signature_bytes = [0u8; 64]; + wrapper_signature_bytes.copy_from_slice(&signature.wrapper_signature[1..65]); + let wrapper_signature = Signature::from_bytes(&wrapper_signature_bytes); let wrapper_sig = public_key .verify(&unsigned_wrapper_sig_hash, &wrapper_signature) .is_ok();