@derec-alliance/react-native 0.0.8 → 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.
Files changed (50) hide show
  1. package/README.md +410 -9
  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/Convert.cpp +9 -0
  6. package/cpp/Convert.h +8 -2
  7. package/cpp/Primitives.cpp +123 -29
  8. package/cpp/ProtocolHost.cpp +4 -5
  9. package/cpp/StoreCallbacks.cpp +148 -61
  10. package/cpp/StoreCallbacks.h +8 -1
  11. package/cpp/derec_ffi.h +127 -48
  12. package/ios/DeRecFFI.xcframework/Info.plist +5 -5
  13. package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +127 -48
  14. package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
  15. package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +127 -48
  16. package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
  17. package/lib/errors.d.ts +11 -1
  18. package/lib/errors.js +66 -1
  19. package/lib/messages.js +5 -3
  20. package/lib/primitives.d.ts +3 -3
  21. package/lib/primitives.js +7 -3
  22. package/lib/protocol.d.ts +110 -10
  23. package/lib/protocol.js +166 -11
  24. package/lib/types.d.ts +474 -48
  25. package/lib/types.js +23 -1
  26. package/package.json +4 -17
  27. package/schema/derec_descriptor.bin +0 -0
  28. package/schema/proto/committedderecshare.proto +93 -0
  29. package/schema/proto/communicationinfo.proto +104 -0
  30. package/schema/proto/contact.proto +258 -0
  31. package/schema/proto/derecmessage.proto +232 -0
  32. package/schema/proto/derecsecret.proto +163 -0
  33. package/schema/proto/derectransport.proto +38 -0
  34. package/schema/proto/error.proto +68 -0
  35. package/schema/proto/getshare.proto +184 -0
  36. package/schema/proto/pair.proto +284 -0
  37. package/schema/proto/parameterrange.proto +36 -0
  38. package/schema/proto/prepair.proto +163 -0
  39. package/schema/proto/result.proto +194 -0
  40. package/schema/proto/secretidsversions.proto +199 -0
  41. package/schema/proto/storeshare.proto +242 -0
  42. package/schema/proto/transportprotocol.proto +112 -0
  43. package/schema/proto/unpair.proto +132 -0
  44. package/schema/proto/updatechannelinfo.proto +100 -0
  45. package/schema/proto/verify.proto +160 -0
  46. package/src/errors.ts +69 -1
  47. package/src/messages.ts +5 -3
  48. package/src/primitives.ts +19 -4
  49. package/src/protocol.ts +175 -13
  50. package/src/types.ts +481 -52
