Skip to content

Commit

Permalink
update Rust dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Nov 29, 2023
1 parent 4fd882b commit 22d0f85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 10 additions & 4 deletions rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,25 @@ where
section_hashes: HashMap<usize, Vec<u8>>,
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![],
&section_hashes,
signature.raw_indices.clone(),
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();
Expand All @@ -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();
Expand Down

0 comments on commit 22d0f85

Please sign in to comment.