Skip to content

Commit

Permalink
Add a function to only blind the public key
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Feb 6, 2022
1 parent d01d57b commit 88d7de4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ed25519-compact"
version = "1.0.10"
version = "1.0.11"
authors = ["Frank Denis <github@pureftpd.org>"]
edition = "2018"
description = "A small, self-contained, wasm-friendly Ed25519 implementation"
Expand Down
14 changes: 14 additions & 0 deletions src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,20 @@ mod blind_keys {
}
}

impl PublicKey {
/// Returns a blind version of the public key.
pub fn blind(&self, blind: &Blind) -> Result<BlindPublicKey, Error> {
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 {
Expand Down

0 comments on commit 88d7de4

Please sign in to comment.