From 9313800860e47233677edb155b2c9fe1f25a59ae Mon Sep 17 00:00:00 2001 From: Nanak Nihal Singh Khalsa Date: Fri, 3 Feb 2023 16:17:16 -0500 Subject: [PATCH] added check that inputs are on curve --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 62ca8d6..797d33f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -416,6 +416,9 @@ impl PrivateKey { } pub fn decrypt_elgamal(&self, encrypted_point: ElGamalEncryption) -> Point { + // Make sure inputs aren't bad (i imagine this check could be skipped for performance reasons, but it seems a sanity check here would be helpful) + assert!(encrypted_point.c1.on_curve() && encrypted_point.c2.on_curve()); + let shared_secret = encrypted_point.c1.mul_scalar(&self.scalar_key()); println!("Shared Secret {:?}", shared_secret); // Subtract the shared secret