Struct sc_keystore::LocalKeystore
source · pub struct LocalKeystore(/* private fields */);
Expand description
A local based keystore that is either memory-based or filesystem-based.
Implementations§
source§impl LocalKeystore
impl LocalKeystore
sourcepub fn open<T: Into<PathBuf>>(
path: T,
password: Option<SecretString>
) -> Result<Self>
pub fn open<T: Into<PathBuf>>( path: T, password: Option<SecretString> ) -> Result<Self>
Create a local keystore from filesystem.
The keystore will be created at path
. The keystore optionally supports to encrypt/decrypt
the keys in the keystore using password
.
NOTE: Even when passing a password
, the keys on disk appear to look like normal secret
uris. However, without having the correct password the secret uri will not generate the
correct private key. See SecretUri
for more information.
Trait Implementations§
source§impl Into<Arc<dyn Keystore>> for LocalKeystore
impl Into<Arc<dyn Keystore>> for LocalKeystore
source§fn into(self) -> KeystorePtr
fn into(self) -> KeystorePtr
source§impl Keystore for LocalKeystore
impl Keystore for LocalKeystore
source§fn insert(
&self,
key_type: KeyTypeId,
suri: &str,
public: &[u8]
) -> Result<(), ()>
fn insert( &self, key_type: KeyTypeId, suri: &str, public: &[u8] ) -> Result<(), ()>
Insert a new secret key.
WARNING: if the secret keypair has been manually generated using a password
(e.g. using methods such as sp_core::crypto::Pair::from_phrase
) then such
a password must match the one used to open the keystore via LocalKeystore::open
.
If the passwords doesn’t match then the inserted key ends up being unusable under
the current keystore instance.
source§fn sr25519_generate_new(
&self,
key_type: KeyTypeId,
seed: Option<&str>
) -> Result<Public, TraitError>
fn sr25519_generate_new( &self, key_type: KeyTypeId, seed: Option<&str> ) -> Result<Public, TraitError>
Generate a new pair compatible with the ‘ed25519’ signature scheme.
If [seed]
is Some
then the key will be ephemeral and stored in memory.
source§fn ed25519_generate_new(
&self,
key_type: KeyTypeId,
seed: Option<&str>
) -> Result<Public, TraitError>
fn ed25519_generate_new( &self, key_type: KeyTypeId, seed: Option<&str> ) -> Result<Public, TraitError>
Generate a new pair compatible with the ‘sr25519’ signature scheme.
If [seed]
is Some
then the key will be ephemeral and stored in memory.
source§fn ecdsa_generate_new(
&self,
key_type: KeyTypeId,
seed: Option<&str>
) -> Result<Public, TraitError>
fn ecdsa_generate_new( &self, key_type: KeyTypeId, seed: Option<&str> ) -> Result<Public, TraitError>
Generate a new pair compatible with the ‘ecdsa’ signature scheme.
If [seed]
is Some
then the key will be ephemeral and stored in memory.
source§fn keys(&self, key_type: KeyTypeId) -> Result<Vec<Vec<u8>>, TraitError>
fn keys(&self, key_type: KeyTypeId) -> Result<Vec<Vec<u8>>, TraitError>
source§fn has_keys(&self, public_keys: &[(Vec<u8>, KeyTypeId)]) -> bool
fn has_keys(&self, public_keys: &[(Vec<u8>, KeyTypeId)]) -> bool
source§fn sr25519_public_keys(&self, key_type: KeyTypeId) -> Vec<Public>
fn sr25519_public_keys(&self, key_type: KeyTypeId) -> Vec<Public>
source§fn sr25519_sign(
&self,
key_type: KeyTypeId,
public: &Public,
msg: &[u8]
) -> Result<Option<Signature>, TraitError>
fn sr25519_sign( &self, key_type: KeyTypeId, public: &Public, msg: &[u8] ) -> Result<Option<Signature>, TraitError>
source§fn sr25519_vrf_sign(
&self,
key_type: KeyTypeId,
public: &Public,
data: &VrfSignData
) -> Result<Option<VrfSignature>, TraitError>
fn sr25519_vrf_sign( &self, key_type: KeyTypeId, public: &Public, data: &VrfSignData ) -> Result<Option<VrfSignature>, TraitError>
source§fn sr25519_vrf_pre_output(
&self,
key_type: KeyTypeId,
public: &Public,
input: &VrfInput
) -> Result<Option<VrfPreOutput>, TraitError>
fn sr25519_vrf_pre_output( &self, key_type: KeyTypeId, public: &Public, input: &VrfInput ) -> Result<Option<VrfPreOutput>, TraitError>
source§fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec<Public>
fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec<Public>
source§fn ed25519_sign(
&self,
key_type: KeyTypeId,
public: &Public,
msg: &[u8]
) -> Result<Option<Signature>, TraitError>
fn ed25519_sign( &self, key_type: KeyTypeId, public: &Public, msg: &[u8] ) -> Result<Option<Signature>, TraitError>
source§fn ecdsa_public_keys(&self, key_type: KeyTypeId) -> Vec<Public>
fn ecdsa_public_keys(&self, key_type: KeyTypeId) -> Vec<Public>
source§fn ecdsa_sign(
&self,
key_type: KeyTypeId,
public: &Public,
msg: &[u8]
) -> Result<Option<Signature>, TraitError>
fn ecdsa_sign( &self, key_type: KeyTypeId, public: &Public, msg: &[u8] ) -> Result<Option<Signature>, TraitError>
Auto Trait Implementations§
impl !Freeze for LocalKeystore
impl !RefUnwindSafe for LocalKeystore
impl Send for LocalKeystore
impl Sync for LocalKeystore
impl Unpin for LocalKeystore
impl UnwindSafe for LocalKeystore
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.