Skip to content

Commit

Permalink
chore: bump secio to 0.6.1 (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo authored Jun 21, 2023
1 parent c0f8514 commit 339a41b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## secio 0.6.1

### Features
- Expose the PublicKey `from_raw_key` api

## yamux 0.3.8 secio 0.6.0 tentacle 0.5.0-alpha.1

### Features
Expand Down
2 changes: 1 addition & 1 deletion secio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tentacle-secio"
version = "0.6.0"
version = "0.6.1"
license = "MIT"
description = "Secio encryption protocol for p2p"
authors = ["piaoliu <[email protected]>", "Nervos Core Dev <[email protected]>"]
Expand Down
5 changes: 5 additions & 0 deletions secio/src/handshake/handshake_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ impl PublicKey {
self.key
}

/// from raw pubkey
pub fn from_raw_key(pubkey: Vec<u8>) -> Self {
PublicKey { key: pubkey }
}

/// Encode with molecule
pub fn encode(self) -> Bytes {
let secp256k1 = handshake_mol::Secp256k1::new_builder()
Expand Down
2 changes: 1 addition & 1 deletion secio/src/handshake/procedure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ where

let data_to_verify = crate::sha256_compat::sha256(&data_to_verify);

if !<K as KeyProvider>::verify_ecdsa(
if !ephemeral_context.config.key_provider.verify_ecdsa(
ephemeral_context.state.remote.public_key.inner_ref(),
data_to_verify,
&remote_exchanges.signature,
Expand Down
6 changes: 3 additions & 3 deletions secio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub trait KeyProvider: std::clone::Clone + Send + Sync + 'static {
fn pubkey(&self) -> Vec<u8>;

/// Checks that `sig` is a valid ECDSA signature for `msg` using the pubkey.
fn verify_ecdsa<P, T, F>(pubkey: P, message: T, signature: F) -> bool
fn verify_ecdsa<P, T, F>(&self, pubkey: P, message: T, signature: F) -> bool
where
P: AsRef<[u8]>,
T: AsRef<[u8]>,
Expand Down Expand Up @@ -168,7 +168,7 @@ impl KeyProvider for SecioKeyPair {
}
}

fn verify_ecdsa<P, T, F>(pubkey: P, message: T, signature: F) -> bool
fn verify_ecdsa<P, T, F>(&self, pubkey: P, message: T, signature: F) -> bool
where
P: AsRef<[u8]>,
T: AsRef<[u8]>,
Expand Down Expand Up @@ -205,7 +205,7 @@ impl KeyProvider for NoopKeyProvider {
Vec::new()
}

fn verify_ecdsa<P, T, F>(_pubkey: P, _message: T, _signature: F) -> bool
fn verify_ecdsa<P, T, F>(&self, _pubkey: P, _message: T, _signature: F) -> bool
where
P: AsRef<[u8]>,
T: AsRef<[u8]>,
Expand Down

0 comments on commit 339a41b

Please sign in to comment.