@@ -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
+ }
@@ -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,68 @@
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
+
11
+ package org.derecalliance.derec.protobuf;
12
+
13
+ // ErrorResponseMessage is a generic error response sent when a protocol
14
+ // message cannot be processed successfully.
15
+ //
16
+ // # Context
17
+ //
18
+ // This message may be returned in response to any DeRecMessage when the
19
+ // receiver encounters an error during processing.
20
+ //
21
+ // Typical scenarios include:
22
+ //
23
+ // - malformed or invalid message payloads
24
+ // - unsupported or unknown message types
25
+ // - protocol violations (e.g., invalid sequence, nonce mismatch)
26
+ // - authorization or validation failures
27
+ //
28
+ // # Semantics
29
+ //
30
+ // This message indicates that:
31
+ //
32
+ // - the original request was not successfully processed
33
+ // - no state change should be assumed by the sender
34
+ //
35
+ // The sender SHOULD:
36
+ //
37
+ // - inspect the `result` field to determine the cause of the failure
38
+ // - decide whether to retry, abort, or escalate based on the error
39
+ //
40
+ // # Usage Guidelines
41
+ //
42
+ // - This message is intended as a fallback when no more specific response
43
+ // type is applicable
44
+ // - Protocol-specific errors SHOULD use their corresponding response
45
+ // messages when available
46
+ //
47
+ // # Security Considerations
48
+ //
49
+ // - Error responses SHOULD avoid leaking sensitive internal details
50
+ // - Only high-level error information should be exposed via `result`
51
+ //
52
+ // # Idempotency
53
+ //
54
+ // Error responses are idempotent and may be returned multiple times
55
+ // for repeated invalid requests.
56
+ message ErrorResponseMessage {
57
+ // Result describing the error encountered while processing the request.
58
+ //
59
+ // This field encodes the error type and any associated status information.
60
+ DeRecResult result = 1;
61
+
62
+ // Timestamp indicating when this message was created.
63
+ //
64
+ // This value is expressed in UTC and can be used for observability,
65
+ // replay detection, and timeout handling. The envelope carries the same
66
+ // value, and a receiver rejects a message whose two copies differ.
67
+ google.protobuf.Timestamp timestamp = 2;
68
+ }
@@ -0,0 +1,184 @@
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
+ // Formerly the singular `replyTo`, superseded by `replyToTransports`.
74
+ reserved 4;
75
+ reserved "replyTo";
76
+
77
+ // Every ephemeral endpoint the requester wants this exchange's response
78
+ // delivered to, in its own preference order.
79
+ //
80
+ // See `StoreShareRequestMessage.replyToTransports` for full semantics.
81
+ repeated TransportProtocol replyToTransports = 6;
82
+
83
+ // Identity of the replica-group member this message concerns.
84
+ //
85
+ // Present **only** on the replica path, where a member drives catch-up
86
+ // against another member. Absent on the owner ↔ helper path, which is
87
+ // unchanged.
88
+ //
89
+ // Every member of a group is addressed on one shared `channel_id`, so the
90
+ // channel cannot name the peer — this field does. Its presence is also what
91
+ // tells the receiver which path a message belongs to.
92
+ optional uint64 replicaId = 5;
93
+ }
94
+
95
+ // GetShareResponseMessage returns a share previously stored by the Helper.
96
+ //
97
+ // # Semantics
98
+ //
99
+ // This message is sent in response to a GetShareRequestMessage. It either:
100
+ //
101
+ // - returns the requested share (on success), or
102
+ // - indicates failure via the `result` field
103
+ //
104
+ // # Authorization Enforcement
105
+ //
106
+ // The Helper MUST ensure that the request satisfies the authorization rules
107
+ // described in GetShareRequestMessage before returning any share data.
108
+ //
109
+ // # Share Contents
110
+ //
111
+ // The returned share is an opaque byte sequence that typically includes:
112
+ //
113
+ // - the Shamir share (x, y)
114
+ // - the encrypted secret payload (or a reference to it)
115
+ // - the commitment (e.g., Merkle root)
116
+ // - the opening proof for verification
117
+ //
118
+ // The exact structure is defined by the share algorithm indicated in
119
+ // `shareAlgorithm`.
120
+ //
121
+ // # Security Considerations
122
+ //
123
+ // - The share MUST only be returned over an authenticated and encrypted
124
+ // DeRec channel
125
+ // - Incorrect or malicious shares may be detected by the Owner during
126
+ // recovery using commitment verification
127
+ //
128
+ // # Idempotency
129
+ //
130
+ // For a given (secretId, version), repeated responses SHOULD return
131
+ // the same share data.
132
+ message GetShareResponseMessage {
133
+
134
+ // Result of processing the request.
135
+ //
136
+ // Indicates whether the share was successfully retrieved or if an error
137
+ // occurred (e.g., unauthorized request, unknown secretId, or missing version).
138
+ DeRecResult result = 1;
139
+
140
+ // The committed DeRec share.
141
+ //
142
+ // This is an opaque byte array containing the share data as produced by
143
+ // the share distribution algorithm. Its internal structure depends on
144
+ // `shareAlgorithm`.
145
+ bytes committedDeRecShare = 2;
146
+
147
+ // Identifier of the share algorithm used to produce the share.
148
+ //
149
+ // This allows the recipient to interpret and process the share correctly
150
+ // during verification and reconstruction.
151
+ int32 shareAlgorithm = 3;
152
+
153
+ // Timestamp indicating when this message was created.
154
+ //
155
+ // This value is expressed in UTC and can be used for observability,
156
+ // replay detection, and timeout handling.
157
+ google.protobuf.Timestamp timestamp = 4;
158
+
159
+ // Identifier of the secret to which this response refers.
160
+ //
161
+ // Echoed from the corresponding GetShareRequestMessage so the Owner can
162
+ // correlate responses with the correct pending recovery without inspecting
163
+ // the share bytes. Required when the Owner has multiple recoveries in
164
+ // progress concurrently, or to defend against stale responses from a
165
+ // previously-abandoned recovery attempt.
166
+ uint64 secretId = 5;
167
+
168
+ // Version of the share being returned.
169
+ //
170
+ // Echoed from the corresponding GetShareRequestMessage for the same
171
+ // correlation reasons as `secretId`.
172
+ uint32 version = 6;
173
+
174
+ // Identity of the replica-group member this message concerns.
175
+ //
176
+ // Present **only** on the replica path, where a member drives catch-up
177
+ // against another member. Absent on the owner ↔ helper path, which is
178
+ // unchanged.
179
+ //
180
+ // Every member of a group is addressed on one shared `channel_id`, so the
181
+ // channel cannot name the peer — this field does. Its presence is also what
182
+ // tells the receiver which path a message belongs to.
183
+ optional uint64 replicaId = 7;
184
+ }