@derec-alliance/react-native 0.0.9 → 0.0.10
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 +20 -7
- package/android/src/main/jniLibs/arm64-v8a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/x86_64/libderec_library.a +0 -0
- package/cpp/Primitives.cpp +13 -7
- package/cpp/ProtocolHost.cpp +4 -5
- package/cpp/StoreCallbacks.cpp +31 -43
- package/cpp/derec_ffi.h +44 -33
- package/ios/DeRecFFI.xcframework/Info.plist +5 -5
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +44 -33
- package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +44 -33
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/errors.d.ts +1 -1
- package/lib/errors.js +3 -0
- package/lib/messages.js +5 -3
- package/lib/primitives.d.ts +1 -1
- package/lib/primitives.js +4 -2
- package/lib/protocol.d.ts +9 -5
- package/lib/protocol.js +9 -5
- package/lib/types.d.ts +48 -20
- package/lib/types.js +4 -1
- package/package.json +4 -17
- package/schema/derec_descriptor.bin +0 -0
- package/schema/proto/committedderecshare.proto +93 -0
- package/schema/proto/communicationinfo.proto +104 -0
- package/schema/proto/contact.proto +258 -0
- package/schema/proto/derecmessage.proto +232 -0
- package/schema/proto/derecsecret.proto +163 -0
- package/schema/proto/derectransport.proto +38 -0
- package/schema/proto/error.proto +68 -0
- package/schema/proto/getshare.proto +184 -0
- package/schema/proto/pair.proto +284 -0
- package/schema/proto/parameterrange.proto +36 -0
- package/schema/proto/prepair.proto +163 -0
- package/schema/proto/result.proto +194 -0
- package/schema/proto/secretidsversions.proto +199 -0
- package/schema/proto/storeshare.proto +242 -0
- package/schema/proto/transportprotocol.proto +112 -0
- package/schema/proto/unpair.proto +132 -0
- package/schema/proto/updatechannelinfo.proto +100 -0
- package/schema/proto/verify.proto +160 -0
- package/src/errors.ts +3 -0
- package/src/messages.ts +5 -3
- package/src/primitives.ts +6 -2
- package/src/protocol.ts +10 -6
- package/src/types.ts +49 -23
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
// CommunicationInfoKeyValue represents a single application-defined
|
|
11
|
+
// key-value pair used to convey user-facing identification data.
|
|
12
|
+
//
|
|
13
|
+
// # Purpose
|
|
14
|
+
//
|
|
15
|
+
// This structure is intended for:
|
|
16
|
+
//
|
|
17
|
+
// - displaying human-readable information to users during pairing
|
|
18
|
+
// - helping users identify and confirm counterparties
|
|
19
|
+
// - providing contextual metadata for UI/UX purposes
|
|
20
|
+
//
|
|
21
|
+
// # Semantics
|
|
22
|
+
//
|
|
23
|
+
// - The `key` is an application-defined identifier (e.g., "name", "phone")
|
|
24
|
+
// - The `value` contains the associated data, either as a string or raw bytes
|
|
25
|
+
//
|
|
26
|
+
// The protocol does not interpret these fields; they are opaque to the
|
|
27
|
+
// DeRec protocol and are only intended for application-level use.
|
|
28
|
+
//
|
|
29
|
+
// # Encoding
|
|
30
|
+
//
|
|
31
|
+
// Exactly one of the `value` fields MUST be set.
|
|
32
|
+
//
|
|
33
|
+
// Implementations SHOULD:
|
|
34
|
+
//
|
|
35
|
+
// - prefer `stringValue` for human-readable data
|
|
36
|
+
// - use `bytesValue` for structured or binary data (e.g., encoded identifiers)
|
|
37
|
+
//
|
|
38
|
+
// # Interoperability
|
|
39
|
+
//
|
|
40
|
+
// Applications SHOULD use consistent and well-known keys where possible
|
|
41
|
+
// (e.g., "name", "email", "phone") to improve cross-implementation UX,
|
|
42
|
+
// but no global registry is enforced by the protocol.
|
|
43
|
+
message CommunicationInfoKeyValue {
|
|
44
|
+
// Application-defined key identifying the type of information.
|
|
45
|
+
//
|
|
46
|
+
// Examples include "name", "email", "phone", or "accountId".
|
|
47
|
+
string key = 1;
|
|
48
|
+
|
|
49
|
+
// Value associated with the key.
|
|
50
|
+
//
|
|
51
|
+
// Exactly one of the following fields MUST be set.
|
|
52
|
+
oneof value {
|
|
53
|
+
// Human-readable string value.
|
|
54
|
+
//
|
|
55
|
+
// This is the preferred representation for most user-facing data.
|
|
56
|
+
string stringValue = 2;
|
|
57
|
+
|
|
58
|
+
// Binary value.
|
|
59
|
+
//
|
|
60
|
+
// May be used for structured or encoded data that is not naturally
|
|
61
|
+
// represented as a string.
|
|
62
|
+
bytes bytesValue = 3;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// CommunicationInfo contains application-level identifying information
|
|
67
|
+
// about a participant (Owner or Helper).
|
|
68
|
+
//
|
|
69
|
+
// # Purpose
|
|
70
|
+
//
|
|
71
|
+
// This message is used to:
|
|
72
|
+
//
|
|
73
|
+
// - present identifying details to users during pairing
|
|
74
|
+
// - assist users in verifying the identity of the counterparty
|
|
75
|
+
// - provide contextual metadata for UI display
|
|
76
|
+
//
|
|
77
|
+
// # Semantics
|
|
78
|
+
//
|
|
79
|
+
// - The contents are entirely application-defined
|
|
80
|
+
// - The protocol does not validate, interpret, or enforce any schema
|
|
81
|
+
// - Entries are independent key-value pairs
|
|
82
|
+
//
|
|
83
|
+
// # Security Considerations
|
|
84
|
+
//
|
|
85
|
+
// - This data MUST NOT be relied upon for authentication
|
|
86
|
+
// - Authentication is handled outside the protocol (e.g., in-person,
|
|
87
|
+
// KYC, or application-specific mechanisms)
|
|
88
|
+
//
|
|
89
|
+
// # Privacy Considerations
|
|
90
|
+
//
|
|
91
|
+
// - Applications SHOULD avoid including sensitive information unless
|
|
92
|
+
// necessary for the user experience
|
|
93
|
+
// - Users should be informed about what data is being shared
|
|
94
|
+
//
|
|
95
|
+
// # Interoperability
|
|
96
|
+
//
|
|
97
|
+
// While no schema is enforced, using common keys improves usability
|
|
98
|
+
// across implementations.
|
|
99
|
+
message CommunicationInfo {
|
|
100
|
+
// List of key-value entries describing the participant.
|
|
101
|
+
//
|
|
102
|
+
// Each entry represents one piece of identifying information.
|
|
103
|
+
repeated CommunicationInfoKeyValue communicationInfoEntries = 1;
|
|
104
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
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 "transportprotocol.proto";
|
|
10
|
+
|
|
11
|
+
package org.derecalliance.derec.protobuf;
|
|
12
|
+
|
|
13
|
+
// ContactMessage is the only DeRec protocol message that is not wrapped
|
|
14
|
+
// inside a DeRecMessage.
|
|
15
|
+
//
|
|
16
|
+
// This message is exchanged out-of-band before pairing begins. It provides
|
|
17
|
+
// the minimum information required for another party to initiate contact and
|
|
18
|
+
// send the first protocol message for a new pairing session.
|
|
19
|
+
//
|
|
20
|
+
// Unlike normal DeRec protocol messages, a ContactMessage:
|
|
21
|
+
//
|
|
22
|
+
// - is not wrapped in a DeRecMessage
|
|
23
|
+
// - is not signed
|
|
24
|
+
// - is not encrypted
|
|
25
|
+
// - is not delivered through an already-established DeRec channel
|
|
26
|
+
//
|
|
27
|
+
// Because it is exchanged before any secure channel exists, this message
|
|
28
|
+
// should only contain bootstrap information needed to establish that channel.
|
|
29
|
+
// It is typically transferred through a trusted or user-mediated mechanism.
|
|
30
|
+
//
|
|
31
|
+
// Typical exchange mechanisms include:
|
|
32
|
+
//
|
|
33
|
+
// - QR codes displayed by either the Owner or Helper and scanned by the other
|
|
34
|
+
// party
|
|
35
|
+
// - distribution inside an application controlled by one of the parties
|
|
36
|
+
// - transmission over an already-existing communication channel when the
|
|
37
|
+
// parties have a prior relationship
|
|
38
|
+
//
|
|
39
|
+
// The recipient of this message uses its contents to construct and send the
|
|
40
|
+
// initial pairing request. In particular, the ContactMessage conveys:
|
|
41
|
+
//
|
|
42
|
+
// - the public encryption key material needed to protect the first inbound
|
|
43
|
+
// pairing message
|
|
44
|
+
// - a channel identifier that the recipient must echo in subsequent protocol
|
|
45
|
+
// messages sent to this contact
|
|
46
|
+
// - a nonce that binds the pairing attempt to the out-of-band contact exchange
|
|
47
|
+
// - the transport information required to deliver the pairing request
|
|
48
|
+
//
|
|
49
|
+
// The nonce may be transmitted together with the rest of the message or
|
|
50
|
+
// delivered separately by the application, depending on the authentication
|
|
51
|
+
// and pairing UX.
|
|
52
|
+
//
|
|
53
|
+
// # Modes
|
|
54
|
+
//
|
|
55
|
+
// `ContactMessage` supports three delivery modes for the public encryption
|
|
56
|
+
// material, selected by `contactMode`:
|
|
57
|
+
//
|
|
58
|
+
// - `INLINE_KEYS` (default): both `mlkemEncapsulationKey` and
|
|
59
|
+
// `eciesPublicKey` are present in the contact. The recipient may proceed
|
|
60
|
+
// directly to `PairRequestMessage`. This is the original, wire-equivalent
|
|
61
|
+
// behavior — existing contacts (which have no `contactMode` set) are
|
|
62
|
+
// parsed as `INLINE_KEYS` by virtue of the proto3 default.
|
|
63
|
+
//
|
|
64
|
+
// - `HASHED_KEYS`: `contactBindingHash` is present and both
|
|
65
|
+
// key fields are absent. The contact is small enough to fit in a QR code
|
|
66
|
+
// or short URL. The recipient must first exchange a `PrePairRequest` /
|
|
67
|
+
// `PrePairResponse` pair to obtain the actual keys, then verify them
|
|
68
|
+
// against the hash before sending `PairRequestMessage`. The hash binding
|
|
69
|
+
// gives the OOB-shared contact the same MITM resistance as inline-keys
|
|
70
|
+
// mode despite the keys traveling over the (unauthenticated) transport.
|
|
71
|
+
// Because the `PrePair*` messages are plaintext, the `supportedTransports`
|
|
72
|
+
// carried in this mode MUST be ephemeral — see the security note on
|
|
73
|
+
// `PrePairRequestMessage` for the required ephemeral-then-swap discipline.
|
|
74
|
+
//
|
|
75
|
+
// - `NO_KEYS`: all of `mlkemEncapsulationKey`, `eciesPublicKey`, and
|
|
76
|
+
// `contactBindingHash` are absent. The contact carries only
|
|
77
|
+
// `channelId`, `nonce`, and `supportedTransports` — small enough to be
|
|
78
|
+
// hand-typed or dictated over the phone. There is no cryptographic
|
|
79
|
+
// binding: the recipient's `PrePairRequest` triggers on-the-fly key
|
|
80
|
+
// generation on the contact creator, and the returned keys are used
|
|
81
|
+
// without hash verification. The security model rests **entirely** on
|
|
82
|
+
// the out-of-band delivery channel being fully trusted (e.g. a
|
|
83
|
+
// verified email from an already-KYC-authenticated institution). The
|
|
84
|
+
// `nonce` correlates the incoming request to the intended user; because
|
|
85
|
+
// the nonce is intentionally small for human typability, applications
|
|
86
|
+
// MUST rate-limit incoming `PrePairRequest`s per `channelId` and expire
|
|
87
|
+
// outstanding NoKeys contacts on a short timer. Not appropriate for
|
|
88
|
+
// peer-to-peer pairing over untrusted channels — use `HASHED_KEYS` or
|
|
89
|
+
// `INLINE_KEYS` there.
|
|
90
|
+
//
|
|
91
|
+
// Because nothing binds the published keys to the contact, a `NO_KEYS`
|
|
92
|
+
// channel MUST NOT be used until the pair is confirmed out of band. An
|
|
93
|
+
// implementation MUST hold it unusable — no secrets sent, inbound
|
|
94
|
+
// messages ignored — until both sides compare the human-readable
|
|
95
|
+
// fingerprint derived from the established channel key and it matches. A
|
|
96
|
+
// man-in-the-middle on the `PrePair` leg yields two different channel
|
|
97
|
+
// keys and therefore two different fingerprints, so this comparison is
|
|
98
|
+
// what `HASHED_KEYS` gets from its `contactBindingHash` and `NO_KEYS`
|
|
99
|
+
// can get no other way. This is a requirement of the mode, not a
|
|
100
|
+
// deployment choice. The creator's `fingerprintCommitment` is what keeps
|
|
101
|
+
// the man-in-the-middle from searching offline for a key pair whose two
|
|
102
|
+
// fingerprints agree.
|
|
103
|
+
//
|
|
104
|
+
// The mode selector and the per-mode field-presence invariants are enforced
|
|
105
|
+
// by the implementation; mixing fields across modes is a protocol error.
|
|
106
|
+
|
|
107
|
+
// Selects the delivery mode for the public encryption material in
|
|
108
|
+
// `ContactMessage`. See `ContactMessage` for details.
|
|
109
|
+
enum ContactMode {
|
|
110
|
+
// Default. `mlkemEncapsulationKey` and `eciesPublicKey` are inlined
|
|
111
|
+
// in the contact.
|
|
112
|
+
INLINE_KEYS = 0;
|
|
113
|
+
// `contactBindingHash` is inlined in the contact; keys are obtained via
|
|
114
|
+
// `PrePairRequest` / `PrePairResponse` and verified against the hash.
|
|
115
|
+
HASHED_KEYS = 1;
|
|
116
|
+
// No key material and no hash are inlined. The contact carries only
|
|
117
|
+
// `channelId`, `nonce`, and `supportedTransports`; the contact creator
|
|
118
|
+
// generates key material on the fly when the corresponding
|
|
119
|
+
// `PrePairRequest` arrives. Only appropriate when the out-of-band
|
|
120
|
+
// delivery channel is fully trusted, and the channel stays unusable
|
|
121
|
+
// until both sides confirm the fingerprint out of band — nothing else
|
|
122
|
+
// binds the published keys to the contact.
|
|
123
|
+
NO_KEYS = 2;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
message ContactMessage {
|
|
127
|
+
|
|
128
|
+
// Selects how the public encryption material is delivered. Defaults to
|
|
129
|
+
// `INLINE_KEYS` (current behavior) when unset.
|
|
130
|
+
ContactMode contactMode = 1;
|
|
131
|
+
|
|
132
|
+
// Serialized ML-KEM-1024 encapsulation key.
|
|
133
|
+
//
|
|
134
|
+
// Present only when `contactMode == INLINE_KEYS`. Used by
|
|
135
|
+
// the recipient to construct the initial pairing message.
|
|
136
|
+
optional bytes mlkemEncapsulationKey = 2;
|
|
137
|
+
|
|
138
|
+
// Serialized ECIES public key.
|
|
139
|
+
//
|
|
140
|
+
// Present only when `contactMode == INLINE_KEYS`. Used by
|
|
141
|
+
// the recipient to construct the initial pairing message.
|
|
142
|
+
optional bytes eciesPublicKey = 3;
|
|
143
|
+
|
|
144
|
+
// SHA-384 commitment to the public encryption material.
|
|
145
|
+
//
|
|
146
|
+
// Present only when `contactMode == HASHED_KEYS`. Computed
|
|
147
|
+
// as:
|
|
148
|
+
//
|
|
149
|
+
// ```text
|
|
150
|
+
// SHA-384(
|
|
151
|
+
// mlkemEncapsulationKey
|
|
152
|
+
// || eciesPublicKey
|
|
153
|
+
// || u64_be(nonce)
|
|
154
|
+
// || u64_be(channelId)
|
|
155
|
+
// )
|
|
156
|
+
// ```
|
|
157
|
+
//
|
|
158
|
+
// The recipient obtains the actual keys via `PrePairRequest` and
|
|
159
|
+
// recomputes this hash to confirm integrity before proceeding to
|
|
160
|
+
// `PairRequestMessage`.
|
|
161
|
+
optional bytes contactBindingHash = 4;
|
|
162
|
+
|
|
163
|
+
// Channel identifier associated with this contact.
|
|
164
|
+
//
|
|
165
|
+
// This value identifies the communication channel that the creator of this
|
|
166
|
+
// ContactMessage expects to use for the new pairing. After receiving this
|
|
167
|
+
// contact, the initiating party includes this channelId in subsequent
|
|
168
|
+
// protocol messages sent to the contact creator.
|
|
169
|
+
//
|
|
170
|
+
// The recipient uses this identifier to determine which local key material
|
|
171
|
+
// and pairing state should be used when processing the message.
|
|
172
|
+
//
|
|
173
|
+
// If an implementation generates multiple pending contact records or
|
|
174
|
+
// multiple encryption key pairs for different pairing attempts, it should
|
|
175
|
+
// retain the mapping from channelId to the corresponding local state so it
|
|
176
|
+
// can process inbound messages without trial decryption across all keys.
|
|
177
|
+
//
|
|
178
|
+
// This value MUST be unique within the scope required by the implementation
|
|
179
|
+
// to disambiguate concurrent or stored pairing sessions.
|
|
180
|
+
uint64 channelId = 5;
|
|
181
|
+
|
|
182
|
+
// Random nonce used to bind the pairing request to this contact exchange.
|
|
183
|
+
//
|
|
184
|
+
// The initiator includes this value in the pairing request so the creator
|
|
185
|
+
// of the ContactMessage can confirm that the request corresponds to the
|
|
186
|
+
// same out-of-band contact information that was just shared.
|
|
187
|
+
//
|
|
188
|
+
// This helps the application detect mismatched, stale, or spoofed pairing
|
|
189
|
+
// attempts during the bootstrap phase.
|
|
190
|
+
//
|
|
191
|
+
// Applications may choose to reveal this nonce only after sufficient
|
|
192
|
+
// out-of-band authentication has taken place.
|
|
193
|
+
uint64 nonce = 6;
|
|
194
|
+
|
|
195
|
+
// Formerly the singular `transportProtocol`, superseded by `supportedTransports`.
|
|
196
|
+
reserved 7;
|
|
197
|
+
reserved "transportProtocol";
|
|
198
|
+
|
|
199
|
+
// Timestamp indicating when the sender created this message.
|
|
200
|
+
//
|
|
201
|
+
// This value is expressed in UTC and can be used for:
|
|
202
|
+
//
|
|
203
|
+
// - replay detection
|
|
204
|
+
// - timeout handling
|
|
205
|
+
// - logging and observability
|
|
206
|
+
google.protobuf.Timestamp timestamp = 8;
|
|
207
|
+
|
|
208
|
+
// Every transport endpoint the creator of this contact can be reached on.
|
|
209
|
+
//
|
|
210
|
+
// Each entry is a complete endpoint: a URI plus the protocol that says
|
|
211
|
+
// how to interpret it. The list is written in the creator's own
|
|
212
|
+
// preference order.
|
|
213
|
+
//
|
|
214
|
+
// # Selection is the recipient's
|
|
215
|
+
//
|
|
216
|
+
// A recipient picks whichever entry suits it, ordered by its **own**
|
|
217
|
+
// preference rather than the sender's. The order here expresses
|
|
218
|
+
// availability, not a ranking the recipient must honor.
|
|
219
|
+
//
|
|
220
|
+
// A contact MUST carry at least one entry: it is the only way the
|
|
221
|
+
// recipient learns where to send its first message.
|
|
222
|
+
//
|
|
223
|
+
// # Security
|
|
224
|
+
//
|
|
225
|
+
// `contactBindingHash` does not cover this field. An attacker able to
|
|
226
|
+
// rewrite an out-of-band contact can therefore remove entries. Removing
|
|
227
|
+
// the secure ones leaves only plaintext, which the recipient's transport
|
|
228
|
+
// policy refuses unless plaintext has been explicitly opted into. DeRec
|
|
229
|
+
// messages are signed and encrypted at the application layer on every
|
|
230
|
+
// transport, so substituting one secure transport for another is not a
|
|
231
|
+
// loss of confidentiality or authenticity.
|
|
232
|
+
repeated TransportProtocol supportedTransports = 9;
|
|
233
|
+
|
|
234
|
+
// The creator's commitment to the fingerprint nonce it reveals in
|
|
235
|
+
// `PairResponseMessage.fingerprintNonce`:
|
|
236
|
+
//
|
|
237
|
+
// ```text
|
|
238
|
+
// SHA-256("DeRec fingerprint commitment v1"
|
|
239
|
+
// || mlkemEncapsulationKey || eciesPublicKey || fingerprintNonce)
|
|
240
|
+
// ```
|
|
241
|
+
//
|
|
242
|
+
// Present, exactly 32 bytes, in `INLINE_KEYS` mode only. In
|
|
243
|
+
// `HASHED_KEYS` and `NO_KEYS` mode the commitment travels with the keys,
|
|
244
|
+
// in `PrePairResponseMessage.fingerprintCommitment`, and this field MUST
|
|
245
|
+
// be absent.
|
|
246
|
+
//
|
|
247
|
+
// # Why the creator commits
|
|
248
|
+
//
|
|
249
|
+
// The responder picks every random input of the handshake key after it
|
|
250
|
+
// has seen the creator's keys. Without a commitment, whoever answers the
|
|
251
|
+
// creator's keys can try handshake contributions offline until one
|
|
252
|
+
// yields the fingerprint it needs, and send only that one. The creator
|
|
253
|
+
// therefore fixes a random nonce before the responder contributes, and
|
|
254
|
+
// reveals it only after the responder's `PairRequestMessage` has fixed
|
|
255
|
+
// the handshake key. The channel key, and so the fingerprint, depends on
|
|
256
|
+
// both, so no contribution can be chosen to match a target fingerprint.
|
|
257
|
+
optional bytes fingerprintCommitment = 10;
|
|
258
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
// - a per-channel sequence number for ordering and duplicate detection
|
|
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
|
+
// Request/response pairing is defined per message type: each request
|
|
58
|
+
// message has a corresponding response message, and the response envelope
|
|
59
|
+
// echoes the request's `traceId`. Most flows are initiated by the Owner;
|
|
60
|
+
// some, such as UpdateChannelInfo, may be initiated by either party.
|
|
61
|
+
//
|
|
62
|
+
// Delivery of every message, responses included, follows the transport,
|
|
63
|
+
// which is push: a response is a separate delivery to the requester's own
|
|
64
|
+
// endpoint, not a return value on the delivery that carried the request.
|
|
65
|
+
//
|
|
66
|
+
// The `sequence` field is intended to:
|
|
67
|
+
//
|
|
68
|
+
// - enforce message ordering
|
|
69
|
+
// - detect duplicates or out-of-order delivery
|
|
70
|
+
// - support replay protection
|
|
71
|
+
//
|
|
72
|
+
// These semantics are not yet implemented by this library: a sender may set
|
|
73
|
+
// `sequence`, but it is not checked on receipt. Replay protection currently
|
|
74
|
+
// relies on `timestamp`: an envelope older than the receiver's configured
|
|
75
|
+
// inbound-message window is discarded. After decryption the receiver also
|
|
76
|
+
// checks that `envelope.timestamp` equals the inner message's `timestamp`, and
|
|
77
|
+
// discards the message if they differ or either is absent.
|
|
78
|
+
//
|
|
79
|
+
// Implementations SHOULD treat messages as idempotent and be resilient to
|
|
80
|
+
// retries and duplicate deliveries.
|
|
81
|
+
//
|
|
82
|
+
// # Key Rotation
|
|
83
|
+
//
|
|
84
|
+
// The sequence number is intended as a trigger for automatic key rotation:
|
|
85
|
+
// when a configured threshold is reached, implementations MAY initiate a key
|
|
86
|
+
// rotation flow to maintain forward secrecy. This library does not implement
|
|
87
|
+
// sequence-triggered key rotation.
|
|
88
|
+
//
|
|
89
|
+
// # Versioning
|
|
90
|
+
//
|
|
91
|
+
// The protocolVersionMajor and protocolVersionMinor fields allow peers to:
|
|
92
|
+
//
|
|
93
|
+
// - detect incompatible protocol versions
|
|
94
|
+
// - apply backward-compatible parsing logic when possible
|
|
95
|
+
//
|
|
96
|
+
// Implementations MUST define behavior for handling version mismatches.
|
|
97
|
+
//
|
|
98
|
+
// # Payload Encoding
|
|
99
|
+
//
|
|
100
|
+
// The `message` field contains encrypted raw bytes. When decrypted, these bytes
|
|
101
|
+
// MUST deserialize into a MessageBody, which contains exactly one concrete
|
|
102
|
+
// protocol message.
|
|
103
|
+
//
|
|
104
|
+
// The oneof structure ensures that each DeRecMessage carries a single logical
|
|
105
|
+
// operation.
|
|
106
|
+
message DeRecMessage {
|
|
107
|
+
// DeRec protocol major version.
|
|
108
|
+
//
|
|
109
|
+
// Incremented for breaking changes that are not backward compatible.
|
|
110
|
+
uint32 protocolVersionMajor = 1;
|
|
111
|
+
|
|
112
|
+
// DeRec protocol minor version.
|
|
113
|
+
//
|
|
114
|
+
// Incremented for backward-compatible changes such as adding new fields
|
|
115
|
+
// or message types.
|
|
116
|
+
uint32 protocolVersionMinor = 2;
|
|
117
|
+
|
|
118
|
+
// Monotonically increasing message sequence number.
|
|
119
|
+
//
|
|
120
|
+
// This value is intended to increment by 1 for each message sent on a
|
|
121
|
+
// given channel, and to be used to:
|
|
122
|
+
//
|
|
123
|
+
// - enforce ordering
|
|
124
|
+
// - detect duplicates or missing messages
|
|
125
|
+
// - support replay protection
|
|
126
|
+
//
|
|
127
|
+
// Implementations MAY also use this value to trigger automatic key rotation
|
|
128
|
+
// once a predefined threshold is reached.
|
|
129
|
+
//
|
|
130
|
+
// Not yet implemented by this library: a sender may set this field, but it
|
|
131
|
+
// is not checked on receipt, and it does not trigger key rotation. Replay
|
|
132
|
+
// protection currently relies on `timestamp`.
|
|
133
|
+
uint32 sequence = 3;
|
|
134
|
+
|
|
135
|
+
// Channel identifier associated with this communication session.
|
|
136
|
+
//
|
|
137
|
+
// This value uniquely identifies the logical channel between an Owner and
|
|
138
|
+
// a Helper for a given secret. It is established during pairing and used
|
|
139
|
+
// thereafter to:
|
|
140
|
+
//
|
|
141
|
+
// - route messages to the correct channel state
|
|
142
|
+
// - select the appropriate cryptographic keys
|
|
143
|
+
//
|
|
144
|
+
// This MUST match the channelId exchanged during the ContactMessage phase.
|
|
145
|
+
uint64 channelId = 4;
|
|
146
|
+
|
|
147
|
+
// Timestamp indicating when the sender created this message.
|
|
148
|
+
//
|
|
149
|
+
// The sender sets this to the same value as the inner message's
|
|
150
|
+
// `timestamp`; the receiver discards a message whose two timestamps differ.
|
|
151
|
+
//
|
|
152
|
+
// This value is expressed in UTC and can be used for:
|
|
153
|
+
//
|
|
154
|
+
// - replay detection
|
|
155
|
+
// - timeout handling
|
|
156
|
+
// - logging and observability
|
|
157
|
+
//
|
|
158
|
+
// Implementations SHOULD NOT rely solely on this value for security-critical
|
|
159
|
+
// decisions without additional protections.
|
|
160
|
+
google.protobuf.Timestamp timestamp = 5;
|
|
161
|
+
|
|
162
|
+
// Encrypted message payload.
|
|
163
|
+
//
|
|
164
|
+
// This field contains the encrypted bytes of a serialized MessageBody.
|
|
165
|
+
// The encryption scheme and key material are defined by the pairing process
|
|
166
|
+
// and subsequent key management flows.
|
|
167
|
+
//
|
|
168
|
+
// Upon decryption, this field MUST deserialize into a valid MessageBody
|
|
169
|
+
// containing exactly one protocol message.
|
|
170
|
+
bytes message = 6;
|
|
171
|
+
|
|
172
|
+
// Application-supplied correlation token, echoed verbatim by the
|
|
173
|
+
// responder on the matching response envelope.
|
|
174
|
+
//
|
|
175
|
+
// # Purpose
|
|
176
|
+
//
|
|
177
|
+
// Lets the side that originated a request match the eventual response to
|
|
178
|
+
// the in-flight request that produced it, even when:
|
|
179
|
+
//
|
|
180
|
+
// - multiple requests are outstanding on the same channel,
|
|
181
|
+
// - responses arrive out of order with respect to send order,
|
|
182
|
+
// - the responder takes arbitrary time to reply.
|
|
183
|
+
//
|
|
184
|
+
// # Semantics
|
|
185
|
+
//
|
|
186
|
+
// - On a request envelope: the requester sets this to any value it can
|
|
187
|
+
// use to correlate the response back to the originating call site. A
|
|
188
|
+
// random `uint64` is a typical choice; collisions are unlikely at any
|
|
189
|
+
// realistic concurrency level.
|
|
190
|
+
// - On a response envelope: the responder MUST copy the request's
|
|
191
|
+
// `traceId` verbatim. The library does this automatically in every
|
|
192
|
+
// response producer.
|
|
193
|
+
// - Zero (the protobuf default when unset) is treated as "no correlation
|
|
194
|
+
// requested." Responders still echo the zero on the response envelope;
|
|
195
|
+
// requesters that do not care about correlation simply ignore the
|
|
196
|
+
// field.
|
|
197
|
+
//
|
|
198
|
+
// # Privacy
|
|
199
|
+
//
|
|
200
|
+
// This field is plaintext on the wire (the envelope is not encrypted).
|
|
201
|
+
// The token itself is opaque, so it carries no information about either
|
|
202
|
+
// peer's identity or intent — it is purely a correlation handle. Passive
|
|
203
|
+
// observers could already correlate request/response pairs by channelId
|
|
204
|
+
// and timing; `traceId` does not add to that exposure.
|
|
205
|
+
uint64 traceId = 7;
|
|
206
|
+
|
|
207
|
+
// MessageBody defines all possible DeRec protocol messages that can be
|
|
208
|
+
// transported inside the DeRecMessage envelope.
|
|
209
|
+
//
|
|
210
|
+
// Exactly one of the fields MUST be set when constructing a message.
|
|
211
|
+
message MessageBody {
|
|
212
|
+
oneof body {
|
|
213
|
+
PairRequestMessage pairRequestMessage = 1;
|
|
214
|
+
PairResponseMessage pairResponseMessage = 2;
|
|
215
|
+
UnpairRequestMessage unpairRequestMessage = 3;
|
|
216
|
+
UnpairResponseMessage unpairResponseMessage = 4;
|
|
217
|
+
StoreShareRequestMessage storeShareRequestMessage = 5;
|
|
218
|
+
StoreShareResponseMessage storeShareResponseMessage = 6;
|
|
219
|
+
VerifyShareRequestMessage verifyShareRequestMessage = 7;
|
|
220
|
+
VerifyShareResponseMessage verifyShareResponseMessage = 8;
|
|
221
|
+
GetSecretIdsVersionsRequestMessage getSecretIdsVersionsRequestMessage = 9;
|
|
222
|
+
GetSecretIdsVersionsResponseMessage getSecretIdsVersionsResponseMessage = 10;
|
|
223
|
+
GetShareRequestMessage getShareRequestMessage = 11;
|
|
224
|
+
GetShareResponseMessage getShareResponseMessage = 12;
|
|
225
|
+
ErrorResponseMessage errorResponseMessage = 13;
|
|
226
|
+
UpdateChannelInfoRequestMessage updateChannelInfoRequestMessage = 14;
|
|
227
|
+
UpdateChannelInfoResponseMessage updateChannelInfoResponseMessage = 15;
|
|
228
|
+
PrePairRequestMessage prePairRequestMessage = 16;
|
|
229
|
+
PrePairResponseMessage prePairResponseMessage = 17;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|