diff --git a/sn_auditor/src/dag_db.rs b/sn_auditor/src/dag_db.rs index 24eb3cb037..9048ab7c39 100644 --- a/sn_auditor/src/dag_db.rs +++ b/sn_auditor/src/dag_db.rs @@ -34,7 +34,7 @@ pub struct SpendDagDb { dag: Arc>, forwarded_payments: Arc>, beta_participants: BTreeMap, - foundation_sk: SecretKey, + encrption_sk: SecretKey, } /// Map of Discord usernames to their tracked forwarded payments @@ -52,7 +52,7 @@ impl SpendDagDb { /// Create a new SpendDagDb /// If a local spend DAG file is found, it will be loaded /// Else a new DAG will be created containing only Genesis - pub async fn new(path: PathBuf, client: Client, foundation_sk: SecretKey) -> Result { + pub async fn new(path: PathBuf, client: Client, encrption_sk: SecretKey) -> Result { let dag_path = path.join(SPEND_DAG_FILENAME); let dag = match SpendDag::load_from_file(&dag_path) { Ok(d) => { @@ -71,12 +71,12 @@ impl SpendDagDb { dag: Arc::new(RwLock::new(dag)), forwarded_payments: Arc::new(RwLock::new(BTreeMap::new())), beta_participants: BTreeMap::new(), - foundation_sk, + encrption_sk, }) } /// Create a new SpendDagDb from a local file and no network connection - pub fn offline(dag_path: PathBuf, foundation_sk: SecretKey) -> Result { + pub fn offline(dag_path: PathBuf, encrption_sk: SecretKey) -> Result { let path = dag_path .parent() .ok_or_else(|| eyre!("Failed to get parent path"))? @@ -88,7 +88,7 @@ impl SpendDagDb { dag: Arc::new(RwLock::new(dag)), forwarded_payments: Arc::new(RwLock::new(BTreeMap::new())), beta_participants: BTreeMap::new(), - foundation_sk, + encrption_sk, }) } @@ -272,7 +272,7 @@ impl SpendDagDb { // find spends with payments let mut payments: ForwardedPayments = BTreeMap::new(); for spend in all_spends { - let user_name_hash = match spend.reason().get_sender_hash(&self.foundation_sk) { + let user_name_hash = match spend.reason().get_sender_hash(&self.encrption_sk) { Some(n) => n, None => continue, }; diff --git a/sn_transfers/src/cashnotes/spend_reason.rs b/sn_transfers/src/cashnotes/spend_reason.rs index 2d6a179874..2116f57867 100644 --- a/sn_transfers/src/cashnotes/spend_reason.rs +++ b/sn_transfers/src/cashnotes/spend_reason.rs @@ -113,9 +113,9 @@ impl DiscordName { impl DiscordNameCipher { /// Create a new DiscordNameCipher from a Discord username /// it is encrypted to the given pubkey - pub fn create(user_name: &str, foundation_pk: PublicKey) -> Result { + pub fn create(user_name: &str, encryption_pk: PublicKey) -> Result { let discord_name = DiscordName::new(user_name); - let cipher = foundation_pk.encrypt(discord_name.to_sized_bytes()); + let cipher = encryption_pk.encrypt(discord_name.to_sized_bytes()); let bytes = cipher.to_bytes(); if bytes.len() > MAX_CIPHER_SIZE { return Err(TransferError::DiscordNameCipherTooBig); @@ -145,24 +145,24 @@ mod tests { #[test] fn test_discord_name_cyphering() { - let foundation_sk = SecretKey::random(); - let foundation_pk = foundation_sk.public_key(); + let encryption_sk = SecretKey::random(); + let encryption_pk = encryption_sk.public_key(); let user_name = "JohnDoe#1234"; let user_name_hash = Hash::hash(user_name.as_bytes()); let cypher = - DiscordNameCipher::create(user_name, foundation_pk).expect("cypher creation failed"); + DiscordNameCipher::create(user_name, encryption_pk).expect("cypher creation failed"); let recovered_hash = cypher - .decrypt_to_username_hash(&foundation_sk) + .decrypt_to_username_hash(&encryption_sk) .expect("decryption failed"); assert_eq!(user_name_hash, recovered_hash); let user_name2 = "JackMa#5678"; let user_name_hash2 = Hash::hash(user_name2.as_bytes()); let cypher = - DiscordNameCipher::create(user_name2, foundation_pk).expect("cypher creation failed"); + DiscordNameCipher::create(user_name2, encryption_pk).expect("cypher creation failed"); let recovered_hash = cypher - .decrypt_to_username_hash(&foundation_sk) + .decrypt_to_username_hash(&encryption_sk) .expect("decryption failed"); assert_eq!(user_name_hash2, recovered_hash);