@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.
- package/README.md +114 -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 +38 -9
- package/cpp/Primitives.h +5 -3
- package/cpp/ProtocolHost.cpp +4 -5
- package/cpp/StoreCallbacks.cpp +31 -43
- package/cpp/derec_ffi.h +98 -33
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +98 -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 +98 -33
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/errors.d.ts +8 -3
- package/lib/errors.js +6 -0
- package/lib/messages.js +5 -3
- package/lib/primitives.d.ts +12 -2
- package/lib/primitives.js +17 -2
- package/lib/protocol.d.ts +9 -5
- package/lib/protocol.js +9 -5
- package/lib/types.d.ts +194 -46
- 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 +266 -0
- package/schema/proto/derecmessage.proto +248 -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 +164 -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 +12 -1
- package/src/messages.ts +5 -3
- package/src/primitives.ts +23 -2
- package/src/protocol.ts +10 -6
- package/src/types.ts +185 -43
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
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 "communicationinfo.proto";
|
|
10
|
+
import "parameterrange.proto";
|
|
11
|
+
import "result.proto";
|
|
12
|
+
import "transportprotocol.proto";
|
|
13
|
+
|
|
14
|
+
package org.derecalliance.derec.protobuf;
|
|
15
|
+
|
|
16
|
+
// SenderKind identifies the logical role of the sender in the pairing flow.
|
|
17
|
+
//
|
|
18
|
+
// The role determines how the receiver interprets the message and what
|
|
19
|
+
// role each party takes in the resulting channel. Pairs are formed by
|
|
20
|
+
// matching complementary kinds: Owner↔Helper, ReplicaSource↔ReplicaDestination.
|
|
21
|
+
enum SenderKind {
|
|
22
|
+
// Sender is an Owner.
|
|
23
|
+
//
|
|
24
|
+
// Used for all Owner-initiated pairings, whether establishing a new
|
|
25
|
+
// relationship or re-pairing during recovery. There is no protocol-level
|
|
26
|
+
// distinction between the two cases.
|
|
27
|
+
OWNER = 0;
|
|
28
|
+
|
|
29
|
+
// Sender is acting as a Helper.
|
|
30
|
+
//
|
|
31
|
+
// Helpers may initiate pairing in some application flows, though the
|
|
32
|
+
// Owner typically acts as the initiator.
|
|
33
|
+
HELPER = 1;
|
|
34
|
+
|
|
35
|
+
// Sender is the Source side of a replica pair — the device that owns
|
|
36
|
+
// the secrets and pushes them to a destination for backup. The matching
|
|
37
|
+
// peer kind is REPLICA_DESTINATION.
|
|
38
|
+
//
|
|
39
|
+
// Replica pairing follows the same cryptographic handshake as Helper
|
|
40
|
+
// pairing but adds a mandatory fingerprint-verify step before the
|
|
41
|
+
// channel transitions out of `Pending`. After verification, the Source
|
|
42
|
+
// calls ProtectSecret targeting the Destination channel; the library
|
|
43
|
+
// sends a `ReplicaSecretPayload` (full secret + share map) to the
|
|
44
|
+
// Destination via a normal channel-mode `StoreShareRequest`.
|
|
45
|
+
REPLICA_SOURCE = 3;
|
|
46
|
+
|
|
47
|
+
// Sender is the Destination side of a replica pair — the device that
|
|
48
|
+
// receives and stores full secret copies from a Source for backup or
|
|
49
|
+
// recovery purposes. The matching peer kind is REPLICA_SOURCE.
|
|
50
|
+
//
|
|
51
|
+
// The Destination never initiates ProtectSecret on this channel; it
|
|
52
|
+
// only receives `ReplicaSecretPayload` messages and surfaces them to
|
|
53
|
+
// the application via the `ReplicaSecretReceived` event.
|
|
54
|
+
REPLICA_DESTINATION = 4;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// PairRequestMessage is the first message in the pairing protocol,
|
|
58
|
+
// sent from the initiator to the responder after receiving a ContactMessage.
|
|
59
|
+
//
|
|
60
|
+
// # Preconditions
|
|
61
|
+
//
|
|
62
|
+
// Before sending this message:
|
|
63
|
+
//
|
|
64
|
+
// - The initiator MUST have received a valid ContactMessage from the responder
|
|
65
|
+
// - The initiator MUST use the responder's public encryption material from
|
|
66
|
+
// the ContactMessage to construct this request
|
|
67
|
+
//
|
|
68
|
+
// # Purpose
|
|
69
|
+
//
|
|
70
|
+
// This message establishes:
|
|
71
|
+
//
|
|
72
|
+
// - the initiator's identity and role (Owner/Helper, recovery mode or not)
|
|
73
|
+
// - fresh cryptographic material for the responder to use in subsequent messages
|
|
74
|
+
// - agreement negotiation inputs (parameter ranges)
|
|
75
|
+
// - binding between the out-of-band contact exchange and this pairing attempt
|
|
76
|
+
// - transport information for future communication
|
|
77
|
+
//
|
|
78
|
+
// # Security Properties
|
|
79
|
+
//
|
|
80
|
+
// - The nonce binds this request to the ContactMessage exchange
|
|
81
|
+
// - The ciphertext and public keys bootstrap a secure communication channel
|
|
82
|
+
// - The message is encrypted and authenticated at the DeRecMessage layer
|
|
83
|
+
//
|
|
84
|
+
// # Outcome
|
|
85
|
+
//
|
|
86
|
+
// Upon successful processing, the responder replies with PairResponseMessage.
|
|
87
|
+
// After this exchange:
|
|
88
|
+
//
|
|
89
|
+
// - both parties know each other's public keys
|
|
90
|
+
// - a secure communication channel is established for subsequent protocol flows
|
|
91
|
+
message PairRequestMessage {
|
|
92
|
+
|
|
93
|
+
// The role of the sender of this message.
|
|
94
|
+
//
|
|
95
|
+
// This informs the responder whether the initiator is:
|
|
96
|
+
//
|
|
97
|
+
// - an Owner (normal or recovery mode), or
|
|
98
|
+
// - a Helper
|
|
99
|
+
//
|
|
100
|
+
// Recovery mode has special semantics for how Helpers associate this
|
|
101
|
+
// pairing with existing stored secrets.
|
|
102
|
+
SenderKind senderKind = 1;
|
|
103
|
+
|
|
104
|
+
// ML-KEM-1024 ciphertext.
|
|
105
|
+
//
|
|
106
|
+
// This ciphertext is generated using the responder's ML-KEM public key
|
|
107
|
+
// obtained from the ContactMessage. It is used to establish shared
|
|
108
|
+
// cryptographic material for securing subsequent communication.
|
|
109
|
+
bytes mlkemCiphertext = 2;
|
|
110
|
+
|
|
111
|
+
// Serialized ECIES public key of the sender.
|
|
112
|
+
//
|
|
113
|
+
// This key is provided to the responder so that future messages can be
|
|
114
|
+
// encrypted toward the initiator.
|
|
115
|
+
bytes eciesPublicKey = 3;
|
|
116
|
+
|
|
117
|
+
// Sender's application-level identifying information.
|
|
118
|
+
//
|
|
119
|
+
// This field is intended for user-facing identification and may include
|
|
120
|
+
// data such as name, phone number, or account identifiers.
|
|
121
|
+
//
|
|
122
|
+
// It is not used directly by the protocol for security decisions.
|
|
123
|
+
CommunicationInfo communicationInfo = 5;
|
|
124
|
+
|
|
125
|
+
// Nonce binding this request to the ContactMessage exchange.
|
|
126
|
+
//
|
|
127
|
+
// This value MUST match the nonce provided in the ContactMessage.
|
|
128
|
+
// It allows the responder to verify that the pairing request corresponds
|
|
129
|
+
// to the same out-of-band interaction, preventing mismatched or spoofed
|
|
130
|
+
// pairing attempts.
|
|
131
|
+
uint64 nonce = 6;
|
|
132
|
+
|
|
133
|
+
// Parameter range supported by the sender.
|
|
134
|
+
//
|
|
135
|
+
// This defines the acceptable configuration space (e.g., thresholds,
|
|
136
|
+
// limits) that the sender is willing to operate under.
|
|
137
|
+
//
|
|
138
|
+
// The responder combines this with its own parameter range to determine
|
|
139
|
+
// whether pairing is possible and which parameters to use.
|
|
140
|
+
ParameterRange parameterRange = 7;
|
|
141
|
+
|
|
142
|
+
// Formerly the singular `transportProtocol`, superseded by `supportedTransports`.
|
|
143
|
+
reserved 8;
|
|
144
|
+
reserved "transportProtocol";
|
|
145
|
+
|
|
146
|
+
// Timestamp indicating when this message was created.
|
|
147
|
+
//
|
|
148
|
+
// Used for observability and may assist in replay detection or timeout
|
|
149
|
+
// handling, depending on the implementation.
|
|
150
|
+
google.protobuf.Timestamp timestamp = 9;
|
|
151
|
+
|
|
152
|
+
// Every transport endpoint the initiator can be reached on, in the
|
|
153
|
+
// initiator's own preference order.
|
|
154
|
+
//
|
|
155
|
+
// Same semantics as `ContactMessage.supportedTransports`: the responder
|
|
156
|
+
// selects by its own preference, and the list MUST carry at least one
|
|
157
|
+
// entry.
|
|
158
|
+
repeated TransportProtocol supportedTransports = 10;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// PairResponseMessage is the response to a PairRequestMessage.
|
|
162
|
+
//
|
|
163
|
+
// # Purpose
|
|
164
|
+
//
|
|
165
|
+
// This message completes the pairing handshake. It informs the initiator:
|
|
166
|
+
//
|
|
167
|
+
// - whether the pairing was accepted or rejected
|
|
168
|
+
// - the responder's role and identity information
|
|
169
|
+
// - the responder's supported parameter range
|
|
170
|
+
//
|
|
171
|
+
// # Differences from PairRequestMessage
|
|
172
|
+
//
|
|
173
|
+
// - Does not include encryption public keys, as those were already exchanged
|
|
174
|
+
// via ContactMessage and PairRequestMessage
|
|
175
|
+
// - Includes a Result field indicating success or failure
|
|
176
|
+
//
|
|
177
|
+
// # Semantics
|
|
178
|
+
//
|
|
179
|
+
// - If `result` indicates success, a secure channel is considered established
|
|
180
|
+
// - If `result` indicates failure, the pairing MUST be treated as unsuccessful
|
|
181
|
+
// and no further protocol messages should be exchanged on this channel
|
|
182
|
+
//
|
|
183
|
+
// The nonce MUST match the value provided in the request, ensuring that the
|
|
184
|
+
// response corresponds to the same pairing session.
|
|
185
|
+
message PairResponseMessage {
|
|
186
|
+
|
|
187
|
+
// Result of processing the pairing request.
|
|
188
|
+
//
|
|
189
|
+
// Indicates whether the pairing was successful or failed.
|
|
190
|
+
// Failure may occur due to:
|
|
191
|
+
//
|
|
192
|
+
// - incompatible parameter ranges
|
|
193
|
+
// - failed authentication at the application layer
|
|
194
|
+
// - invalid or malformed request data
|
|
195
|
+
DeRecResult result = 1;
|
|
196
|
+
|
|
197
|
+
// Application-level identifying information of the responder.
|
|
198
|
+
//
|
|
199
|
+
// Intended for user-facing identification and display purposes.
|
|
200
|
+
CommunicationInfo communicationInfo = 4;
|
|
201
|
+
|
|
202
|
+
// Nonce identifying the pairing session.
|
|
203
|
+
//
|
|
204
|
+
// This value MUST exactly match the nonce received in the
|
|
205
|
+
// PairRequestMessage. A mismatch indicates an invalid or unrelated
|
|
206
|
+
// pairing attempt and SHOULD result in rejection.
|
|
207
|
+
uint64 nonce = 5;
|
|
208
|
+
|
|
209
|
+
// Parameter range supported by the responder.
|
|
210
|
+
//
|
|
211
|
+
// The initiator combines this with its own parameter range to determine
|
|
212
|
+
// the final agreed configuration for the channel.
|
|
213
|
+
ParameterRange parameterRange = 6;
|
|
214
|
+
|
|
215
|
+
// Timestamp indicating when this message was created.
|
|
216
|
+
//
|
|
217
|
+
// Used for observability and may assist in replay detection or timeout
|
|
218
|
+
// handling, depending on the implementation.
|
|
219
|
+
google.protobuf.Timestamp timestamp = 7;
|
|
220
|
+
|
|
221
|
+
// Derived channel identifier the two parties switch to immediately after
|
|
222
|
+
// the pairing handshake completes. This message is the only place this
|
|
223
|
+
// value travels on the wire, and it travels encrypted (inside the pairing
|
|
224
|
+
// envelope), so a passive observer who only sees the pre-rekey traffic
|
|
225
|
+
// cannot link the now-paired session to its long-running successor.
|
|
226
|
+
//
|
|
227
|
+
// # Derivation
|
|
228
|
+
//
|
|
229
|
+
// The responder computes:
|
|
230
|
+
//
|
|
231
|
+
// ```text
|
|
232
|
+
// channelId = u64::from_be_bytes(
|
|
233
|
+
// SHA-384(
|
|
234
|
+
// u64_be(originalChannelId) || sharedKeyBytes
|
|
235
|
+
// )[0..8]
|
|
236
|
+
// )
|
|
237
|
+
// ```
|
|
238
|
+
//
|
|
239
|
+
// where `originalChannelId` is the channelId from the contact / pairing
|
|
240
|
+
// envelopes and `sharedKeyBytes` is the channel key derived as described
|
|
241
|
+
// on `fingerprintNonce`.
|
|
242
|
+
//
|
|
243
|
+
// # Validation
|
|
244
|
+
//
|
|
245
|
+
// The requester MUST recompute the same hash with its own derivation of
|
|
246
|
+
// the shared key and reject the response (closing the would-be channel)
|
|
247
|
+
// if the value here does not match. A non-matching value indicates either
|
|
248
|
+
// a key-derivation mismatch (the channel would be unusable anyway) or
|
|
249
|
+
// tampering by a peer that somehow forged a valid envelope but cannot
|
|
250
|
+
// produce the SHA-384 preimage.
|
|
251
|
+
//
|
|
252
|
+
// # Effect
|
|
253
|
+
//
|
|
254
|
+
// Both parties atomically rekey their local channel record from
|
|
255
|
+
// `originalChannelId` to this value once the handshake is accepted. All
|
|
256
|
+
// subsequent envelopes on this channel — including the
|
|
257
|
+
// UpdateChannelInfo handover for the long-term transport — route on the
|
|
258
|
+
// new id.
|
|
259
|
+
uint64 channelId = 8;
|
|
260
|
+
|
|
261
|
+
// The 32-byte fingerprint nonce the creator committed to in
|
|
262
|
+
// `fingerprintCommitment` (on the `ContactMessage` in `INLINE_KEYS` mode,
|
|
263
|
+
// on the `PrePairResponseMessage` otherwise). Present only when
|
|
264
|
+
// `result.status == OK`.
|
|
265
|
+
//
|
|
266
|
+
// The requester MUST recompute the commitment from the creator's keys and
|
|
267
|
+
// this nonce, and reject the response (closing the would-be channel) if
|
|
268
|
+
// it does not match.
|
|
269
|
+
//
|
|
270
|
+
// # Channel key
|
|
271
|
+
//
|
|
272
|
+
// Both parties derive the channel key from the handshake key and this
|
|
273
|
+
// nonce:
|
|
274
|
+
//
|
|
275
|
+
// ```text
|
|
276
|
+
// SHA-256("DeRec channel key v1" || handshakeKey || fingerprintNonce)
|
|
277
|
+
// ```
|
|
278
|
+
//
|
|
279
|
+
// where `handshakeKey` is the ML-KEM shared secret XOR the ECDH shared
|
|
280
|
+
// secret. The channel key encrypts every later message, feeds the
|
|
281
|
+
// `channelId` derivation above, and is what the fingerprint is computed
|
|
282
|
+
// from.
|
|
283
|
+
optional bytes fingerprintNonce = 9;
|
|
284
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
message ParameterRange {
|
|
11
|
+
|
|
12
|
+
// Minimum and maximum number of bytes the party is willing to store
|
|
13
|
+
// at any given time.
|
|
14
|
+
int64 minShareSize = 1;
|
|
15
|
+
int64 maxShareSize = 2;
|
|
16
|
+
|
|
17
|
+
// Minimum and maximum interval between verification requests that
|
|
18
|
+
// will be accepted.
|
|
19
|
+
int64 minTimeBetweenVerifications = 3;
|
|
20
|
+
int64 maxTimeBetweenVerifications = 4;
|
|
21
|
+
|
|
22
|
+
// Minimum and maximum interval between accepting new share updates.
|
|
23
|
+
int64 minTimeBetweenShareUpdates = 5;
|
|
24
|
+
int64 maxTimeBetweenShareUpdates = 6;
|
|
25
|
+
|
|
26
|
+
// Minimum and maximum timeout period (in seconds) after which the
|
|
27
|
+
// other party is considered unresponsive and the pairing may be
|
|
28
|
+
// removed along with all associated data.
|
|
29
|
+
int64 minUnresponsiveDeletionTimeout = 7;
|
|
30
|
+
int64 maxUnresponsiveDeletionTimeout = 8;
|
|
31
|
+
|
|
32
|
+
// Minimum and maximum timeout period (in seconds) after which the
|
|
33
|
+
// other party is considered inactive.
|
|
34
|
+
int64 minUnresponsiveDeactivationTimeout = 9;
|
|
35
|
+
int64 maxUnresponsiveDeactivationTimeout = 10;
|
|
36
|
+
}
|