@@ -84,24 +84,16 @@ public class ThresholdKey {
84
84
return Metadata ( pointer: result!)
85
85
}
86
86
87
- private func initialize( import_share : String ? , input: ShareStore ? , never_initialize_new_key: Bool ? , include_local_metadata_transitions: Bool ? , use_tss : Bool = false , device_tss_share : String ? , device_tss_index : Int32 ? , tss_factor_pub : KeyPoint ? , completion: @escaping ( Result < KeyDetails , Error > ) -> Void ) {
87
+ private func initialize( import_metdata_key : String ? , input: ShareStore ? , never_initialize_new_key: Bool ? , include_local_metadata_transitions: Bool ? , completion: @escaping ( Result < KeyDetails , Error > ) -> Void ) {
88
88
tkeyQueue. async {
89
89
do {
90
90
var errorCode : Int32 = - 1
91
- var sharePointer : UnsafeMutablePointer < Int8 > ?
92
- var tssDeviceSharePointer : UnsafeMutablePointer < Int8 > ?
93
- var tssFactorPubPointer : OpaquePointer ?
94
- var device_index : Int32 = device_tss_index ?? 2
95
- if import_share != nil {
96
- sharePointer = UnsafeMutablePointer < Int8 > ( mutating: NSString ( string: import_share!) . utf8String)
97
- }
98
-
99
- if device_tss_share != nil {
100
- tssDeviceSharePointer = UnsafeMutablePointer < Int8 > ( mutating: NSString ( string: device_tss_share!) . utf8String)
101
- }
102
-
103
- if tss_factor_pub != nil {
104
- tssFactorPubPointer = tss_factor_pub!. pointer
91
+ var keyPointer : UnsafeMutablePointer < Int8 > ?
92
+ var device_index : Int32 = 2
93
+ let useTss = false
94
+
95
+ if import_metdata_key != nil {
96
+ keyPointer = UnsafeMutablePointer < Int8 > ( mutating: NSString ( string: import_metdata_key!) . utf8String)
105
97
}
106
98
107
99
var storePtr : OpaquePointer ?
@@ -114,7 +106,7 @@ public class ThresholdKey {
114
106
115
107
let curvePointer = UnsafeMutablePointer < Int8 > ( mutating: NSString ( string: self . curveN) . utf8String)
116
108
let ptr = withUnsafeMutablePointer ( to: & device_index, { tssDeviceIndexPointer in withUnsafeMutablePointer ( to: & errorCode, { error in
117
- threshold_key_initialize ( self . pointer, sharePointer , storePtr, neverInitializeNewKey, includeLocalMetadataTransitions, curvePointer, use_tss , tssDeviceSharePointer , tssDeviceIndexPointer, tssFactorPubPointer , error) } ) } )
109
+ threshold_key_initialize ( self . pointer, keyPointer , storePtr, neverInitializeNewKey, includeLocalMetadataTransitions, false , curvePointer, useTss , nil , tssDeviceIndexPointer, nil , error) } ) } )
118
110
guard errorCode == 0 else {
119
111
throw RuntimeError ( " Error in ThresholdKey Initialize " )
120
112
}
@@ -129,22 +121,18 @@ public class ThresholdKey {
129
121
/// Initializes a `ThresholdKey` object.
130
122
///
131
123
/// - Parameters:
132
- /// - import_share: Share to be imported, optional.
124
+ /// - import_metdata_key: Metadata key to be imported, optional.
133
125
/// - input: `ShareStore` to be used, optional.
134
126
/// - never_initialize_new_key: Do not initialize a new tKey if an existing one is found.
135
127
/// - include_local_matadata_transitions: Proritize existing metadata transitions over cloud fetched transitions.
136
- /// - use_tss: Whether TSS is used or not.
137
- /// - device_tss_share: Device share for TSS, optional
138
- /// - device_tss_index: Device index for TSS, optional
139
- /// - tss_factor_pub: Factor Key for TSS, optional
140
128
///
141
129
/// - Returns: `KeyDetails`
142
130
///
143
131
/// - Throws: `RuntimeError`, indicates invalid parameters.
144
- public func initialize( import_share : String ? = nil , input: ShareStore ? = nil , never_initialize_new_key: Bool ? = nil , include_local_metadata_transitions: Bool ? = nil , use_tss : Bool = false , device_tss_share : String ? = nil , device_tss_index : Int32 ? = nil , tss_factor_pub : KeyPoint ? = nil ) async throws -> KeyDetails {
132
+ public func initialize( import_metdata_key : String ? = nil , input: ShareStore ? = nil , never_initialize_new_key: Bool ? = nil , include_local_metadata_transitions: Bool ? = nil ) async throws -> KeyDetails {
145
133
return try await withCheckedThrowingContinuation {
146
134
continuation in
147
- self . initialize ( import_share : import_share , input: input, never_initialize_new_key: never_initialize_new_key, include_local_metadata_transitions: include_local_metadata_transitions, use_tss : use_tss , device_tss_share : device_tss_share , device_tss_index : device_tss_index , tss_factor_pub : tss_factor_pub ) {
135
+ self . initialize ( import_metdata_key : import_metdata_key , input: input, never_initialize_new_key: never_initialize_new_key, include_local_metadata_transitions: include_local_metadata_transitions ) {
148
136
result in
149
137
switch result {
150
138
case let . success( result) :
@@ -174,7 +162,9 @@ public class ThresholdKey {
174
162
}
175
163
}
176
164
177
- /// Reconstructs the private key, this assumes that the number of shares inserted into the `ThrehsoldKey` are equal or greater than the threshold.
165
+ /// Reconstructs the private key, this assumes that the number of shares inserted into the `ThresholdKey` are equal or greater than the threshold.
166
+ ///
167
+ /// - Returns: `KeyReconstructionDetails`
178
168
///
179
169
/// - Throws: `RuntimeError`.
180
170
public func reconstruct( ) async throws -> KeyReconstructionDetails {
@@ -227,18 +217,15 @@ public class ThresholdKey {
227
217
return ShareStoreArray ( pointer: result!)
228
218
}
229
219
230
- private func generate_new_share( use_tss : Bool = false , tss_options : TssOptions ? = nil , completion: @escaping ( Result < GenerateShareStoreResult , Error > ) -> Void ) {
220
+ private func generate_new_share( completion: @escaping ( Result < GenerateShareStoreResult , Error > ) -> Void ) {
231
221
tkeyQueue. async {
232
222
do {
233
- var options : OpaquePointer ?
234
- if tss_options != nil {
235
- options = tss_options!. pointer
236
- }
223
+ let useTss = false
237
224
238
225
var errorCode : Int32 = - 1
239
226
let curvePointer = UnsafeMutablePointer < Int8 > ( mutating: ( self . curveN as NSString ) . utf8String)
240
227
let ptr = withUnsafeMutablePointer ( to: & errorCode, { error in
241
- threshold_key_generate_share ( self . pointer, curvePointer, use_tss , options , error)
228
+ threshold_key_generate_share ( self . pointer, curvePointer, useTss , nil , error)
242
229
} )
243
230
guard errorCode == 0 else {
244
231
throw RuntimeError ( " Error in ThresholdKey generate_new_share " )
@@ -254,16 +241,12 @@ public class ThresholdKey {
254
241
255
242
/// Generates a new share.
256
243
///
257
- /// - Parameters:
258
- /// - use_tss: Whether TSS should be used or not..
259
- /// - tss_options: TSS options that should be used for TSS.
260
- ///
261
- /// - Returns: `GenerateShareStoreArray`
244
+ /// - Returns: `GenerateShareStoreResult`
262
245
///
263
246
/// - Throws: `RuntimeError`, indicates invalid `ThresholdKey`.
264
- public func generate_new_share( use_tss : Bool = false , tss_options : TssOptions ? = nil ) async throws -> GenerateShareStoreResult {
247
+ public func generate_new_share( ) async throws -> GenerateShareStoreResult {
265
248
return try await withCheckedThrowingContinuation {
266
- continuation in self . generate_new_share ( use_tss : use_tss , tss_options : tss_options ) {
249
+ continuation in self . generate_new_share ( ) {
267
250
result in
268
251
switch result {
269
252
case let . success( result) :
@@ -275,18 +258,17 @@ public class ThresholdKey {
275
258
}
276
259
}
277
260
278
- private func delete_share( share_index: String , use_tss : Bool = false , tss_options : TssOptions ? = nil , completion: @escaping ( Result < Void , Error > ) -> Void ) {
261
+ private func delete_share( share_index: String , completion: @escaping ( Result < Void , Error > ) -> Void ) {
279
262
tkeyQueue. async {
280
263
do {
281
264
var errorCode : Int32 = - 1
282
265
let curvePointer = UnsafeMutablePointer < Int8 > ( mutating: ( self . curveN as NSString ) . utf8String)
283
266
let shareIndexPointer = UnsafeMutablePointer < Int8 > ( mutating: ( share_index as NSString ) . utf8String)
284
- var options : OpaquePointer ?
285
- if tss_options != nil {
286
- options = tss_options!. pointer
287
- }
267
+
268
+ let useTss = false
269
+
288
270
withUnsafeMutablePointer ( to: & errorCode, { error in
289
- threshold_key_delete_share ( self . pointer, shareIndexPointer, curvePointer, use_tss , options , error)
271
+ threshold_key_delete_share ( self . pointer, shareIndexPointer, curvePointer, useTss , nil , error)
290
272
} )
291
273
guard errorCode == 0 else {
292
274
throw RuntimeError ( " Error in Threshold while Deleting share " )
@@ -301,10 +283,8 @@ public class ThresholdKey {
301
283
/// Deletes a share at the specified index. Caution is advised to not try delete a share that would prevent the total number of shares being below the threshold.
302
284
/// - Parameters:
303
285
/// - share_index: Share index to be deleted.
304
- /// - use_tss: Whether TSS should be used or not..
305
- /// - tss_options: TSS options that should be used for TSS.
306
286
/// - Throws: `RuntimeError`, indicates invalid share index or invalid `ThresholdKey`.
307
- public func delete_share( share_index: String , use_tss : Bool = false , tss_options : TssOptions ? = nil ) async throws {
287
+ public func delete_share( share_index: String ) async throws {
308
288
return try await withCheckedThrowingContinuation {
309
289
continuation in
310
290
self . delete_share ( share_index: share_index) {
@@ -576,7 +556,7 @@ public class ThresholdKey {
576
556
577
557
/// Retrieves all share indexes for a `ThresholdKey`.
578
558
///
579
- /// - Returns: Array of ` String`
559
+ /// - Returns: Array of String
580
560
///
581
561
/// - Throws: `RuntimeError`, indicates invalid `ThresholdKey`.
582
562
public func get_shares_indexes( ) throws -> [ String ] {
@@ -1067,6 +1047,14 @@ public class ThresholdKey {
1067
1047
}
1068
1048
}
1069
1049
1050
+ /// Function to assign a public key to the service provider, used only for TSS
1051
+ ///
1052
+ /// - Parameters:
1053
+ /// - tag: The tss tag
1054
+ /// - nonce: The tss nonce
1055
+ /// - public_key: The pulic key to be assigned
1056
+ ///
1057
+ /// - Throws: `RuntimeError`, indicates invalid parameters or invalid `ThresholdKey`.
1070
1058
public func service_provider_assign_public_key( tag: String , nonce: String , public_key: String ) throws {
1071
1059
var errorCode : Int32 = - 1
1072
1060
let tagPointer = UnsafeMutablePointer < Int8 > ( mutating: NSString ( string: tag) . utf8String)
@@ -1078,6 +1066,12 @@ public class ThresholdKey {
1078
1066
}
1079
1067
}
1080
1068
1069
+
1070
+ /// Function to get all tss tags
1071
+ ///
1072
+ /// - Returns: Array of String
1073
+ ///
1074
+ /// - Throws: `RuntimeError`, indicates invalid parameters or invalid `ThresholdKey`.
1081
1075
public func get_all_tss_tags( ) throws -> [ String ] {
1082
1076
var errorCode : Int32 = - 1
1083
1077
@@ -1097,7 +1091,12 @@ public class ThresholdKey {
1097
1091
1098
1092
return result_vec
1099
1093
}
1100
-
1094
+
1095
+ /// Function to get extended verifier id
1096
+ ///
1097
+ /// - Returns: String
1098
+ ///
1099
+ /// - Throws: `RuntimeError`, indicates invalid parameters or invalid `ThresholdKey`.
1101
1100
public func get_extended_verifier_id( ) throws -> String {
1102
1101
var errorCode : Int32 = - 1
1103
1102
0 commit comments