@derec-alliance/react-native 0.0.9 → 0.0.11

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.
Files changed (47) hide show
  1. package/README.md +114 -7
  2. package/android/src/main/jniLibs/arm64-v8a/libderec_library.a +0 -0
  3. package/android/src/main/jniLibs/armeabi-v7a/libderec_library.a +0 -0
  4. package/android/src/main/jniLibs/x86_64/libderec_library.a +0 -0
  5. package/cpp/Primitives.cpp +38 -9
  6. package/cpp/Primitives.h +5 -3
  7. package/cpp/ProtocolHost.cpp +4 -5
  8. package/cpp/StoreCallbacks.cpp +31 -43
  9. package/cpp/derec_ffi.h +98 -33
  10. package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +98 -33
  11. package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
  12. package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +98 -33
  13. package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
  14. package/lib/errors.d.ts +8 -3
  15. package/lib/errors.js +6 -0
  16. package/lib/messages.js +5 -3
  17. package/lib/primitives.d.ts +12 -2
  18. package/lib/primitives.js +17 -2
  19. package/lib/protocol.d.ts +9 -5
  20. package/lib/protocol.js +9 -5
  21. package/lib/types.d.ts +194 -46
  22. package/lib/types.js +4 -1
  23. package/package.json +4 -17
  24. package/schema/derec_descriptor.bin +0 -0
  25. package/schema/proto/committedderecshare.proto +93 -0
  26. package/schema/proto/communicationinfo.proto +104 -0
  27. package/schema/proto/contact.proto +266 -0
  28. package/schema/proto/derecmessage.proto +248 -0
  29. package/schema/proto/derecsecret.proto +163 -0
  30. package/schema/proto/derectransport.proto +38 -0
  31. package/schema/proto/error.proto +68 -0
  32. package/schema/proto/getshare.proto +184 -0
  33. package/schema/proto/pair.proto +284 -0
  34. package/schema/proto/parameterrange.proto +36 -0
  35. package/schema/proto/prepair.proto +164 -0
  36. package/schema/proto/result.proto +194 -0
  37. package/schema/proto/secretidsversions.proto +199 -0
  38. package/schema/proto/storeshare.proto +242 -0
  39. package/schema/proto/transportprotocol.proto +112 -0
  40. package/schema/proto/unpair.proto +132 -0
  41. package/schema/proto/updatechannelinfo.proto +100 -0
  42. package/schema/proto/verify.proto +160 -0
  43. package/src/errors.ts +12 -1
  44. package/src/messages.ts +5 -3
  45. package/src/primitives.ts +23 -2
  46. package/src/protocol.ts +10 -6
  47. package/src/types.ts +185 -43
