@derec-alliance/react-native 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/android/src/main/jniLibs/arm64-v8a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/x86_64/libderec_library.a +0 -0
- package/cpp/Primitives.cpp +13 -7
- package/cpp/ProtocolHost.cpp +4 -5
- package/cpp/StoreCallbacks.cpp +31 -43
- package/cpp/derec_ffi.h +44 -33
- package/ios/DeRecFFI.xcframework/Info.plist +5 -5
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +44 -33
- package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +44 -33
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/errors.d.ts +1 -1
- package/lib/errors.js +3 -0
- package/lib/messages.js +5 -3
- package/lib/primitives.d.ts +1 -1
- package/lib/primitives.js +4 -2
- package/lib/protocol.d.ts +9 -5
- package/lib/protocol.js +9 -5
- package/lib/types.d.ts +48 -20
- package/lib/types.js +4 -1
- package/package.json +4 -17
- package/schema/derec_descriptor.bin +0 -0
- package/schema/proto/committedderecshare.proto +93 -0
- package/schema/proto/communicationinfo.proto +104 -0
- package/schema/proto/contact.proto +258 -0
- package/schema/proto/derecmessage.proto +232 -0
- package/schema/proto/derecsecret.proto +163 -0
- package/schema/proto/derectransport.proto +38 -0
- package/schema/proto/error.proto +68 -0
- package/schema/proto/getshare.proto +184 -0
- package/schema/proto/pair.proto +284 -0
- package/schema/proto/parameterrange.proto +36 -0
- package/schema/proto/prepair.proto +163 -0
- package/schema/proto/result.proto +194 -0
- package/schema/proto/secretidsversions.proto +199 -0
- package/schema/proto/storeshare.proto +242 -0
- package/schema/proto/transportprotocol.proto +112 -0
- package/schema/proto/unpair.proto +132 -0
- package/schema/proto/updatechannelinfo.proto +100 -0
- package/schema/proto/verify.proto +160 -0
- package/src/errors.ts +3 -0
- package/src/messages.ts +5 -3
- package/src/primitives.ts +6 -2
- package/src/protocol.ts +10 -6
- package/src/types.ts +49 -23
|
@@ -0,0 +1,100 @@
|
|
|
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 "result.proto";
|
|
11
|
+
import "transportprotocol.proto";
|
|
12
|
+
|
|
13
|
+
package org.derecalliance.derec.protobuf;
|
|
14
|
+
|
|
15
|
+
// UpdateChannelInfoRequestMessage notifies the peer that the sender's
|
|
16
|
+
// communication metadata and/or transport endpoint have changed.
|
|
17
|
+
//
|
|
18
|
+
// # Context
|
|
19
|
+
//
|
|
20
|
+
// Both `communication_info` and the transport endpoints are exchanged at pairing
|
|
21
|
+
// time only. This message lets either party (Owner or Helper) propagate
|
|
22
|
+
// post-pairing changes without re-pairing.
|
|
23
|
+
//
|
|
24
|
+
// # Semantics
|
|
25
|
+
//
|
|
26
|
+
// Both fields are optional and independent:
|
|
27
|
+
//
|
|
28
|
+
// - `communication_info` absent (no `CommunicationInfo` set) means "do not
|
|
29
|
+
// modify the communication info stored for the sender." Presence — even
|
|
30
|
+
// with an empty `communication_info_entries` list — means "replace the
|
|
31
|
+
// stored map with the supplied one." Updates, additions, and deletions
|
|
32
|
+
// are all expressed by the difference between the receiver's current map
|
|
33
|
+
// and the supplied one.
|
|
34
|
+
// - `supported_transports` empty means "do not modify the transport
|
|
35
|
+
// endpoints stored for the sender." Non-empty means "the sender's transport
|
|
36
|
+
// endpoints are now these." The receiver MUST route subsequent messages on
|
|
37
|
+
// this channel to the new endpoints, including the
|
|
38
|
+
// UpdateChannelInfoResponseMessage for this request.
|
|
39
|
+
//
|
|
40
|
+
// # Endpoint changeover
|
|
41
|
+
//
|
|
42
|
+
// When `supported_transports` is updated, the receiver sends its response to
|
|
43
|
+
// the new endpoints. The sender's application is therefore responsible for
|
|
44
|
+
// ensuring the new endpoint is reachable BEFORE this request is issued, and
|
|
45
|
+
// for keeping the old endpoint operational long enough for in-flight
|
|
46
|
+
// messages from other peers (and any concurrent operations) to drain.
|
|
47
|
+
message UpdateChannelInfoRequestMessage {
|
|
48
|
+
|
|
49
|
+
// Updated communication info for the sender, or absent to leave unchanged.
|
|
50
|
+
//
|
|
51
|
+
// Presence (even with an empty entries list) replaces the receiver's
|
|
52
|
+
// stored map for this channel. Absence leaves it untouched.
|
|
53
|
+
optional CommunicationInfo communicationInfo = 1;
|
|
54
|
+
|
|
55
|
+
// Formerly the singular `transportProtocol`, superseded by `supportedTransports`.
|
|
56
|
+
reserved 2;
|
|
57
|
+
reserved "transportProtocol";
|
|
58
|
+
|
|
59
|
+
// Every transport endpoint the sender can now be reached on, in its own
|
|
60
|
+
// preference order, replacing the receiver's stored set for this channel.
|
|
61
|
+
//
|
|
62
|
+
// # Semantics
|
|
63
|
+
//
|
|
64
|
+
// - Empty: the sender's endpoints are left unchanged. An update that
|
|
65
|
+
// changes only `communicationInfo` says nothing about transports.
|
|
66
|
+
// - Non-empty: replaces the stored set outright. Unlike a request's
|
|
67
|
+
// `replyToTransports`, this **is** persisted — it is how a peer
|
|
68
|
+
// announces it has moved.
|
|
69
|
+
repeated TransportProtocol supportedTransports = 4;
|
|
70
|
+
|
|
71
|
+
// Timestamp indicating when this message was created.
|
|
72
|
+
//
|
|
73
|
+
// This value is expressed in UTC and is used for envelope-vs-body
|
|
74
|
+
// timestamp validation, replay detection, and observability.
|
|
75
|
+
google.protobuf.Timestamp timestamp = 3;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// UpdateChannelInfoResponseMessage is the response to an
|
|
79
|
+
// UpdateChannelInfoRequestMessage.
|
|
80
|
+
//
|
|
81
|
+
// # Semantics
|
|
82
|
+
//
|
|
83
|
+
// On success (`result.status == OK`):
|
|
84
|
+
//
|
|
85
|
+
// - the receiver has persisted the supplied updates
|
|
86
|
+
// - subsequent messages from the receiver MUST use the new endpoints, if
|
|
87
|
+
// `supported_transports` was updated
|
|
88
|
+
//
|
|
89
|
+
// On failure:
|
|
90
|
+
//
|
|
91
|
+
// - the receiver's stored state is unchanged
|
|
92
|
+
// - the sender SHOULD inspect `result.memo` for diagnostic context
|
|
93
|
+
message UpdateChannelInfoResponseMessage {
|
|
94
|
+
|
|
95
|
+
// Result of processing the update.
|
|
96
|
+
DeRecResult result = 1;
|
|
97
|
+
|
|
98
|
+
// Timestamp indicating when this message was created.
|
|
99
|
+
google.protobuf.Timestamp timestamp = 2;
|
|
100
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
|
|
15
|
+
// VerifyShareRequestMessage initiates a verification challenge from the Owner
|
|
16
|
+
// to a Helper to confirm that the Helper still retains a specific share.
|
|
17
|
+
//
|
|
18
|
+
// # Context
|
|
19
|
+
//
|
|
20
|
+
// This message is part of the verification flow, which allows the Owner to:
|
|
21
|
+
//
|
|
22
|
+
// - periodically check Helper liveness
|
|
23
|
+
// - detect data loss or corruption of stored shares
|
|
24
|
+
// - identify Helpers that are no longer reliable for recovery
|
|
25
|
+
//
|
|
26
|
+
// # Semantics
|
|
27
|
+
//
|
|
28
|
+
// The Owner challenges the Helper by providing:
|
|
29
|
+
//
|
|
30
|
+
// - a `version` identifying the share to verify
|
|
31
|
+
// - a fresh `nonce` to ensure the response is unique and not replayable
|
|
32
|
+
//
|
|
33
|
+
// The Helper MUST compute a cryptographic hash over:
|
|
34
|
+
//
|
|
35
|
+
// committedDeRecShare || nonce
|
|
36
|
+
//
|
|
37
|
+
// and return the result in a VerifyShareResponseMessage.
|
|
38
|
+
//
|
|
39
|
+
// # Security Properties
|
|
40
|
+
//
|
|
41
|
+
// - The nonce ensures freshness and prevents replay attacks
|
|
42
|
+
// - The hash proves possession of the exact share bytes
|
|
43
|
+
// - The Helper cannot produce a valid response without holding the share
|
|
44
|
+
//
|
|
45
|
+
// # Idempotency
|
|
46
|
+
//
|
|
47
|
+
// Each request is uniquely identified by the nonce. Reusing a nonce SHOULD
|
|
48
|
+
// be avoided, as it weakens replay protection guarantees.
|
|
49
|
+
message VerifyShareRequestMessage {
|
|
50
|
+
// Secret id being challenged.
|
|
51
|
+
//
|
|
52
|
+
// This identifies which stored share for a secret the Helper must use to compute
|
|
53
|
+
// the verification proof.
|
|
54
|
+
uint64 secretId = 1;
|
|
55
|
+
|
|
56
|
+
// Share version being challenged.
|
|
57
|
+
//
|
|
58
|
+
// This identifies which stored share version the Helper must use to compute
|
|
59
|
+
// the verification proof.
|
|
60
|
+
uint32 version = 2;
|
|
61
|
+
|
|
62
|
+
// Random challenge nonce generated by the Owner.
|
|
63
|
+
//
|
|
64
|
+
// This value MUST be unpredictable and unique per request to ensure
|
|
65
|
+
// freshness and prevent replay of previous responses.
|
|
66
|
+
uint64 nonce = 3;
|
|
67
|
+
|
|
68
|
+
// Timestamp indicating when this message was created.
|
|
69
|
+
//
|
|
70
|
+
// This value is expressed in UTC and can be used for:
|
|
71
|
+
//
|
|
72
|
+
// - observability and logging
|
|
73
|
+
// - replay detection (in combination with sequence numbers)
|
|
74
|
+
// - timeout handling
|
|
75
|
+
google.protobuf.Timestamp timestamp = 4;
|
|
76
|
+
|
|
77
|
+
// Formerly the singular `replyTo`, superseded by `replyToTransports`.
|
|
78
|
+
reserved 5;
|
|
79
|
+
reserved "replyTo";
|
|
80
|
+
|
|
81
|
+
// Every ephemeral endpoint the requester wants this exchange's response
|
|
82
|
+
// delivered to, in its own preference order.
|
|
83
|
+
//
|
|
84
|
+
// See `StoreShareRequestMessage.replyToTransports` for full semantics.
|
|
85
|
+
repeated TransportProtocol replyToTransports = 6;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// VerifyShareResponseMessage contains the result of a verification challenge
|
|
89
|
+
// and, on success, provides a proof of share possession.
|
|
90
|
+
//
|
|
91
|
+
// # Semantics
|
|
92
|
+
//
|
|
93
|
+
// In response to a VerifyShareRequestMessage, the Helper:
|
|
94
|
+
//
|
|
95
|
+
// - retrieves the requested share version
|
|
96
|
+
// - computes the hash over (committedDeRecShare || nonce)
|
|
97
|
+
// - returns the result along with the echoed version and nonce
|
|
98
|
+
//
|
|
99
|
+
// The Owner verifies the response by recomputing the expected hash and
|
|
100
|
+
// comparing it with the received value.
|
|
101
|
+
//
|
|
102
|
+
// # Failure Handling
|
|
103
|
+
//
|
|
104
|
+
// If the verification fails (e.g., incorrect hash or error result), the Owner:
|
|
105
|
+
//
|
|
106
|
+
// - MAY retry the verification
|
|
107
|
+
// - MAY resend the correct share to the Helper
|
|
108
|
+
// - MAY mark the Helper as unreliable after repeated failures
|
|
109
|
+
//
|
|
110
|
+
// # Security Considerations
|
|
111
|
+
//
|
|
112
|
+
// - The hash MUST be computed using SHA-384 as defined by the protocol
|
|
113
|
+
// - The nonce MUST match the request to ensure the response is not replayed
|
|
114
|
+
// - The response MUST be sent over an authenticated and encrypted channel
|
|
115
|
+
//
|
|
116
|
+
// # Idempotency
|
|
117
|
+
//
|
|
118
|
+
// Responses are tied to a specific (version, nonce) pair. Replaying a response
|
|
119
|
+
// with a stale nonce SHOULD be rejected by the Owner.
|
|
120
|
+
message VerifyShareResponseMessage {
|
|
121
|
+
// Result of processing the verification request.
|
|
122
|
+
//
|
|
123
|
+
// Indicates whether the Helper successfully computed the proof or
|
|
124
|
+
// encountered an error (e.g., share not found).
|
|
125
|
+
DeRecResult result = 1;
|
|
126
|
+
|
|
127
|
+
// Secret id this response refers to.
|
|
128
|
+
//
|
|
129
|
+
// MUST match the version provided in the request.
|
|
130
|
+
uint64 secretId = 2;
|
|
131
|
+
|
|
132
|
+
// Share version this response refers to.
|
|
133
|
+
//
|
|
134
|
+
// MUST match the version provided in the request.
|
|
135
|
+
uint32 version = 3;
|
|
136
|
+
|
|
137
|
+
// Challenge nonce echoed from the request.
|
|
138
|
+
//
|
|
139
|
+
// MUST exactly match the nonce provided in the request.
|
|
140
|
+
uint64 nonce = 4;
|
|
141
|
+
|
|
142
|
+
// Verification proof.
|
|
143
|
+
//
|
|
144
|
+
// This is the SHA-384 hash of:
|
|
145
|
+
//
|
|
146
|
+
// committedDeRecShare || nonce
|
|
147
|
+
//
|
|
148
|
+
// where `committedDeRecShare` is the exact byte sequence originally
|
|
149
|
+
// stored by the Helper.
|
|
150
|
+
bytes hash = 5;
|
|
151
|
+
|
|
152
|
+
// Timestamp indicating when this message was created.
|
|
153
|
+
//
|
|
154
|
+
// This value is expressed in UTC and can be used for:
|
|
155
|
+
//
|
|
156
|
+
// - observability and logging
|
|
157
|
+
// - replay detection (in combination with sequence numbers)
|
|
158
|
+
// - timeout handling
|
|
159
|
+
google.protobuf.Timestamp timestamp = 6;
|
|
160
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -62,6 +62,7 @@ export const DEREC_ERROR_CODES = [
|
|
|
62
62
|
"already_restored",
|
|
63
63
|
"restore_conflict",
|
|
64
64
|
"replica_id_conflict",
|
|
65
|
+
"fingerprint_mismatch",
|
|
65
66
|
"encryption",
|
|
66
67
|
"keygen",
|
|
67
68
|
"finish_pairing_initiator",
|
|
@@ -74,6 +75,7 @@ export const DEREC_ERROR_CODES = [
|
|
|
74
75
|
"missing_replica_id",
|
|
75
76
|
"unexpected_replica_id",
|
|
76
77
|
"incompatible_parameter_range",
|
|
78
|
+
"fingerprint_commitment_mismatch",
|
|
77
79
|
"empty_channels",
|
|
78
80
|
"duplicate_channel_id",
|
|
79
81
|
"invalid_threshold",
|
|
@@ -81,6 +83,7 @@ export const DEREC_ERROR_CODES = [
|
|
|
81
83
|
"vss_share_failed",
|
|
82
84
|
"invalid_weight",
|
|
83
85
|
"too_many_subshares",
|
|
86
|
+
"invalid_keep_version",
|
|
84
87
|
"empty_responses",
|
|
85
88
|
"empty_committed_derec_share",
|
|
86
89
|
"decode_committed_derec_share",
|
package/src/messages.ts
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
* surface.
|
|
27
27
|
*
|
|
28
28
|
* Both conversions are keyed by field name, matching the lists in
|
|
29
|
-
* `message_json.rs`. A name-keyed walk is deliberate:
|
|
30
|
-
*
|
|
31
|
-
* bytes" rule
|
|
29
|
+
* `message_json.rs`. A name-keyed walk is deliberate: only the fields that
|
|
30
|
+
* file names change representation, so a structural "array of numbers is
|
|
31
|
+
* bytes" rule cannot corrupt a field that is not bytes.
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
import { jsonFromBytes, jsonToBytes } from './codec';
|
|
@@ -93,6 +93,8 @@ const BYTE_FIELDS = new Set([
|
|
|
93
93
|
'mlkem_encapsulation_key',
|
|
94
94
|
'ecies_public_key',
|
|
95
95
|
'contact_binding_hash',
|
|
96
|
+
'fingerprint_commitment',
|
|
97
|
+
'fingerprint_nonce',
|
|
96
98
|
'bytes_value',
|
|
97
99
|
'share',
|
|
98
100
|
'committed_de_rec_share',
|
package/src/primitives.ts
CHANGED
|
@@ -460,11 +460,13 @@ const pairing = {
|
|
|
460
460
|
mlkem_encapsulation_key: ArrayBuffer;
|
|
461
461
|
ecies_public_key: ArrayBuffer;
|
|
462
462
|
nonce: bigint;
|
|
463
|
+
fingerprint_commitment: ArrayBuffer;
|
|
463
464
|
};
|
|
464
465
|
return {
|
|
465
466
|
mlkem_encapsulation_key: bytes(result.mlkem_encapsulation_key),
|
|
466
467
|
ecies_public_key: bytes(result.ecies_public_key),
|
|
467
468
|
nonce: result.nonce,
|
|
469
|
+
fingerprint_commitment: bytes(result.fingerprint_commitment),
|
|
468
470
|
};
|
|
469
471
|
},
|
|
470
472
|
|
|
@@ -495,11 +497,13 @@ const pairing = {
|
|
|
495
497
|
mlkem_encapsulation_key: ArrayBuffer;
|
|
496
498
|
ecies_public_key: ArrayBuffer;
|
|
497
499
|
nonce: bigint;
|
|
500
|
+
fingerprint_commitment: ArrayBuffer;
|
|
498
501
|
};
|
|
499
502
|
return {
|
|
500
503
|
mlkem_encapsulation_key: bytes(result.mlkem_encapsulation_key),
|
|
501
504
|
ecies_public_key: bytes(result.ecies_public_key),
|
|
502
505
|
nonce: result.nonce,
|
|
506
|
+
fingerprint_commitment: bytes(result.fingerprint_commitment),
|
|
503
507
|
};
|
|
504
508
|
},
|
|
505
509
|
},
|
|
@@ -626,7 +630,7 @@ const sharing = {
|
|
|
626
630
|
version: number,
|
|
627
631
|
secret_id: bigint,
|
|
628
632
|
committed_share: CommittedDeRecShare,
|
|
629
|
-
|
|
633
|
+
keep_version: number,
|
|
630
634
|
description: string,
|
|
631
635
|
shared_key: Uint8Array,
|
|
632
636
|
reply_to?: TransportProtocol[],
|
|
@@ -637,7 +641,7 @@ const sharing = {
|
|
|
637
641
|
version,
|
|
638
642
|
secret_id,
|
|
639
643
|
encodeMessage(MessageKind.CommittedDeRecShare, committed_share),
|
|
640
|
-
|
|
644
|
+
keep_version,
|
|
641
645
|
utf8Encode(description),
|
|
642
646
|
shared_key,
|
|
643
647
|
replyTo(reply_to),
|
package/src/protocol.ts
CHANGED
|
@@ -754,23 +754,27 @@ export class DeRecProtocol {
|
|
|
754
754
|
|
|
755
755
|
/**
|
|
756
756
|
* Verify `fingerprint` against the channel's locally-derived one. On
|
|
757
|
-
* match, the channel transitions from `Pending` to `Paired`.
|
|
758
|
-
*
|
|
757
|
+
* match, the channel transitions from `Pending` to `Paired`.
|
|
758
|
+
*
|
|
759
|
+
* A mismatch rejects with code `fingerprint_mismatch` — a possible
|
|
760
|
+
* man-in-the-middle. A `Pending` pairing is revoked: its records, channel
|
|
761
|
+
* key and pairing material are deleted, so pair again. A channel already
|
|
762
|
+
* `Paired` is left as it is.
|
|
759
763
|
*
|
|
760
764
|
* On a replica destination, confirming is also the decision to adopt the
|
|
761
765
|
* group's vault: the source's publish is then installed as it arrives,
|
|
762
766
|
* with no further prompt. Ask the user before calling this; to decline,
|
|
763
|
-
* never confirm.
|
|
767
|
+
* never confirm: expired-channel cleanup removes the channel and its key.
|
|
764
768
|
*
|
|
765
769
|
* On a promotion the current snapshot is published to the promoted peer,
|
|
766
770
|
* reusing the stored helper weights. If one is no longer valid under the
|
|
767
771
|
* current threshold, that publish fails with `invalid_weight` before
|
|
768
772
|
* anything is sent and this throws. The promotion stands: calling this
|
|
769
|
-
* again resolves
|
|
773
|
+
* again resolves and publishes nothing, so call `start` with
|
|
770
774
|
* `ProtectSecret` and valid weights to reach the promoted peer.
|
|
771
775
|
*/
|
|
772
|
-
async verifyFingerprint(channelId: bigint | number, fingerprint: string): Promise<
|
|
773
|
-
|
|
776
|
+
async verifyFingerprint(channelId: bigint | number, fingerprint: string): Promise<void> {
|
|
777
|
+
await this.host.verifyFingerprint(toBigInt(channelId), fingerprint);
|
|
774
778
|
}
|
|
775
779
|
|
|
776
780
|
async removeExpiredChannels(olderThanSecs: number): Promise<string[]> {
|
package/src/types.ts
CHANGED
|
@@ -299,9 +299,9 @@ export interface ShareStore {
|
|
|
299
299
|
* `versions`. Idempotent: a version that is not stored is skipped, and
|
|
300
300
|
* an empty array is a no-op.
|
|
301
301
|
*
|
|
302
|
-
* A helper calls this to apply `StoreShareRequestMessage.
|
|
303
|
-
*
|
|
304
|
-
*
|
|
302
|
+
* A helper calls this to apply `StoreShareRequestMessage.keepVersion`:
|
|
303
|
+
* once the incoming share is persisted, every version stored on the
|
|
304
|
+
* channel other than the incoming one and `keepVersion` is removed.
|
|
305
305
|
* Shares under other channels or partitions must be left untouched.
|
|
306
306
|
*/
|
|
307
307
|
removeVersions(
|
|
@@ -310,26 +310,26 @@ export interface ShareStore {
|
|
|
310
310
|
versions: number[],
|
|
311
311
|
): Promise<void>;
|
|
312
312
|
/**
|
|
313
|
-
* Owner only: the
|
|
314
|
-
* `version`. Asked once per sharing round, before anything is
|
|
315
|
-
* including the rounds the library starts itself; the answer
|
|
316
|
-
* `
|
|
313
|
+
* Owner only: the one older version every helper keeps after the owner
|
|
314
|
+
* distributes `version`. Asked once per sharing round, before anything is
|
|
315
|
+
* sent, including the rounds the library starts itself; the answer
|
|
316
|
+
* becomes `keepVersion` for every helper.
|
|
317
317
|
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
318
|
+
* Resolve to an integer in `0..=4294967295`. A helper that stores
|
|
319
|
+
* `version` keeps it and the returned version, and deletes every other
|
|
320
|
+
* version it holds; `0` keeps no other version. An answer equal to or
|
|
321
|
+
* greater than `version` fails the round with `invalid_keep_version`
|
|
322
|
+
* before anything is sent.
|
|
323
|
+
*
|
|
324
|
+
* Return the last valid version: the newest one whose `SharingComplete`
|
|
325
|
+
* reported `threshold_met`. A version whose round is still open is
|
|
326
|
+
* deleted from every helper that stores `version` unless it is the one
|
|
327
|
+
* returned here. Only the application knows which versions committed.
|
|
328
|
+
* When a helper confirms `version`, the library also removes this
|
|
329
|
+
* device's rows for that channel other than `version` and the returned
|
|
330
|
+
* version.
|
|
328
331
|
*/
|
|
329
|
-
|
|
330
|
-
secretId: string,
|
|
331
|
-
version: number,
|
|
332
|
-
): Promise<number[] | null | undefined>;
|
|
332
|
+
keepVersion(secretId: string, version: number): Promise<number>;
|
|
333
333
|
/**
|
|
334
334
|
* Record a verification challenge the helper is about to answer for
|
|
335
335
|
* `(secretId, channelId, version)`. Called once per accepted challenge,
|
|
@@ -633,7 +633,10 @@ export enum SenderKind {
|
|
|
633
633
|
* are ignored. A man-in-the-middle on the plaintext `PrePair` leg leaves
|
|
634
634
|
* the two sides with different shared keys and so different fingerprints,
|
|
635
635
|
* which is what the comparison catches — the role `contact_binding_hash`
|
|
636
|
-
* plays for `HashedKeys`.
|
|
636
|
+
* plays for `HashedKeys`. The creator's `PrePair` response also carries a
|
|
637
|
+
* commitment to a nonce it reveals only in its `PairResponse`, and the
|
|
638
|
+
* channel key depends on that nonce, so whoever answers the scanner cannot
|
|
639
|
+
* search offline for keys that make the two fingerprints agree.
|
|
637
640
|
*/
|
|
638
641
|
export enum ContactMode {
|
|
639
642
|
InlineKeys = 0,
|
|
@@ -695,6 +698,14 @@ export interface ContactMessage {
|
|
|
695
698
|
/** Present only when `contact_mode === ContactMode.HashedKeys`. SHA-384 digest (48 bytes). */
|
|
696
699
|
contact_binding_hash?: Uint8Array;
|
|
697
700
|
timestamp?: Timestamp;
|
|
701
|
+
/**
|
|
702
|
+
* Present only when `contact_mode === ContactMode.InlineKeys`. The
|
|
703
|
+
* creator's 32-byte commitment to the fingerprint nonce its
|
|
704
|
+
* `PairResponseMessage` reveals. For the other modes it arrives with the
|
|
705
|
+
* keys in the `PrePairResponseMessage`; a contact filled in from a
|
|
706
|
+
* `ProcessPrePairResult` must carry it alongside the two keys.
|
|
707
|
+
*/
|
|
708
|
+
fingerprint_commitment?: Uint8Array;
|
|
698
709
|
/** Every transport endpoint the creator of this contact can be reached
|
|
699
710
|
* on, in its own preference order. */
|
|
700
711
|
supported_transports: TransportProtocol[];
|
|
@@ -1763,6 +1774,11 @@ export interface PairResponseMessage {
|
|
|
1763
1774
|
* its own derivation. Zero on rejection (non-Ok `result.status`).
|
|
1764
1775
|
*/
|
|
1765
1776
|
channel_id: bigint;
|
|
1777
|
+
/**
|
|
1778
|
+
* Present only when `result.status === Ok`. The 32-byte fingerprint nonce
|
|
1779
|
+
* the contact creator committed to in `fingerprint_commitment`.
|
|
1780
|
+
*/
|
|
1781
|
+
fingerprint_nonce?: Uint8Array;
|
|
1766
1782
|
}
|
|
1767
1783
|
|
|
1768
1784
|
export interface PrePairRequestMessage {
|
|
@@ -1783,6 +1799,12 @@ export interface PrePairResponseMessage {
|
|
|
1783
1799
|
ecies_public_key?: Uint8Array;
|
|
1784
1800
|
nonce: bigint;
|
|
1785
1801
|
timestamp?: Timestamp;
|
|
1802
|
+
/**
|
|
1803
|
+
* Present only when `result.status === Ok`. The creator's 32-byte
|
|
1804
|
+
* commitment to the fingerprint nonce its `PairResponseMessage` reveals,
|
|
1805
|
+
* covering the two keys above.
|
|
1806
|
+
*/
|
|
1807
|
+
fingerprint_commitment?: Uint8Array;
|
|
1786
1808
|
}
|
|
1787
1809
|
|
|
1788
1810
|
export interface GetShareRequestMessage {
|
|
@@ -1832,7 +1854,7 @@ export interface StoreShareRequestMessage {
|
|
|
1832
1854
|
share: Uint8Array;
|
|
1833
1855
|
share_algorithm: number;
|
|
1834
1856
|
version: number;
|
|
1835
|
-
|
|
1857
|
+
keep_version: number;
|
|
1836
1858
|
version_description: string;
|
|
1837
1859
|
timestamp?: Timestamp;
|
|
1838
1860
|
secret_id: bigint;
|
|
@@ -1989,6 +2011,10 @@ export interface ProcessPrePairResult {
|
|
|
1989
2011
|
|
|
1990
2012
|
/** Nonce echoed from the original `ContactMessage`. */
|
|
1991
2013
|
nonce: bigint;
|
|
2014
|
+
|
|
2015
|
+
/** The creator's 32-byte commitment to its fingerprint nonce. Copy it into
|
|
2016
|
+
* the contact the pair request is built from, alongside the two keys. */
|
|
2017
|
+
fingerprint_commitment: Uint8Array;
|
|
1992
2018
|
}
|
|
1993
2019
|
|
|
1994
2020
|
/**
|