File size: 4,569 Bytes
163043c
 
cc036f3
163043c
cc036f3
 
163043c
cc036f3
163043c
 
 
 
 
cc036f3
163043c
 
 
cc036f3
163043c
cc036f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163043c
 
cc036f3
 
163043c
cc036f3
 
163043c
cc036f3
163043c
 
cc036f3
163043c
cc036f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163043c
 
cc036f3
 
 
 
 
 
 
 
 
 
 
163043c
cc036f3
 
163043c
cc036f3
163043c
 
cc036f3
163043c
 
cc036f3
 
 
 
 
163043c
 
 
 
 
 
cc036f3
 
 
 
 
163043c
cc036f3
163043c
 
cc036f3
163043c
 
cc036f3
 
 
 
 
163043c
 
 
 
 
cc036f3
 
 
 
 
163043c
cc036f3
163043c
 
cc036f3
 
163043c
 
 
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
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://hypercortex.org/schemas/dht_protocol.json",
  "title": "DHT Protocol Schema",
  "description": "Schema for DISCOVERY and PEER_EXCHANGE messages in the HyperCortex Mesh DHT layer.",
  "schema_version": "4.2",
  "type": "object",

  "oneOf": [
    { "$ref": "#/definitions/discovery" },
    { "$ref": "#/definitions/peerExchangeRequest" },
    { "$ref": "#/definitions/peerExchangeResponse" }
  ],

  "definitions": {
    "interface": {
      "type": "object",
      "required": ["addr", "nonce", "pow_hash", "difficulty", "datetime", "type"],
      "properties": {
        "addr": {
          "type": "string",
          "pattern": "^(tcp|udp)://.+",
          "description": "Full address of the peer (transport://host:port)."
        },
        "nonce": {
          "type": "integer",
          "minimum": 0,
          "description": "Proof-of-Work nonce."
        },
        "pow_hash": {
          "type": "string",
          "description": "Proof-of-Work SHA256 hash result."
        },
        "difficulty": {
          "type": "integer",
          "minimum": 1,
          "description": "Difficulty level of the Proof-of-Work."
        },
        "datetime": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp of when the address was last validated."
        },
        "type": {
          "type": "string",
          "description": "Interface type: internet, localhost, or private network.",
          "pattern": "^(localhost|internet|yggdrasil|i2p|lan:[0-9]{1,3}(\\.[0-9]{1,3}){3})$"
        }
      },
      "additionalProperties": false
    },

    "peer": {
      "type": "object",
      "required": ["id", "name", "pubkey", "addresses", "signature", "sig_algo", "version"],
      "properties": {
        "version": {
          "type": "string",
          "description": "Version of this peer record format.",
          "default": "1.0"
        },
        "id": {
          "type": "string",
          "description": "Peer's decentralized identifier (DID)."
        },
        "name": {
          "type": "string",
          "description": "Human-readable name of the peer."
        },
        "pubkey": {
          "type": "string",
          "description": "Base58-encoded Ed25519 public key."
        },
        "addresses": {
          "type": "array",
          "items": { "$ref": "#/definitions/interface" },
          "description": "List of network interfaces associated with this peer."
        },
        "signature": {
          "type": "string",
          "description": "Base64URL-encoded Ed25519 signature of this record."
        },
        "sig_algo": {
          "type": "string",
          "enum": ["ed25519"],
          "description": "Signature algorithm used for signing the record."
        }
      },
      "additionalProperties": false
    },

    "discovery": {
      "type": "object",
      "required": ["type", "version", "id", "name", "pubkey", "addresses", "signature", "sig_algo"],
      "properties": {
        "type": { "const": "DISCOVERY" },
        "version": {
          "type": "string",
          "description": "Version of the DISCOVERY message format.",
          "default": "1.0"
        },
        "id": { "type": "string" },
        "name": { "type": "string" },
        "pubkey": { "type": "string" },
        "addresses": {
          "type": "array",
          "items": { "$ref": "#/definitions/interface" }
        },
        "signature": { "type": "string" },
        "sig_algo": { "type": "string", "enum": ["ed25519"] }
      },
      "additionalProperties": false
    },

    "peerExchangeRequest": {
      "type": "object",
      "required": ["type", "version", "id", "name", "addresses", "signature", "sig_algo"],
      "properties": {
        "type": { "const": "PEER_EXCHANGE_REQUEST" },
        "version": {
          "type": "string",
          "description": "Version of the PEER_EXCHANGE_REQUEST format.",
          "default": "1.0"
        },
        "id": { "type": "string" },
        "name": { "type": "string" },
        "addresses": {
          "type": "array",
          "items": { "$ref": "#/definitions/interface" }
        },
        "signature": { "type": "string" },
        "sig_algo": { "type": "string", "enum": ["ed25519"] }
      },
      "additionalProperties": false
    },

    "peerExchangeResponse": {
      "type": "array",
      "items": { "$ref": "#/definitions/peer" },
      "description": "List of peers known to the responding agent."
    }
  }
}