· 6 years ago · Sep 03, 2019, 04:36 PM
1#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2struct SodiumoxideSecretBox {
3 nonce: secretbox::Nonce,
4 encrypted: bool
5}
6
7#[derive(Copy, Clone, Eq, PartialOrd, Ord, PartialEq, Serialize, Deserialize)]
8pub struct PublicKey(pub sodiumoxide::crypto::sign::ed25519::PublicKey);
9
10#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
11pub struct SecretKey(pub sodiumoxide::crypto::sign::ed25519::SecretKey);
12
13pub fn perform_encryption() {
14 let ssb = SodiumoxideSecretBox::new();
15
16 if home_dir.join("config.json").exists() {
17 process_serialized_file(key_store_path, ssb)?;
18 } else {
19 encrypt_keyfile_secretkey(key_store_path, public_key, secret_key, ssb)?;
20 }
21 Ok(())
22}
23
24fn process_serialized_file(key_store_path: &Path, ssb: SodiumoxideSecretBox) -> Result<(), Error>
25{
26
27}
28
29fn encrypt_keyfile_secretkey(key_store_path: &Path, public_key: PublicKey, secret_key: SecretKey,
30 ssb: SodiumoxideSecretBox)
31-> Result<(), Error> {
32
33}