From 5cb72540218b5e463e473dba440f0c10715b0cee Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Thu, 25 Jan 2024 08:59:03 +1300 Subject: [PATCH] Remove retired signer.rs file --- gossip-lib/src/signer.rs | 136 --------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 gossip-lib/src/signer.rs diff --git a/gossip-lib/src/signer.rs b/gossip-lib/src/signer.rs deleted file mode 100644 index f316f7ca2..000000000 --- a/gossip-lib/src/signer.rs +++ /dev/null @@ -1,136 +0,0 @@ - -impl Signer { - // CONSUMING ... - - - pub fn sign_preevent( - &self, - preevent: PreEvent, - pow: Option, - work_sender: Option>, - ) -> Result { - unimplemented!() - /* - match &*self.private.read() { - Some(pk) => match pow { - Some(pow) => Ok(Event::new_with_pow(preevent, pk, pow, work_sender)?), - None => Ok(Event::new(preevent, pk)?), - }, - _ => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - */ - } - - /// Export the private key as bech32 (decrypted!) - pub fn export_private_key_bech32(&self, pass: &str) -> Result { - let maybe_encrypted = self.encrypted.read().to_owned(); - match maybe_encrypted { - Some(epk) => { - // Test password - let mut pk = epk.decrypt(pass)?; - - let output = pk.as_bech32_string(); - - // We have to regenerate encrypted private key because it may have fallen from - // medium to weak security. And then we need to save that - let epk = pk.export_encrypted(pass, GLOBALS.storage.read_setting_log_n())?; - *self.encrypted.write() = Some(epk); - *self.private.write() = Some(pk); - self.save()?; - Ok(output) - } - _ => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - } - - /// Export the private key as hex (decrypted!) - pub fn export_private_key_hex(&self, pass: &str) -> Result { - let maybe_encrypted = self.encrypted.read().to_owned(); - match maybe_encrypted { - Some(epk) => { - // Test password - let mut pk = epk.decrypt(pass)?; - - let output = pk.as_hex_string(); - - // We have to regenerate encrypted private key because it may have fallen from - // medium to weak security. And then we need to save that - let epk = pk.export_encrypted(pass, GLOBALS.storage.read_setting_log_n())?; - *self.encrypted.write() = Some(epk); - *self.private.write() = Some(pk); - self.save()?; - Ok(output) - } - _ => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - } - - pub(crate) fn delete_identity(&self) { - *self.private.write() = None; - *self.encrypted.write() = None; - *self.public.write() = None; - let _ = self.save(); - } - - /// Decrypt an event - pub fn decrypt_message(&self, event: &Event) -> Result { - unimplemented!() - /* - match &*self.private.read() { - Some(private) => Ok(event.decrypted_contents(private)?), - _ => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - */ - } - - /// Unwrap a giftwrap event - pub fn unwrap_giftwrap(&self, event: &Event) -> Result { - unimplemented!() - /* - match &*self.private.read() { - Some(private) => Ok(event.giftwrap_unwrap(private)?), - _ => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - */ - } - - /// Unwrap a giftwrap event V1 - pub fn unwrap_giftwrap1(&self, event: &EventV1) -> Result { - unimplemented!() - /* - match &*self.private.read() { - Some(private) => Ok(event.giftwrap_unwrap(private)?), - _ => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - */ - } - - /// Encrypt content - pub fn encrypt( - &self, - other: &PublicKey, - plaintext: &str, - algo: ContentEncryptionAlgorithm, - ) -> Result { - match &*self.private.read() { - Some(private) => Ok(private.encrypt(other, plaintext, algo)?), - None => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - } - - /// Decrypt NIP-04 content - pub fn decrypt_nip04(&self, other: &PublicKey, ciphertext: &str) -> Result, Error> { - match &*self.private.read() { - Some(private) => Ok(private.decrypt_nip04(other, ciphertext)?), - None => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - } - - /// Decrypt NIP-44 content - pub fn decrypt_nip44(&self, other: &PublicKey, ciphertext: &str) -> Result { - match &*self.private.read() { - Some(private) => Ok(private.decrypt_nip44(other, ciphertext)?), - None => Err((ErrorKind::NoPrivateKey, file!(), line!()).into()), - } - } -}