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
//! # Agent metadata documentation.
//!
//! [AgentInfo] and the wrapping [AgentInfoSigned] define a pattern for
//! cryptographically verifiable declarations of network reachability.
//!
//! To facilitate ease of debugging (See our unit tests in this module!),
//! The canonical encoding for this info is JSON.
//!
//! #### Json Schemas
//!
//! ```json
//! {
//! "title": "AgentInfoSigned",
//! "type": "object",
//! "properties": {
//! "agentInfo": { "type": "string", "required": true, "description": "json AgentInfo" },
//! "signature": { "type": "string", "required": true, "description": "base64" }
//! }
//! }
//! ```
//!
//! ```json
//! {
//! "title": "AgentInfo",
//! "type": "object",
//! "properties": {
//! "agent": { "type": "string", "required": true, "description": "base64" },
//! "space": { "type": "string", "required": true, "description": "base64" },
//! "createdAt": {
//! "type": "string",
//! "required": true,
//! "description": "i64 micros since unix epoch"
//! },
//! "expiresAt": {
//! "type": "string",
//! "required": true,
//! "description": "i64 micros since unix epoch",
//! },
//! "isTombstone": { "type": "boolean", "required": true },
//! "url": { "type": "string", "description": "optional" },
//! "storageArc": {
//! "type": "array",
//! "description": "optional",
//! "items": [
//! {
//! "type": "number",
//! "required": true,
//! "description": "u32 arc start loc"
//! },
//! {
//! "type": "number",
//! "required": true,
//! "description": "u32 arc end loc"
//! }
//! ]
//! }
//! }
//! }
//! ```
//!
//! #### Cryptography
//!
//! This module and its data structures are designed to be agnostic to
//! cryptography. It exposes the [Signer] and [Verifier] traits to allow
//! implementors to choose the algorithm to be used.
//!
//! The underlying data structures, however, cannot be quite so agnostic.
//!
//! By convention, absent other indications, the [crate::AgentInfo::agent] property
//! will be an ed25519 public key, and the [crate::AgentInfoSigned::get_signature] will
//! be an ed25519 signature.
//!
//! Future versions of this library may look for an optional "alg" property
//! on the [crate::AgentInfo] type before falling back to this usage of ed25519.
//! These other algorithms may treat the [crate::AgentInfo::agent] property as a
//! hash of the public key instead of the public key itself, and find the
//! public key instead on an "algPubKey" property. (Some post-quantum
//! algorithms have ridiculously long key material.)
//!
//! [AgentInfo]: crate::AgentInfo
//! [AgentInfoSigned]: crate::AgentInfoSigned
//! [Signer]: crate::Signer
//! [Verifier]: crate::Verifier