Expand description
A Keystore is a secure repository of private keys. MetaLairClient is a reference to a Keystore. MetaLairClient allows async generation of keypairs, and usage of those keypairs, reference by the public AgentPubKey.
§Examples
use holo_hash::AgentPubKey;
use std::path::Path;
use std::path::PathBuf;
use holochain_keystore::*;
use holochain_keystore::lair_keystore::*;
use holochain_serialized_bytes::prelude::*;
use std::sync::{Arc, Mutex};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
tokio::task::spawn(async move {
let mut passphrase = sodoken::LockedArray::new(32).unwrap();
passphrase.lock().copy_from_slice(b"passphrase");
let passphrase = Arc::new(Mutex::new(passphrase));
let keystore = spawn_lair_keystore_in_proc(&PathBuf::from("/"), passphrase).await.unwrap();
let agent_pubkey = AgentPubKey::new_random(&keystore).await.unwrap();
#[derive(Debug, serde::Serialize, serde::Deserialize, SerializedBytes)]
struct MyData(Vec<u8>);
let my_data_1 = MyData(b"signature test data 1".to_vec());
let signature = agent_pubkey.sign(&keystore, &my_data_1).await.unwrap();
assert!(agent_pubkey.verify_signature(&signature, &my_data_1).await.unwrap());
}).await.unwrap();
}Modules§
- lair_
keystore - Keystore backed by lair_keystore_api.
- paths
- Paths for the keystore.
Structs§
- Meta
Lair Client - Abstraction around runtime switching/upgrade of lair keystore / client.
Enums§
- Keystore
Error - Keystore Error Type.
Constants§
- TEST_
AGENT_ PK_ 1 - First Test Agent Pub Key
- TEST_
AGENT_ PK_ 2 - Second Test Agent Pub Key
- TEST_
AGENT_ PK_ 3 - Third Test Agent Pub Key
- TEST_
AGENT_ PK_ 4 - Fourth Test Agent Pub Key
Traits§
- Agent
PubKey Ext - Extend holo_hash::AgentPubKey with additional signature functionality from Keystore.
Functions§
- spawn_
test_ keystore - Construct a new test keystore with the new lair api.
- test_
keystore - Generate a test keystore pre-populated with a couple of test key-pairs.
Type Aliases§
- Keystore
Result - alias
- Lair
Result - Lair result type.