1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Configuration for software-backed signer (using ed25519-dalek)

use crate::chain;
use serde::Deserialize;
use std::path::{Path, PathBuf};

/// Software signer configuration
#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct SoftSignConfig {
    /// Chains this signing key is authorized to be used from
    pub chain_ids: Vec<chain::Id>,

    /// Path to a file containing a cryptographic key
    // TODO: use `abscissa::Secret` to wrap this `PathBuf`
    pub path: SoftPrivateKey,
}

/// Software-backed private key (stored in a file)
#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct SoftPrivateKey(PathBuf);

impl SoftPrivateKey {
    /// Borrow this private key as a path
    pub fn as_path(&self) -> &Path {
        self.0.as_ref()
    }
}