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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//! Relating to identity functions.
use super ::*;
/// Returns all of the identity key pairs that are currently stored in the wallet.
/// If the wallet is encrypted, it must be unlocked prior to using this command.
///
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::new();
/// let response = identity::all_id_keys(&client).await.unwrap();
/// dbg!(&response);
/// assert!(response.success());
/// }
/// ```
pub async
/// This command will return an identity’s set of public keys (in order of
/// decreasing priority) that were active at a specific block, or at the most
/// recent height if the "height" parameter is not included. This is useful for
/// validating entries containing identity signatures (e.g. on identity attributes
/// and endorsements), allowing you to tell if a given signature was created with
/// a key that was valid at the time that the entry was published. Time is
/// measured in directory blocks.
///
/// As an example, let’s say the identity at chain-id
/// 3b69dabe22c014af9a9bc9dfa7917ce4602a03579597ddf184d8de56702512ae signs an entry
/// using their level-3 key idpub2GU1Pcax2PibH8hHZg58fKRiSJKQWQkWYkpmt7VH1jCXBgqp9w,
/// and publishes it to the blockchain at height 163420 and then replaces that key
/// one block later at height 163421. Even though the key is no longer valid at the
/// highest block height, we can tell that it was valid at the time that the
/// signature was created, so we can still trust that the entry is authentic.
/// However, if someone then published another entry signed with the key that was
/// just replaced, we will be able to tell that the signer key is no longer valid
/// and that the entry shouldn’t be trusted.
///
/// If the wallet is encrypted, it must be unlocked prior to using this command.
///
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::open_node();
/// let chainid = "3b69dabe22c014af9a9bc9dfa7917ce4602a03579597ddf184d8de56702512ae";
/// let height = 163419;
/// let response = identity::active_id_keys(&client, chainid, Some(height)).await.unwrap();
/// dbg!(&response);
/// }
/// ```
pub async
/// **Be careful using this function! Ensure that you have backups of important keys
/// before removing them.** Given an identity public key, this command deletes the
/// corresponding identity key pair from the wallet. Once executed, the user will
/// no longer be able to retrieve that key pair or sign attributes/endorsements
/// with the key pair from this wallet. If the wallet is encrypted, it must be
/// unlocked prior to using this command.
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::new();
/// let response = generate::identity_key(&client).await.unwrap();
/// let address = response.result.public;
/// let remove_response = identity::remove_id_key(&client, &address).await.unwrap();
/// dbg!(&remove_response);
/// assert!(remove_response.result.success);
/// }
/// ```
pub async
/// Given an identity public key as input, this command will respond with the
/// corresponding public/private key pair from the wallet. If the desired identity
/// key isn’t currently stored in the wallet, an error is returned to indicate this.
/// If the wallet is encrypted, it must be unlocked prior to using this command.
/// # Example
/// ```
/// use factom::*;
///
/// #[tokio::main]
/// async fn main() {
/// let client = Factom::new();
/// /// Generate key
/// let gen_response = generate::identity_key(&client).await.unwrap();
/// let pub_id = &gen_response.result.public;
/// let priv_id = &gen_response.result.secret;
/// /// Get key from wallet
/// let id_response = identity::id_key(&client, pub_id).await.unwrap();
/// assert_eq!(&id_response.result.secret, priv_id);
/// /// Remove key
/// let remove_response = identity::remove_id_key(&client, &pub_id).await.unwrap();
/// }
/// ```
pub async
/// all-identity-keys function
/// identity-key function
/// active-identity-keys function
/// remove-id-key function