[][src]Trait radicle_keystore::Keystore

pub trait Keystore {
    type PublicKey: From<Self::SecretKey>;
    type SecretKey: SecretKeyExt<Metadata = Self::Metadata>;
    type Metadata;
    type Error: Error;
    fn put_key(&mut self, key: Self::SecretKey) -> Result<(), Self::Error>;
fn get_key(
        &self
    ) -> Result<Keypair<Self::PublicKey, Self::SecretKey>, Self::Error>;
fn show_key(&self) -> Result<(Self::PublicKey, Self::Metadata), Self::Error>; }

Abstraction over secure storage for private key material.

Associated Types

type PublicKey: From<Self::SecretKey>

type SecretKey: SecretKeyExt<Metadata = Self::Metadata>

type Metadata

type Error: Error

Loading content...

Required methods

fn put_key(&mut self, key: Self::SecretKey) -> Result<(), Self::Error>

Securely store secret key key in the keystore.

The key may carry Keystore::Metadata, which is stored alongside the key material. The metadata, as well as the public portion of the key, may be stored in clear, so as to not require prompting the user when retrieving those values.

Key rotation is not (yet) part of this API, thus put_key MUST return an error if an equivalent key is already present in the storage backend.

fn get_key(
    &self
) -> Result<Keypair<Self::PublicKey, Self::SecretKey>, Self::Error>

Retrieve both the secret and public parts of the stored key material.

fn show_key(&self) -> Result<(Self::PublicKey, Self::Metadata), Self::Error>

Retrieve only the public part of the key material, along with any metadata.

Loading content...

Implementors

impl<C, PK, SK, M> Keystore for FileStorage<C, PK, SK, M> where
    C: Crypto,
    C::Error: Display + Debug,
    C::SecretBox: Serialize + DeserializeOwned,
    SK: AsRef<[u8]> + SecretKeyExt<Metadata = M>,
    <SK as SecretKeyExt>::Error: Display + Debug,
    PK: Clone + From<SK> + Serialize + DeserializeOwned,
    M: Clone + Serialize + DeserializeOwned
[src]

type PublicKey = PK

type SecretKey = SK

type Metadata = M

type Error = Error<C::Error, <SK as SecretKeyExt>::Error>

impl<C, PK, SK, M> Keystore for MemoryStorage<C, PK, SK, M> where
    C: Crypto,
    C::Error: Display + Debug,
    C::SecretBox: Clone,
    SK: AsRef<[u8]> + SecretKeyExt<Metadata = M>,
    <SK as SecretKeyExt>::Error: Display + Debug,
    PK: Clone + From<SK>,
    M: Clone
[src]

type PublicKey = PK

type SecretKey = SK

type Metadata = M

type Error = Error<C::Error, <SK as SecretKeyExt>::Error>

Loading content...