diff --git a/Cargo.toml b/Cargo.toml index 3e52bc6..ab19814 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ed25519-compact" -version = "1.0.10" +version = "1.0.11" authors = ["Frank Denis "] edition = "2018" description = "A small, self-contained, wasm-friendly Ed25519 implementation" diff --git a/src/ed25519.rs b/src/ed25519.rs index c14a0ba..04866a8 100644 --- a/src/ed25519.rs +++ b/src/ed25519.rs @@ -673,6 +673,20 @@ mod blind_keys { } } + impl PublicKey { + /// Returns a blind version of the public key. + pub fn blind(&self, blind: &Blind) -> Result { + let (blind_factor, _prefix2) = { + let hash_output = sha512::Hash::hash(&blind[..]); + KeyPair::split(&hash_output, true, false) + }; + let pk_p3 = GeP3::from_bytes_vartime(&self.0).ok_or(Error::InvalidPublicKey)?; + Ok(BlindPublicKey( + ge_scalarmult(&blind_factor, &pk_p3).to_bytes(), + )) + } + } + impl KeyPair { /// Returns a blind version of the key pair. pub fn blind(&self, blind: &Blind) -> BlindKeyPair {