diff --git a/CHANGELOG.md b/CHANGELOG.md index 87b692fa..6b058f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/secio/Cargo.toml b/secio/Cargo.toml index 9e9617ad..67a23605 100644 --- a/secio/Cargo.toml +++ b/secio/Cargo.toml @@ -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 ", "Nervos Core Dev "] diff --git a/secio/src/handshake/handshake_struct.rs b/secio/src/handshake/handshake_struct.rs index 9aa6460c..206f0e32 100644 --- a/secio/src/handshake/handshake_struct.rs +++ b/secio/src/handshake/handshake_struct.rs @@ -134,6 +134,11 @@ impl PublicKey { self.key } + /// from raw pubkey + pub fn from_raw_key(pubkey: Vec) -> Self { + PublicKey { key: pubkey } + } + /// Encode with molecule pub fn encode(self) -> Bytes { let secp256k1 = handshake_mol::Secp256k1::new_builder() diff --git a/secio/src/handshake/procedure.rs b/secio/src/handshake/procedure.rs index 4a2195be..f6da37d4 100644 --- a/secio/src/handshake/procedure.rs +++ b/secio/src/handshake/procedure.rs @@ -156,7 +156,7 @@ where let data_to_verify = crate::sha256_compat::sha256(&data_to_verify); - if !::verify_ecdsa( + if !ephemeral_context.config.key_provider.verify_ecdsa( ephemeral_context.state.remote.public_key.inner_ref(), data_to_verify, &remote_exchanges.signature, diff --git a/secio/src/lib.rs b/secio/src/lib.rs index 75e33f9a..a2d5db1d 100644 --- a/secio/src/lib.rs +++ b/secio/src/lib.rs @@ -135,7 +135,7 @@ pub trait KeyProvider: std::clone::Clone + Send + Sync + 'static { fn pubkey(&self) -> Vec; /// Checks that `sig` is a valid ECDSA signature for `msg` using the pubkey. - fn verify_ecdsa(pubkey: P, message: T, signature: F) -> bool + fn verify_ecdsa(&self, pubkey: P, message: T, signature: F) -> bool where P: AsRef<[u8]>, T: AsRef<[u8]>, @@ -168,7 +168,7 @@ impl KeyProvider for SecioKeyPair { } } - fn verify_ecdsa(pubkey: P, message: T, signature: F) -> bool + fn verify_ecdsa(&self, pubkey: P, message: T, signature: F) -> bool where P: AsRef<[u8]>, T: AsRef<[u8]>, @@ -205,7 +205,7 @@ impl KeyProvider for NoopKeyProvider { Vec::new() } - fn verify_ecdsa(_pubkey: P, _message: T, _signature: F) -> bool + fn verify_ecdsa(&self, _pubkey: P, _message: T, _signature: F) -> bool where P: AsRef<[u8]>, T: AsRef<[u8]>,