@@ -0,0 +1,266 @@
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 keys are concatenated without their lengths, so the hash binds
159
+ // them only because each has a fixed size: 1568 bytes for the ML-KEM-1024
160
+ // encapsulation key and 65 bytes for the uncompressed secp256k1 point.
161
+ // Keys of any other size MUST be refused rather than hashed.
162
+ //
163
+ // The recipient obtains the actual keys via `PrePairRequest` and
164
+ // recomputes this hash to confirm integrity before proceeding to
165
+ // `PairRequestMessage`.
166
+ optional bytes contactBindingHash = 4;
167
+
168
+ // Channel identifier associated with this contact.
169
+ //
170
+ // This value identifies the communication channel that the creator of this
171
+ // ContactMessage expects to use for the new pairing. After receiving this
172
+ // contact, the initiating party includes this channelId in subsequent
173
+ // protocol messages sent to the contact creator.
174
+ //
175
+ // The recipient uses this identifier to determine which local key material
176
+ // and pairing state should be used when processing the message.
177
+ //
178
+ // If an implementation generates multiple pending contact records or
179
+ // multiple encryption key pairs for different pairing attempts, it should
180
+ // retain the mapping from channelId to the corresponding local state so it
181
+ // can process inbound messages without trial decryption across all keys.
182
+ //
183
+ // This value MUST be unique within the scope required by the implementation
184
+ // to disambiguate concurrent or stored pairing sessions.
185
+ uint64 channelId = 5;
186
+
187
+ // Random nonce used to bind the pairing request to this contact exchange.
188
+ //
189
+ // The initiator includes this value in the pairing request so the creator
190
+ // of the ContactMessage can confirm that the request corresponds to the
191
+ // same out-of-band contact information that was just shared.
192
+ //
193
+ // This helps the application detect mismatched, stale, or spoofed pairing
194
+ // attempts during the bootstrap phase.
195
+ //
196
+ // Applications may choose to reveal this nonce only after sufficient
197
+ // out-of-band authentication has taken place.
198
+ uint64 nonce = 6;
199
+
200
+ // Formerly the singular `transportProtocol`, superseded by `supportedTransports`.
201
+ reserved 7;
202
+ reserved "transportProtocol";
203
+
204
+ // Timestamp indicating when the sender created this message.
205
+ //
206
+ // This value is expressed in UTC and can be used for:
207
+ //
208
+ // - replay detection
209
+ // - timeout handling
210
+ // - logging and observability
211
+ google.protobuf.Timestamp timestamp = 8;
212
+
213
+ // Every transport endpoint the creator of this contact can be reached on.
214
+ //
215
+ // Each entry is a complete endpoint: a URI plus the protocol that says
216
+ // how to interpret it. The list is written in the creator's own
217
+ // preference order.
218
+ //
219
+ // # Selection is the recipient's
220
+ //
221
+ // A recipient picks whichever entry suits it, ordered by its **own**
222
+ // preference rather than the sender's. The order here expresses
223
+ // availability, not a ranking the recipient must honor.
224
+ //
225
+ // A contact MUST carry at least one entry: it is the only way the
226
+ // recipient learns where to send its first message.
227
+ //
228
+ // # Security
229
+ //
230
+ // `contactBindingHash` does not cover this field. An attacker able to
231
+ // rewrite an out-of-band contact can therefore remove entries. Removing
232
+ // the secure ones leaves only plaintext, which the recipient's transport
233
+ // policy refuses unless plaintext has been explicitly opted into. DeRec
234
+ // messages are signed and encrypted at the application layer on every
235
+ // transport, so substituting one secure transport for another is not a
236
+ // loss of confidentiality or authenticity.
237
+ repeated TransportProtocol supportedTransports = 9;
238
+
239
+ // The creator's commitment to the fingerprint nonce it reveals in
240
+ // `PairResponseMessage.fingerprintNonce`:
241
+ //
242
+ // ```text
243
+ // SHA-256("DeRec fingerprint commitment v1"
244
+ // || mlkemEncapsulationKey || eciesPublicKey || fingerprintNonce)
245
+ // ```
246
+ //
247
+ // As in `contactBindingHash`, the keys are bound only by their fixed
248
+ // sizes, and keys of any other size MUST be refused.
249
+ //
250
+ // Present, exactly 32 bytes, in `INLINE_KEYS` mode only. In
251
+ // `HASHED_KEYS` and `NO_KEYS` mode the commitment travels with the keys,
252
+ // in `PrePairResponseMessage.fingerprintCommitment`, and this field MUST
253
+ // be absent.
254
+ //
255
+ // # Why the creator commits
256
+ //
257
+ // The responder picks every random input of the handshake key after it
258
+ // has seen the creator's keys. Without a commitment, whoever answers the
259
+ // creator's keys can try handshake contributions offline until one
260
+ // yields the fingerprint it needs, and send only that one. The creator
261
+ // therefore fixes a random nonce before the responder contributes, and
262
+ // reveals it only after the responder's `PairRequestMessage` has fixed
263
+ // the handshake key. The channel key, and so the fingerprint, depends on
264
+ // both, so no contribution can be chosen to match a target fingerprint.
265
+ optional bytes fingerprintCommitment = 10;
266
+ }
@@ -0,0 +1,248 @@
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 implemented by this library: a sender may set
73
+ // `sequence`, but it is not checked on receipt. An envelope older than the
74
+ // receiver's configured inbound-message window is discarded. After
75
+ // decryption the receiver also checks that `envelope.timestamp` equals the
76
+ // inner message's `timestamp`, and discards the message if they differ or
77
+ // either is absent.
78
+ //
79
+ // Within the window, detecting a message delivered more than once is the
80
+ // receiving application's transport layer's job. Both ends of a channel
81
+ // encrypt under one key, so a message delivered back to its own sender
82
+ // decrypts there too. The transport MUST:
83
+ //
84
+ // - identify an envelope by a hash of its `message` field only. `sequence`,
85
+ // `traceId` and the protocol version are not authenticated, and an
86
+ // envelope can be re-encoded, so a copy can arrive as different bytes;
87
+ // - keep the identity of every envelope it accepted and of every envelope
88
+ // it sent until the later of its arrival (or sending) and its `timestamp`,
89
+ // plus the inbound-message window, and drop an inbound envelope whose
90
+ // identity it keeps;
91
+ // - record an inbound identity only once the message was accepted.
92
+ //
93
+ // A message held back and delivered late is a first delivery and is not
94
+ // caught this way. A receiver MUST NOT store a share version older than the
95
+ // newest it stores on the channel, and SHOULD reject a channel-info update
96
+ // older than the last one it accepted on the channel.
97
+ //
98
+ // # Key Rotation
99
+ //
100
+ // The sequence number is intended as a trigger for automatic key rotation:
101
+ // when a configured threshold is reached, implementations MAY initiate a key
102
+ // rotation flow to maintain forward secrecy. This library does not implement
103
+ // sequence-triggered key rotation.
104
+ //
105
+ // # Versioning
106
+ //
107
+ // The protocolVersionMajor and protocolVersionMinor fields allow peers to:
108
+ //
109
+ // - detect incompatible protocol versions
110
+ // - apply backward-compatible parsing logic when possible
111
+ //
112
+ // Implementations MUST define behavior for handling version mismatches.
113
+ //
114
+ // # Payload Encoding
115
+ //
116
+ // The `message` field contains encrypted raw bytes. When decrypted, these bytes
117
+ // MUST deserialize into a MessageBody, which contains exactly one concrete
118
+ // protocol message.
119
+ //
120
+ // The oneof structure ensures that each DeRecMessage carries a single logical
121
+ // operation.
122
+ message DeRecMessage {
123
+ // DeRec protocol major version.
124
+ //
125
+ // Incremented for breaking changes that are not backward compatible.
126
+ uint32 protocolVersionMajor = 1;
127
+
128
+ // DeRec protocol minor version.
129
+ //
130
+ // Incremented for backward-compatible changes such as adding new fields
131
+ // or message types.
132
+ uint32 protocolVersionMinor = 2;
133
+
134
+ // Monotonically increasing message sequence number.
135
+ //
136
+ // This value is intended to increment by 1 for each message sent on a
137
+ // given channel, and to be used to:
138
+ //
139
+ // - enforce ordering
140
+ // - detect duplicates or missing messages
141
+ // - support replay protection
142
+ //
143
+ // Implementations MAY also use this value to trigger automatic key rotation
144
+ // once a predefined threshold is reached.
145
+ //
146
+ // Not yet implemented by this library: a sender may set this field, but it
147
+ // is not checked on receipt, and it does not trigger key rotation. Replay
148
+ // protection currently relies on `timestamp`.
149
+ uint32 sequence = 3;
150
+
151
+ // Channel identifier associated with this communication session.
152
+ //
153
+ // This value uniquely identifies the logical channel between an Owner and
154
+ // a Helper for a given secret. It is established during pairing and used
155
+ // thereafter to:
156
+ //
157
+ // - route messages to the correct channel state
158
+ // - select the appropriate cryptographic keys
159
+ //
160
+ // This MUST match the channelId exchanged during the ContactMessage phase.
161
+ uint64 channelId = 4;
162
+
163
+ // Timestamp indicating when the sender created this message.
164
+ //
165
+ // The sender sets this to the same value as the inner message's
166
+ // `timestamp`; the receiver discards a message whose two timestamps differ.
167
+ //
168
+ // This value is expressed in UTC and can be used for:
169
+ //
170
+ // - replay detection
171
+ // - timeout handling
172
+ // - logging and observability
173
+ //
174
+ // Implementations SHOULD NOT rely solely on this value for security-critical
175
+ // decisions without additional protections.
176
+ google.protobuf.Timestamp timestamp = 5;
177
+
178
+ // Encrypted message payload.
179
+ //
180
+ // This field contains the encrypted bytes of a serialized MessageBody.
181
+ // The encryption scheme and key material are defined by the pairing process
182
+ // and subsequent key management flows.
183
+ //
184
+ // Upon decryption, this field MUST deserialize into a valid MessageBody
185
+ // containing exactly one protocol message.
186
+ bytes message = 6;
187
+
188
+ // Application-supplied correlation token, echoed verbatim by the
189
+ // responder on the matching response envelope.
190
+ //
191
+ // # Purpose
192
+ //
193
+ // Lets the side that originated a request match the eventual response to
194
+ // the in-flight request that produced it, even when:
195
+ //
196
+ // - multiple requests are outstanding on the same channel,
197
+ // - responses arrive out of order with respect to send order,
198
+ // - the responder takes arbitrary time to reply.
199
+ //
200
+ // # Semantics
201
+ //
202
+ // - On a request envelope: the requester sets this to any value it can
203
+ // use to correlate the response back to the originating call site. A
204
+ // random `uint64` is a typical choice; collisions are unlikely at any
205
+ // realistic concurrency level.
206
+ // - On a response envelope: the responder MUST copy the request's
207
+ // `traceId` verbatim. The library does this automatically in every
208
+ // response producer.
209
+ // - Zero (the protobuf default when unset) is treated as "no correlation
210
+ // requested." Responders still echo the zero on the response envelope;
211
+ // requesters that do not care about correlation simply ignore the
212
+ // field.
213
+ //
214
+ // # Privacy
215
+ //
216
+ // This field is plaintext on the wire (the envelope is not encrypted).
217
+ // The token itself is opaque, so it carries no information about either
218
+ // peer's identity or intent — it is purely a correlation handle. Passive
219
+ // observers could already correlate request/response pairs by channelId
220
+ // and timing; `traceId` does not add to that exposure.
221
+ uint64 traceId = 7;
222
+
223
+ // MessageBody defines all possible DeRec protocol messages that can be
224
+ // transported inside the DeRecMessage envelope.
225
+ //
226
+ // Exactly one of the fields MUST be set when constructing a message.
227
+ message MessageBody {
228
+ oneof body {
229
+ PairRequestMessage pairRequestMessage = 1;
230
+ PairResponseMessage pairResponseMessage = 2;
231
+ UnpairRequestMessage unpairRequestMessage = 3;
232
+ UnpairResponseMessage unpairResponseMessage = 4;
233
+ StoreShareRequestMessage storeShareRequestMessage = 5;
234
+ StoreShareResponseMessage storeShareResponseMessage = 6;
235
+ VerifyShareRequestMessage verifyShareRequestMessage = 7;
236
+ VerifyShareResponseMessage verifyShareResponseMessage = 8;
237
+ GetSecretIdsVersionsRequestMessage getSecretIdsVersionsRequestMessage = 9;
238
+ GetSecretIdsVersionsResponseMessage getSecretIdsVersionsResponseMessage = 10;
239
+ GetShareRequestMessage getShareRequestMessage = 11;
240
+ GetShareResponseMessage getShareResponseMessage = 12;
241
+ ErrorResponseMessage errorResponseMessage = 13;
242
+ UpdateChannelInfoRequestMessage updateChannelInfoRequestMessage = 14;
243
+ UpdateChannelInfoResponseMessage updateChannelInfoResponseMessage = 15;
244
+ PrePairRequestMessage prePairRequestMessage = 16;
245
+ PrePairResponseMessage prePairResponseMessage = 17;
246
+ }
247
+ }
248
+ }
@@ -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
+ }