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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! 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
//!
//! ```rust,no_run
//! 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();
//! }
//! ```
use *;
pub use *;
pub use *;
pub use *;
pub use *;
/// Construct a simple in-memory in-process keystore.
///
/// # Examples
///
/// ```
/// use holo_hash::AgentPubKey;
/// use holochain_keystore::*;
/// use holochain_serialized_bytes::prelude::*;
///
/// #[tokio::main(flavor = "multi_thread")]
/// async fn main() {
/// tokio::task::spawn(async move {
/// let keystore = spawn_mem_keystore().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();
/// }
/// ```
pub async