@derec-alliance/nodejs 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/derec_descriptor.bin +0 -0
- package/derec_library_bg.wasm +0 -0
- package/package.json +3 -1
- package/proto/committedderecshare.proto +79 -0
- package/proto/communicationinfo.proto +104 -0
- package/proto/contact.proto +264 -0
- package/proto/derecmessage.proto +213 -0
- package/proto/derecsecret.proto +163 -0
- package/proto/derectransport.proto +38 -0
- package/proto/error.proto +60 -0
- package/proto/getshare.proto +194 -0
- package/proto/pair.proto +284 -0
- package/proto/parameterrange.proto +36 -0
- package/proto/prepair.proto +177 -0
- package/proto/result.proto +194 -0
- package/proto/secretidsversions.proto +209 -0
- package/proto/storeshare.proto +274 -0
- package/proto/transportprotocol.proto +100 -0
- package/proto/unpair.proto +140 -0
- package/proto/updatechannelinfo.proto +129 -0
- package/proto/verify.proto +170 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) DeRec Alliance and its Contributors.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
syntax = "proto3";
|
|
7
|
+
|
|
8
|
+
import "google/protobuf/timestamp.proto";
|
|
9
|
+
import "pair.proto";
|
|
10
|
+
import "unpair.proto";
|
|
11
|
+
import "storeshare.proto";
|
|
12
|
+
import "verify.proto";
|
|
13
|
+
import "getshare.proto";
|
|
14
|
+
import "secretidsversions.proto";
|
|
15
|
+
import "updatechannelinfo.proto";
|
|
16
|
+
import "prepair.proto";
|
|
17
|
+
import "error.proto";
|
|
18
|
+
|
|
19
|
+
package org.derecalliance.derec.protobuf;
|
|
20
|
+
|
|
21
|
+
// DeRecMessage is the top-level protocol envelope for all DeRec messages,
|
|
22
|
+
// except ContactMessage which is exchanged out-of-band during pairing.
|
|
23
|
+
//
|
|
24
|
+
// This message represents the unit of communication between an Owner and a
|
|
25
|
+
// Helper once a secure channel has been established. Every protocol exchange
|
|
26
|
+
// (pairing, sharing, verification, recovery, etc.) is carried inside this
|
|
27
|
+
// envelope.
|
|
28
|
+
//
|
|
29
|
+
// # Security Model
|
|
30
|
+
//
|
|
31
|
+
// The DeRecMessage envelope itself is not responsible for confidentiality or
|
|
32
|
+
// authenticity. Instead:
|
|
33
|
+
//
|
|
34
|
+
// - The `message` field contains encrypted bytes representing the inner message
|
|
35
|
+
// - Encryption is applied at the payload level prior to transport
|
|
36
|
+
//
|
|
37
|
+
// Implementations MUST ensure that:
|
|
38
|
+
//
|
|
39
|
+
// - The inner message is encrypted using the agreed channel keys
|
|
40
|
+
// - The envelope metadata is treated as untrusted until the payload is verified
|
|
41
|
+
//
|
|
42
|
+
// # Semantics
|
|
43
|
+
//
|
|
44
|
+
// A DeRecMessage provides:
|
|
45
|
+
//
|
|
46
|
+
// - protocol versioning information for compatibility handling
|
|
47
|
+
// - ordering guarantees via a monotonically increasing sequence number
|
|
48
|
+
// - channel identification for routing and key selection
|
|
49
|
+
// - a timestamp for replay protection and observability
|
|
50
|
+
// - an encrypted payload containing exactly one protocol message
|
|
51
|
+
//
|
|
52
|
+
// The envelope is transport-agnostic and can be delivered over any supported
|
|
53
|
+
// transport (e.g., HTTPS, message queues), as defined by TransportProtocol.
|
|
54
|
+
//
|
|
55
|
+
// # Ordering and Idempotency
|
|
56
|
+
//
|
|
57
|
+
// Communication follows a request/response pattern:
|
|
58
|
+
//
|
|
59
|
+
// - The Owner sends a request message
|
|
60
|
+
// - The Helper replies with a corresponding response
|
|
61
|
+
//
|
|
62
|
+
// The `sequence` field is used to:
|
|
63
|
+
//
|
|
64
|
+
// - enforce message ordering
|
|
65
|
+
// - detect duplicates or out-of-order delivery
|
|
66
|
+
// - support replay protection
|
|
67
|
+
//
|
|
68
|
+
// Implementations SHOULD treat messages as idempotent and be resilient to
|
|
69
|
+
// retries and duplicate deliveries.
|
|
70
|
+
//
|
|
71
|
+
// # Key Rotation
|
|
72
|
+
//
|
|
73
|
+
// The sequence number may also be used as a trigger for automatic key rotation.
|
|
74
|
+
// When a configured threshold is reached, implementations MAY initiate a key
|
|
75
|
+
// rotation flow to maintain forward secrecy.
|
|
76
|
+
//
|
|
77
|
+
// # Versioning
|
|
78
|
+
//
|
|
79
|
+
// The protocolVersionMajor and protocolVersionMinor fields allow peers to:
|
|
80
|
+
//
|
|
81
|
+
// - detect incompatible protocol versions
|
|
82
|
+
// - apply backward-compatible parsing logic when possible
|
|
83
|
+
//
|
|
84
|
+
// Implementations MUST define behavior for handling version mismatches.
|
|
85
|
+
//
|
|
86
|
+
// # Payload Encoding
|
|
87
|
+
//
|
|
88
|
+
// The `message` field contains encrypted raw bytes. When decrypted, these bytes
|
|
89
|
+
// MUST deserialize into a MessageBody, which contains exactly one concrete
|
|
90
|
+
// protocol message.
|
|
91
|
+
//
|
|
92
|
+
// The oneof structure ensures that each DeRecMessage carries a single logical
|
|
93
|
+
// operation.
|
|
94
|
+
message DeRecMessage {
|
|
95
|
+
// DeRec protocol major version.
|
|
96
|
+
//
|
|
97
|
+
// Incremented for breaking changes that are not backward compatible.
|
|
98
|
+
uint32 protocolVersionMajor = 1;
|
|
99
|
+
|
|
100
|
+
// DeRec protocol minor version.
|
|
101
|
+
//
|
|
102
|
+
// Incremented for backward-compatible changes such as adding new fields
|
|
103
|
+
// or message types.
|
|
104
|
+
uint32 protocolVersionMinor = 2;
|
|
105
|
+
|
|
106
|
+
// Monotonically increasing message sequence number.
|
|
107
|
+
//
|
|
108
|
+
// This value increments by 1 for each message sent on a given channel.
|
|
109
|
+
// It is used to:
|
|
110
|
+
//
|
|
111
|
+
// - enforce ordering
|
|
112
|
+
// - detect duplicates or missing messages
|
|
113
|
+
// - support replay protection
|
|
114
|
+
//
|
|
115
|
+
// Implementations MAY also use this value to trigger automatic key rotation
|
|
116
|
+
// once a predefined threshold is reached.
|
|
117
|
+
uint32 sequence = 3;
|
|
118
|
+
|
|
119
|
+
// Channel identifier associated with this communication session.
|
|
120
|
+
//
|
|
121
|
+
// This value uniquely identifies the logical channel between an Owner and
|
|
122
|
+
// a Helper for a given secret. It is established during pairing and used
|
|
123
|
+
// thereafter to:
|
|
124
|
+
//
|
|
125
|
+
// - route messages to the correct channel state
|
|
126
|
+
// - select the appropriate cryptographic keys
|
|
127
|
+
//
|
|
128
|
+
// This MUST match the channelId exchanged during the ContactMessage phase.
|
|
129
|
+
uint64 channelId = 4;
|
|
130
|
+
|
|
131
|
+
// Timestamp indicating when the sender created this message.
|
|
132
|
+
//
|
|
133
|
+
// This value is expressed in UTC and can be used for:
|
|
134
|
+
//
|
|
135
|
+
// - replay detection
|
|
136
|
+
// - timeout handling
|
|
137
|
+
// - logging and observability
|
|
138
|
+
//
|
|
139
|
+
// Implementations SHOULD NOT rely solely on this value for security-critical
|
|
140
|
+
// decisions without additional protections.
|
|
141
|
+
google.protobuf.Timestamp timestamp = 5;
|
|
142
|
+
|
|
143
|
+
// Encrypted message payload.
|
|
144
|
+
//
|
|
145
|
+
// This field contains the encrypted bytes of a serialized MessageBody.
|
|
146
|
+
// The encryption scheme and key material are defined by the pairing process
|
|
147
|
+
// and subsequent key management flows.
|
|
148
|
+
//
|
|
149
|
+
// Upon decryption, this field MUST deserialize into a valid MessageBody
|
|
150
|
+
// containing exactly one protocol message.
|
|
151
|
+
bytes message = 6;
|
|
152
|
+
|
|
153
|
+
// Application-supplied correlation token, echoed verbatim by the
|
|
154
|
+
// responder on the matching response envelope.
|
|
155
|
+
//
|
|
156
|
+
// # Purpose
|
|
157
|
+
//
|
|
158
|
+
// Lets the side that originated a request match the eventual response to
|
|
159
|
+
// the in-flight request that produced it, even when:
|
|
160
|
+
//
|
|
161
|
+
// - multiple requests are outstanding on the same channel,
|
|
162
|
+
// - responses arrive out of order with respect to send order,
|
|
163
|
+
// - the responder takes arbitrary time to reply.
|
|
164
|
+
//
|
|
165
|
+
// # Semantics
|
|
166
|
+
//
|
|
167
|
+
// - On a request envelope: the requester sets this to any value it can
|
|
168
|
+
// use to correlate the response back to the originating call site. A
|
|
169
|
+
// random `uint64` is a typical choice; collisions are unlikely at any
|
|
170
|
+
// realistic concurrency level.
|
|
171
|
+
// - On a response envelope: the responder MUST copy the request's
|
|
172
|
+
// `traceId` verbatim. The library does this automatically in every
|
|
173
|
+
// response producer.
|
|
174
|
+
// - Zero (the protobuf default when unset) is treated as "no correlation
|
|
175
|
+
// requested." Responders still echo the zero on the response envelope;
|
|
176
|
+
// requesters that do not care about correlation simply ignore the
|
|
177
|
+
// field.
|
|
178
|
+
//
|
|
179
|
+
// # Privacy
|
|
180
|
+
//
|
|
181
|
+
// This field is plaintext on the wire (the envelope is not encrypted).
|
|
182
|
+
// The token itself is opaque, so it carries no information about either
|
|
183
|
+
// peer's identity or intent — it is purely a correlation handle. Passive
|
|
184
|
+
// observers could already correlate request/response pairs by channelId
|
|
185
|
+
// and timing; `traceId` does not add to that exposure.
|
|
186
|
+
uint64 traceId = 7;
|
|
187
|
+
|
|
188
|
+
// MessageBody defines all possible DeRec protocol messages that can be
|
|
189
|
+
// transported inside the DeRecMessage envelope.
|
|
190
|
+
//
|
|
191
|
+
// Exactly one of the fields MUST be set when constructing a message.
|
|
192
|
+
message MessageBody {
|
|
193
|
+
oneof body {
|
|
194
|
+
PairRequestMessage pairRequestMessage = 1;
|
|
195
|
+
PairResponseMessage pairResponseMessage = 2;
|
|
196
|
+
UnpairRequestMessage unpairRequestMessage = 3;
|
|
197
|
+
UnpairResponseMessage unpairResponseMessage = 4;
|
|
198
|
+
StoreShareRequestMessage storeShareRequestMessage = 5;
|
|
199
|
+
StoreShareResponseMessage storeShareResponseMessage = 6;
|
|
200
|
+
VerifyShareRequestMessage verifyShareRequestMessage = 7;
|
|
201
|
+
VerifyShareResponseMessage verifyShareResponseMessage = 8;
|
|
202
|
+
GetSecretIdsVersionsRequestMessage getSecretIdsVersionsRequestMessage = 9;
|
|
203
|
+
GetSecretIdsVersionsResponseMessage getSecretIdsVersionsResponseMessage = 10;
|
|
204
|
+
GetShareRequestMessage getShareRequestMessage = 11;
|
|
205
|
+
GetShareResponseMessage getShareResponseMessage = 12;
|
|
206
|
+
ErrorResponseMessage errorResponseMessage = 13;
|
|
207
|
+
UpdateChannelInfoRequestMessage updateChannelInfoRequestMessage = 14;
|
|
208
|
+
UpdateChannelInfoResponseMessage updateChannelInfoResponseMessage = 15;
|
|
209
|
+
PrePairRequestMessage prePairRequestMessage = 16;
|
|
210
|
+
PrePairResponseMessage prePairResponseMessage = 17;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) DeRec Alliance and its Contributors.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
syntax = "proto3";
|
|
7
|
+
|
|
8
|
+
import "result.proto";
|
|
9
|
+
import "parameterrange.proto";
|
|
10
|
+
import "google/protobuf/timestamp.proto";
|
|
11
|
+
|
|
12
|
+
package org.derecalliance.derec.protobuf;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// HelperSpecificInfo captures per-helper metadata associated with a secret.
|
|
16
|
+
//
|
|
17
|
+
// # Purpose
|
|
18
|
+
//
|
|
19
|
+
// This message binds a specific Helper to:
|
|
20
|
+
//
|
|
21
|
+
// - its identity (via a hash of its public encryption key)
|
|
22
|
+
// - the parameters agreed during pairing with the Owner
|
|
23
|
+
//
|
|
24
|
+
// This information allows the Owner to:
|
|
25
|
+
//
|
|
26
|
+
// - track which Helpers are associated with a given secret
|
|
27
|
+
// - reconstruct the correct configuration during recovery
|
|
28
|
+
// - verify that Helpers are operating under the expected parameters
|
|
29
|
+
//
|
|
30
|
+
// # Semantics
|
|
31
|
+
//
|
|
32
|
+
// Each entry represents one Helper participating in the secret sharing
|
|
33
|
+
// scheme. The collection of these entries defines the Helper set for
|
|
34
|
+
// a given version of the secret.
|
|
35
|
+
//
|
|
36
|
+
// # Identity Binding
|
|
37
|
+
//
|
|
38
|
+
// The `helper` field is a SHA-384 hash of the Helper's public encryption
|
|
39
|
+
// key. This provides a stable identifier without exposing the key itself.
|
|
40
|
+
//
|
|
41
|
+
// Implementations MUST ensure that:
|
|
42
|
+
//
|
|
43
|
+
// - the hash corresponds to the exact public key used during pairing
|
|
44
|
+
// - the mapping between Helper identity and key is preserved
|
|
45
|
+
//
|
|
46
|
+
// # Parameter Agreement
|
|
47
|
+
//
|
|
48
|
+
// The `helperParams` field records the parameter range agreed between
|
|
49
|
+
// the Owner and the Helper during pairing. This ensures that:
|
|
50
|
+
//
|
|
51
|
+
// - the share distribution is consistent with negotiated constraints
|
|
52
|
+
// - recovery can validate expected parameters
|
|
53
|
+
message HelperSpecificInfo {
|
|
54
|
+
|
|
55
|
+
// SHA-384 hash of the Helper's public encryption key.
|
|
56
|
+
//
|
|
57
|
+
// This uniquely identifies the Helper within the context of the secret
|
|
58
|
+
// without exposing the raw key material.
|
|
59
|
+
bytes helper = 1;
|
|
60
|
+
|
|
61
|
+
// Parameters agreed upon between the Helper and the Owner.
|
|
62
|
+
//
|
|
63
|
+
// These parameters originate from the intersection of both parties'
|
|
64
|
+
// supported ranges during pairing.
|
|
65
|
+
ParameterRange helperParams = 2;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// DeRecSecret represents the canonical structure of the secret material
|
|
70
|
+
// that is encrypted and distributed across Helpers.
|
|
71
|
+
//
|
|
72
|
+
// # Context
|
|
73
|
+
//
|
|
74
|
+
// Before distribution:
|
|
75
|
+
//
|
|
76
|
+
// - the Owner constructs a DeRecSecret
|
|
77
|
+
// - the `secretData` is encrypted (e.g., via AES-GCM)
|
|
78
|
+
// - the encryption key is split using a secret sharing scheme (e.g., Shamir)
|
|
79
|
+
//
|
|
80
|
+
// The resulting shares are then distributed to Helpers.
|
|
81
|
+
//
|
|
82
|
+
// This message defines the structure used by "share algorithm 0".
|
|
83
|
+
//
|
|
84
|
+
// # Semantics
|
|
85
|
+
//
|
|
86
|
+
// A DeRecSecret contains:
|
|
87
|
+
//
|
|
88
|
+
// - the raw secret payload
|
|
89
|
+
// - metadata describing the sharing configuration
|
|
90
|
+
// - the set of Helpers and their associated parameters
|
|
91
|
+
//
|
|
92
|
+
// This metadata is critical for:
|
|
93
|
+
//
|
|
94
|
+
// - reconstructing the secret during recovery
|
|
95
|
+
// - validating the integrity and configuration of shares
|
|
96
|
+
//
|
|
97
|
+
// # Thresholds
|
|
98
|
+
//
|
|
99
|
+
// Two thresholds are defined:
|
|
100
|
+
//
|
|
101
|
+
// 1. Recovery threshold:
|
|
102
|
+
// - Minimum number of Helpers required to reconstruct the secret
|
|
103
|
+
//
|
|
104
|
+
// 2. Confirmation threshold:
|
|
105
|
+
// - Minimum number of Helpers that must acknowledge receipt of a new
|
|
106
|
+
// share version before older versions can be safely deleted
|
|
107
|
+
//
|
|
108
|
+
// # Security Considerations
|
|
109
|
+
//
|
|
110
|
+
// - The entire DeRecSecret MUST be encrypted before distribution
|
|
111
|
+
// - Helpers MUST NOT have access to the plaintext secretData
|
|
112
|
+
// - Metadata should not leak sensitive information beyond what is required
|
|
113
|
+
//
|
|
114
|
+
// # Versioning
|
|
115
|
+
//
|
|
116
|
+
// Each share distribution version implicitly corresponds to a snapshot
|
|
117
|
+
// of this structure. Changes to:
|
|
118
|
+
//
|
|
119
|
+
// - secretData
|
|
120
|
+
// - helper set
|
|
121
|
+
// - thresholds
|
|
122
|
+
//
|
|
123
|
+
// result in a new version being generated and distributed.
|
|
124
|
+
message DeRecSecret {
|
|
125
|
+
|
|
126
|
+
// Arbitrary secret payload.
|
|
127
|
+
//
|
|
128
|
+
// This may include cryptographic keys, credentials, documents, or any
|
|
129
|
+
// serialized data the Owner wishes to protect. When produced by the DeRec
|
|
130
|
+
// library, these bytes are the recoverable secret: a 1-byte version prefix
|
|
131
|
+
// followed by a versioned payload (v1 = gzip-compressed (RFC 1952) JSON,
|
|
132
|
+
// base64 (RFC 4648 §4) byte fields, u64 as decimal strings). Other payloads
|
|
133
|
+
// MAY use a different encoding; secretData is opaque to the protocol.
|
|
134
|
+
bytes secretData = 1;
|
|
135
|
+
|
|
136
|
+
// Timestamp indicating when this secret (or this version of it) was created.
|
|
137
|
+
//
|
|
138
|
+
// Used for auditing, version tracking, and observability.
|
|
139
|
+
google.protobuf.Timestamp creationTime = 2;
|
|
140
|
+
|
|
141
|
+
// Minimum number of Helpers required to reconstruct the secret.
|
|
142
|
+
//
|
|
143
|
+
// This corresponds to the threshold parameter of the underlying
|
|
144
|
+
// secret sharing scheme.
|
|
145
|
+
int64 helperThresholdForRecovery = 3;
|
|
146
|
+
|
|
147
|
+
// Minimum number of Helpers that must confirm receipt of a share
|
|
148
|
+
// before older versions can be deleted.
|
|
149
|
+
//
|
|
150
|
+
// This ensures that sufficient redundancy exists before removing
|
|
151
|
+
// previous share versions.
|
|
152
|
+
int64 helperThresholdForConfirmingShareReceipt = 4;
|
|
153
|
+
|
|
154
|
+
// List of Helpers participating in this secret.
|
|
155
|
+
//
|
|
156
|
+
// Each entry defines:
|
|
157
|
+
//
|
|
158
|
+
// - the identity of the Helper
|
|
159
|
+
// - the parameters agreed with that Helper
|
|
160
|
+
//
|
|
161
|
+
// The size of this list defines the total number of shares generated.
|
|
162
|
+
repeated HelperSpecificInfo helpers = 5;
|
|
163
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) DeRec Alliance and its Contributors.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
syntax = "proto3";
|
|
7
|
+
|
|
8
|
+
package org.derecalliance.derec.protobuf;
|
|
9
|
+
|
|
10
|
+
import "derecmessage.proto";
|
|
11
|
+
import "google/protobuf/empty.proto";
|
|
12
|
+
|
|
13
|
+
/// Delivery service for DeRec messages over gRPC.
|
|
14
|
+
///
|
|
15
|
+
/// Mirrors the request/response-free delivery model the protocol already
|
|
16
|
+
/// uses: a sender hands one envelope to one endpoint and learns only whether
|
|
17
|
+
/// delivery succeeded.
|
|
18
|
+
///
|
|
19
|
+
/// # Push-only
|
|
20
|
+
///
|
|
21
|
+
/// `Send` returns `google.protobuf.Empty`. There is no inline reply. A
|
|
22
|
+
/// responder answers by opening a new `Send` to the requester's own
|
|
23
|
+
/// endpoint, which means **both parties must run a reachable server**.
|
|
24
|
+
/// Responses are correlated by the envelope's `traceId`, not by the call.
|
|
25
|
+
///
|
|
26
|
+
/// # Security
|
|
27
|
+
///
|
|
28
|
+
/// This service provides no security guarantees of its own. Every
|
|
29
|
+
/// `DeRecMessage` carries its payload signed and encrypted at the
|
|
30
|
+
/// application layer, and remains valid regardless of transport.
|
|
31
|
+
service DeRecTransport {
|
|
32
|
+
/// Deliver one DeRec envelope to this endpoint.
|
|
33
|
+
///
|
|
34
|
+
/// Returns once the receiver has accepted the envelope for processing.
|
|
35
|
+
/// Acceptance is not a protocol-level acknowledgement: a protocol
|
|
36
|
+
/// response, if any, arrives as a separate `Send` call.
|
|
37
|
+
rpc Send(DeRecMessage) returns (google.protobuf.Empty);
|
|
38
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) DeRec Alliance and its Contributors.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
syntax = "proto3";
|
|
7
|
+
|
|
8
|
+
import "result.proto";
|
|
9
|
+
|
|
10
|
+
package org.derecalliance.derec.protobuf;
|
|
11
|
+
|
|
12
|
+
// ErrorResponseMessage is a generic error response sent when a protocol
|
|
13
|
+
// message cannot be processed successfully.
|
|
14
|
+
//
|
|
15
|
+
// # Context
|
|
16
|
+
//
|
|
17
|
+
// This message may be returned in response to any DeRecMessage when the
|
|
18
|
+
// receiver encounters an error during processing.
|
|
19
|
+
//
|
|
20
|
+
// Typical scenarios include:
|
|
21
|
+
//
|
|
22
|
+
// - malformed or invalid message payloads
|
|
23
|
+
// - unsupported or unknown message types
|
|
24
|
+
// - protocol violations (e.g., invalid sequence, nonce mismatch)
|
|
25
|
+
// - authorization or validation failures
|
|
26
|
+
//
|
|
27
|
+
// # Semantics
|
|
28
|
+
//
|
|
29
|
+
// This message indicates that:
|
|
30
|
+
//
|
|
31
|
+
// - the original request was not successfully processed
|
|
32
|
+
// - no state change should be assumed by the sender
|
|
33
|
+
//
|
|
34
|
+
// The sender SHOULD:
|
|
35
|
+
//
|
|
36
|
+
// - inspect the `result` field to determine the cause of the failure
|
|
37
|
+
// - decide whether to retry, abort, or escalate based on the error
|
|
38
|
+
//
|
|
39
|
+
// # Usage Guidelines
|
|
40
|
+
//
|
|
41
|
+
// - This message is intended as a fallback when no more specific response
|
|
42
|
+
// type is applicable
|
|
43
|
+
// - Protocol-specific errors SHOULD use their corresponding response
|
|
44
|
+
// messages when available
|
|
45
|
+
//
|
|
46
|
+
// # Security Considerations
|
|
47
|
+
//
|
|
48
|
+
// - Error responses SHOULD avoid leaking sensitive internal details
|
|
49
|
+
// - Only high-level error information should be exposed via `result`
|
|
50
|
+
//
|
|
51
|
+
// # Idempotency
|
|
52
|
+
//
|
|
53
|
+
// Error responses are idempotent and may be returned multiple times
|
|
54
|
+
// for repeated invalid requests.
|
|
55
|
+
message ErrorResponseMessage {
|
|
56
|
+
// Result describing the error encountered while processing the request.
|
|
57
|
+
//
|
|
58
|
+
// This field encodes the error type and any associated status information.
|
|
59
|
+
DeRecResult result = 1;
|
|
60
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) DeRec Alliance and its Contributors.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
syntax = "proto3";
|
|
7
|
+
|
|
8
|
+
import "google/protobuf/timestamp.proto";
|
|
9
|
+
import "result.proto";
|
|
10
|
+
import "transportprotocol.proto";
|
|
11
|
+
|
|
12
|
+
package org.derecalliance.derec.protobuf;
|
|
13
|
+
|
|
14
|
+
// GetShareRequestMessage requests a previously stored share from a Helper.
|
|
15
|
+
//
|
|
16
|
+
// # Context
|
|
17
|
+
//
|
|
18
|
+
// This message is used during the recovery flow, after pairing has been
|
|
19
|
+
// established (typically in recovery mode). Once a Helper has indicated
|
|
20
|
+
// which secret IDs and versions it holds, the Owner sends this request
|
|
21
|
+
// to retrieve specific shares.
|
|
22
|
+
//
|
|
23
|
+
// # Semantics
|
|
24
|
+
//
|
|
25
|
+
// The request identifies a share by:
|
|
26
|
+
//
|
|
27
|
+
// - `secretId`: the identifier of the protected secret
|
|
28
|
+
// - `version`: the version of the share distribution
|
|
29
|
+
//
|
|
30
|
+
// The Helper is expected to locate the corresponding share and return it
|
|
31
|
+
// in a GetShareResponseMessage.
|
|
32
|
+
//
|
|
33
|
+
// # Authorization Rules
|
|
34
|
+
//
|
|
35
|
+
// The Helper MUST only process this request if it is received through a
|
|
36
|
+
// valid communication channel that is authorized to access the requested
|
|
37
|
+
// share. Specifically:
|
|
38
|
+
//
|
|
39
|
+
// - the request MUST originate from the same secretId channel, OR
|
|
40
|
+
// - the request MUST originate from a channel established in recovery mode
|
|
41
|
+
// and associated with the same user
|
|
42
|
+
//
|
|
43
|
+
// Otherwise, the Helper MUST reject the request.
|
|
44
|
+
//
|
|
45
|
+
// # Idempotency
|
|
46
|
+
//
|
|
47
|
+
// This request is idempotent. Repeated requests for the same (secretId,
|
|
48
|
+
// version) pair SHOULD return the same result.
|
|
49
|
+
message GetShareRequestMessage {
|
|
50
|
+
|
|
51
|
+
// Numeric identifier of the secret for which the share is requested.
|
|
52
|
+
//
|
|
53
|
+
// Generated by the Owner when the secret is created. It uniquely
|
|
54
|
+
// identifies the secret within the context of the Owner and its Helpers.
|
|
55
|
+
uint64 secretId = 1;
|
|
56
|
+
|
|
57
|
+
// Version of the share being requested.
|
|
58
|
+
//
|
|
59
|
+
// Each time a secret is reshared (e.g., due to updates or changes in
|
|
60
|
+
// helper set), a new version is created. This field specifies which
|
|
61
|
+
// version of the share should be returned.
|
|
62
|
+
uint32 version = 2;
|
|
63
|
+
|
|
64
|
+
// Timestamp indicating when this message was created.
|
|
65
|
+
//
|
|
66
|
+
// This value is expressed in UTC and can be used for:
|
|
67
|
+
//
|
|
68
|
+
// - observability and logging
|
|
69
|
+
// - replay detection (in combination with sequence numbers)
|
|
70
|
+
// - timeout handling
|
|
71
|
+
google.protobuf.Timestamp timestamp = 3;
|
|
72
|
+
|
|
73
|
+
// Ephemeral transport endpoint at which the requester wants to receive
|
|
74
|
+
// the response to *this exchange*, overriding the channel's stored peer
|
|
75
|
+
// endpoint for this round-trip only.
|
|
76
|
+
//
|
|
77
|
+
// See `StoreShareRequestMessage.replyTo` for full semantics.
|
|
78
|
+
//
|
|
79
|
+
// Superseded by `replyToTransports`, which carries every endpoint rather
|
|
80
|
+
// than one. Kept, and still populated with the list's first entry, so
|
|
81
|
+
// implementations predating that field still receive a reply.
|
|
82
|
+
// **Scheduled for removal in v0.0.5.** Reading this field directly is now
|
|
83
|
+
// incorrect — resolve it against `replyToTransports`.
|
|
84
|
+
optional TransportProtocol replyTo = 4 [deprecated = true];
|
|
85
|
+
|
|
86
|
+
// Every ephemeral endpoint the requester wants this exchange's response
|
|
87
|
+
// delivered to, in its own preference order.
|
|
88
|
+
//
|
|
89
|
+
// See `StoreShareRequestMessage.replyToTransports` for full semantics,
|
|
90
|
+
// including why this is a new tag rather than a widened `replyTo`.
|
|
91
|
+
repeated TransportProtocol replyToTransports = 6;
|
|
92
|
+
|
|
93
|
+
// Identity of the replica-group member this message concerns.
|
|
94
|
+
//
|
|
95
|
+
// Present **only** on the replica path, where a member drives catch-up
|
|
96
|
+
// against another member. Absent on the owner ↔ helper path, which is
|
|
97
|
+
// unchanged.
|
|
98
|
+
//
|
|
99
|
+
// Every member of a group is addressed on one shared `channel_id`, so the
|
|
100
|
+
// channel cannot name the peer — this field does. Its presence is also what
|
|
101
|
+
// tells the receiver which path a message belongs to.
|
|
102
|
+
optional uint64 replicaId = 5;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// GetShareResponseMessage returns a share previously stored by the Helper.
|
|
106
|
+
//
|
|
107
|
+
// # Semantics
|
|
108
|
+
//
|
|
109
|
+
// This message is sent in response to a GetShareRequestMessage. It either:
|
|
110
|
+
//
|
|
111
|
+
// - returns the requested share (on success), or
|
|
112
|
+
// - indicates failure via the `result` field
|
|
113
|
+
//
|
|
114
|
+
// # Authorization Enforcement
|
|
115
|
+
//
|
|
116
|
+
// The Helper MUST ensure that the request satisfies the authorization rules
|
|
117
|
+
// described in GetShareRequestMessage before returning any share data.
|
|
118
|
+
//
|
|
119
|
+
// # Share Contents
|
|
120
|
+
//
|
|
121
|
+
// The returned share is an opaque byte sequence that typically includes:
|
|
122
|
+
//
|
|
123
|
+
// - the Shamir share (x, y)
|
|
124
|
+
// - the encrypted secret payload (or a reference to it)
|
|
125
|
+
// - the commitment (e.g., Merkle root)
|
|
126
|
+
// - the opening proof for verification
|
|
127
|
+
//
|
|
128
|
+
// The exact structure is defined by the share algorithm indicated in
|
|
129
|
+
// `shareAlgorithm`.
|
|
130
|
+
//
|
|
131
|
+
// # Security Considerations
|
|
132
|
+
//
|
|
133
|
+
// - The share MUST only be returned over an authenticated and encrypted
|
|
134
|
+
// DeRec channel
|
|
135
|
+
// - Incorrect or malicious shares may be detected by the Owner during
|
|
136
|
+
// recovery using commitment verification
|
|
137
|
+
//
|
|
138
|
+
// # Idempotency
|
|
139
|
+
//
|
|
140
|
+
// For a given (secretId, version), repeated responses SHOULD return
|
|
141
|
+
// the same share data.
|
|
142
|
+
message GetShareResponseMessage {
|
|
143
|
+
|
|
144
|
+
// Result of processing the request.
|
|
145
|
+
//
|
|
146
|
+
// Indicates whether the share was successfully retrieved or if an error
|
|
147
|
+
// occurred (e.g., unauthorized request, unknown secretId, or missing version).
|
|
148
|
+
DeRecResult result = 1;
|
|
149
|
+
|
|
150
|
+
// The committed DeRec share.
|
|
151
|
+
//
|
|
152
|
+
// This is an opaque byte array containing the share data as produced by
|
|
153
|
+
// the share distribution algorithm. Its internal structure depends on
|
|
154
|
+
// `shareAlgorithm`.
|
|
155
|
+
bytes committedDeRecShare = 2;
|
|
156
|
+
|
|
157
|
+
// Identifier of the share algorithm used to produce the share.
|
|
158
|
+
//
|
|
159
|
+
// This allows the recipient to interpret and process the share correctly
|
|
160
|
+
// during verification and reconstruction.
|
|
161
|
+
int32 shareAlgorithm = 3;
|
|
162
|
+
|
|
163
|
+
// Timestamp indicating when this message was created.
|
|
164
|
+
//
|
|
165
|
+
// This value is expressed in UTC and can be used for observability,
|
|
166
|
+
// replay detection, and timeout handling.
|
|
167
|
+
google.protobuf.Timestamp timestamp = 4;
|
|
168
|
+
|
|
169
|
+
// Identifier of the secret to which this response refers.
|
|
170
|
+
//
|
|
171
|
+
// Echoed from the corresponding GetShareRequestMessage so the Owner can
|
|
172
|
+
// correlate responses with the correct pending recovery without inspecting
|
|
173
|
+
// the share bytes. Required when the Owner has multiple recoveries in
|
|
174
|
+
// progress concurrently, or to defend against stale responses from a
|
|
175
|
+
// previously-abandoned recovery attempt.
|
|
176
|
+
uint64 secretId = 5;
|
|
177
|
+
|
|
178
|
+
// Version of the share being returned.
|
|
179
|
+
//
|
|
180
|
+
// Echoed from the corresponding GetShareRequestMessage for the same
|
|
181
|
+
// correlation reasons as `secretId`.
|
|
182
|
+
uint32 version = 6;
|
|
183
|
+
|
|
184
|
+
// Identity of the replica-group member this message concerns.
|
|
185
|
+
//
|
|
186
|
+
// Present **only** on the replica path, where a member drives catch-up
|
|
187
|
+
// against another member. Absent on the owner ↔ helper path, which is
|
|
188
|
+
// unchanged.
|
|
189
|
+
//
|
|
190
|
+
// Every member of a group is addressed on one shared `channel_id`, so the
|
|
191
|
+
// channel cannot name the peer — this field does. Its presence is also what
|
|
192
|
+
// tells the receiver which path a message belongs to.
|
|
193
|
+
optional uint64 replicaId = 7;
|
|
194
|
+
}
|