@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.
- package/README.md +410 -9
- 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/Convert.cpp +9 -0
- package/cpp/Convert.h +8 -2
- package/cpp/Primitives.cpp +123 -29
- package/cpp/ProtocolHost.cpp +4 -5
- package/cpp/StoreCallbacks.cpp +148 -61
- package/cpp/StoreCallbacks.h +8 -1
- package/cpp/derec_ffi.h +127 -48
- package/ios/DeRecFFI.xcframework/Info.plist +5 -5
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +127 -48
- package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +127 -48
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/errors.d.ts +11 -1
- package/lib/errors.js +66 -1
- package/lib/messages.js +5 -3
- package/lib/primitives.d.ts +3 -3
- package/lib/primitives.js +7 -3
- package/lib/protocol.d.ts +110 -10
- package/lib/protocol.js +166 -11
- package/lib/types.d.ts +474 -48
- package/lib/types.js +23 -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 +69 -1
- package/src/messages.ts +5 -3
- package/src/primitives.ts +19 -4
- package/src/protocol.ts +175 -13
- package/src/types.ts +481 -52
|
@@ -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
|
@@ -36,9 +36,77 @@ export const DEREC_ERROR_CATEGORIES = [
|
|
|
36
36
|
|
|
37
37
|
export type DeRecErrorCategory = (typeof DEREC_ERROR_CATEGORIES)[number];
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Every code `derec_error_code_name` can return, and no others.
|
|
41
|
+
*
|
|
42
|
+
* Held to the shared enum fixture by a test, like {@link DEREC_ERROR_CATEGORIES}.
|
|
43
|
+
* Unlike the WASM bindings, this SDK raises no marshalling-level codes of its
|
|
44
|
+
* own before a value reaches the library, so this list is exactly the Rust
|
|
45
|
+
* `Code` table in `library/src/interop/error_codes.rs`.
|
|
46
|
+
*/
|
|
47
|
+
export const DEREC_ERROR_CODES = [
|
|
48
|
+
"ok",
|
|
49
|
+
"non_ok_status",
|
|
50
|
+
"version_mismatch",
|
|
51
|
+
"invariant",
|
|
52
|
+
"invalid_input",
|
|
53
|
+
"protobuf_decode",
|
|
54
|
+
"protobuf_encode",
|
|
55
|
+
"protocol_violation",
|
|
56
|
+
"store_error",
|
|
57
|
+
"builder_error",
|
|
58
|
+
"missing_shared_key",
|
|
59
|
+
"role_mismatch",
|
|
60
|
+
"replica_id_not_configured",
|
|
61
|
+
"channel_already_paired",
|
|
62
|
+
"already_restored",
|
|
63
|
+
"restore_conflict",
|
|
64
|
+
"replica_id_conflict",
|
|
65
|
+
"fingerprint_mismatch",
|
|
66
|
+
"encryption",
|
|
67
|
+
"keygen",
|
|
68
|
+
"finish_pairing_initiator",
|
|
69
|
+
"finish_pairing_responder",
|
|
70
|
+
"empty_transport_uri",
|
|
71
|
+
"invalid_contact_message",
|
|
72
|
+
"invalid_pair_request_message",
|
|
73
|
+
"invalid_pair_response_message",
|
|
74
|
+
"prepair_hash_mismatch",
|
|
75
|
+
"missing_replica_id",
|
|
76
|
+
"unexpected_replica_id",
|
|
77
|
+
"incompatible_parameter_range",
|
|
78
|
+
"fingerprint_commitment_mismatch",
|
|
79
|
+
"empty_channels",
|
|
80
|
+
"duplicate_channel_id",
|
|
81
|
+
"invalid_threshold",
|
|
82
|
+
"empty_secret_data",
|
|
83
|
+
"vss_share_failed",
|
|
84
|
+
"invalid_weight",
|
|
85
|
+
"too_many_subshares",
|
|
86
|
+
"invalid_keep_version",
|
|
87
|
+
"empty_responses",
|
|
88
|
+
"empty_committed_derec_share",
|
|
89
|
+
"decode_committed_derec_share",
|
|
90
|
+
"decode_derec_share",
|
|
91
|
+
"secret_id_mismatch",
|
|
92
|
+
"reconstruction_failed",
|
|
93
|
+
"malformed_recovered_secret",
|
|
94
|
+
"ffi_null_ptr",
|
|
95
|
+
"ffi_bad_length",
|
|
96
|
+
"ffi_bad_utf8",
|
|
97
|
+
"ffi_bad_proto",
|
|
98
|
+
"ffi_invalid_enum",
|
|
99
|
+
"ffi_bad_shared_key",
|
|
100
|
+
"ffi_nul_in_string",
|
|
101
|
+
"transport_invalid",
|
|
102
|
+
"no_usable_endpoint",
|
|
103
|
+
] as const;
|
|
104
|
+
|
|
105
|
+
export type DeRecErrorCode = (typeof DEREC_ERROR_CODES)[number];
|
|
106
|
+
|
|
39
107
|
export interface DeRecError {
|
|
40
108
|
category: DeRecErrorCategory;
|
|
41
|
-
code:
|
|
109
|
+
code: DeRecErrorCode;
|
|
42
110
|
message: string;
|
|
43
111
|
status?: number;
|
|
44
112
|
memo?: string;
|
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
|
@@ -71,6 +71,7 @@ import type {
|
|
|
71
71
|
UnpairingProcessResult,
|
|
72
72
|
VerifyShareRequestMessage,
|
|
73
73
|
VerifyShareResponseMessage,
|
|
74
|
+
WeightedChannel,
|
|
74
75
|
} from './types';
|
|
75
76
|
|
|
76
77
|
/** Shape of the `__DeRec` host object: every member is a plain callable, since
|
|
@@ -459,11 +460,13 @@ const pairing = {
|
|
|
459
460
|
mlkem_encapsulation_key: ArrayBuffer;
|
|
460
461
|
ecies_public_key: ArrayBuffer;
|
|
461
462
|
nonce: bigint;
|
|
463
|
+
fingerprint_commitment: ArrayBuffer;
|
|
462
464
|
};
|
|
463
465
|
return {
|
|
464
466
|
mlkem_encapsulation_key: bytes(result.mlkem_encapsulation_key),
|
|
465
467
|
ecies_public_key: bytes(result.ecies_public_key),
|
|
466
468
|
nonce: result.nonce,
|
|
469
|
+
fingerprint_commitment: bytes(result.fingerprint_commitment),
|
|
467
470
|
};
|
|
468
471
|
},
|
|
469
472
|
|
|
@@ -494,11 +497,13 @@ const pairing = {
|
|
|
494
497
|
mlkem_encapsulation_key: ArrayBuffer;
|
|
495
498
|
ecies_public_key: ArrayBuffer;
|
|
496
499
|
nonce: bigint;
|
|
500
|
+
fingerprint_commitment: ArrayBuffer;
|
|
497
501
|
};
|
|
498
502
|
return {
|
|
499
503
|
mlkem_encapsulation_key: bytes(result.mlkem_encapsulation_key),
|
|
500
504
|
ecies_public_key: bytes(result.ecies_public_key),
|
|
501
505
|
nonce: result.nonce,
|
|
506
|
+
fingerprint_commitment: bytes(result.fingerprint_commitment),
|
|
502
507
|
};
|
|
503
508
|
},
|
|
504
509
|
},
|
|
@@ -593,13 +598,23 @@ const recovery = {
|
|
|
593
598
|
const sharing = {
|
|
594
599
|
request: {
|
|
595
600
|
split(
|
|
596
|
-
channels:
|
|
601
|
+
channels: WeightedChannel[],
|
|
597
602
|
secret_id: bigint,
|
|
598
603
|
version: number,
|
|
599
604
|
secret_data: Uint8Array,
|
|
600
605
|
threshold: number,
|
|
601
606
|
): SplitResult {
|
|
602
|
-
const
|
|
607
|
+
const ids = channels.map(([channelId]) => BigInt(channelId));
|
|
608
|
+
const weights = channels.map(([, weight]) => weight);
|
|
609
|
+
const packed = call(
|
|
610
|
+
'protect_secret',
|
|
611
|
+
secret_id,
|
|
612
|
+
secret_data,
|
|
613
|
+
ids,
|
|
614
|
+
weights,
|
|
615
|
+
threshold,
|
|
616
|
+
version,
|
|
617
|
+
);
|
|
603
618
|
const shares = new Map<bigint, CommittedDeRecShare>();
|
|
604
619
|
for (const entry of decodeCommittedShareEntries(packed as ArrayBuffer)) {
|
|
605
620
|
shares.set(
|
|
@@ -615,7 +630,7 @@ const sharing = {
|
|
|
615
630
|
version: number,
|
|
616
631
|
secret_id: bigint,
|
|
617
632
|
committed_share: CommittedDeRecShare,
|
|
618
|
-
|
|
633
|
+
keep_version: number,
|
|
619
634
|
description: string,
|
|
620
635
|
shared_key: Uint8Array,
|
|
621
636
|
reply_to?: TransportProtocol[],
|
|
@@ -626,7 +641,7 @@ const sharing = {
|
|
|
626
641
|
version,
|
|
627
642
|
secret_id,
|
|
628
643
|
encodeMessage(MessageKind.CommittedDeRecShare, committed_share),
|
|
629
|
-
|
|
644
|
+
keep_version,
|
|
630
645
|
utf8Encode(description),
|
|
631
646
|
shared_key,
|
|
632
647
|
replyTo(reply_to),
|