@@ -38,7 +38,7 @@ final class tss_client_swiftTests: XCTestCase {
3838 let hash = TSSHelpers . hashMessage ( message: token)
3939 let data = hash. data ( using: . utf8) !
4040 let msgB64 = Data ( base64Encoded: data) !
41- let serializedNodeSig = try CurveSecp256k1 . signForRecovery ( hash : msgB64 . hexString , privateKey : SecretKey ( hex: item) ) . serialize ( )
41+ let serializedNodeSig = try ECDSA . signRecoverable ( key : SecretKey ( hex: item) , hash : msgB64 . hexString ) . serialize ( )
4242 let msg : [ String : Any ] = [
4343 " data " : token,
4444 " sig " : serializedNodeSig,
@@ -75,7 +75,7 @@ final class tss_client_swiftTests: XCTestCase {
7575 var additiveShares : [ BigInt ] = [ ]
7676 var shareSum = BigInt . zero
7777 for _ in 0 ..< ( parties. count - 1 ) {
78- let shareBigUint = BigUInt ( try CurveSecp256k1 . generatePrivateKey ( ) , radix: 16 )
78+ let shareBigUint = BigUInt ( try SecretKey ( ) . serialize ( ) , radix: 16 )
7979 let shareBigInt = BigInt ( sign: . plus, magnitude: shareBigUint!)
8080 additiveShares. append ( shareBigInt)
8181 shareSum += shareBigInt
@@ -144,12 +144,12 @@ final class tss_client_swiftTests: XCTestCase {
144144
145145 private func setupMockShares( endpoints: [ String ? ] , parties: [ Int32 ] , localClientIndex: Int32 , session: String ) throws -> ( Data , Data )
146146 {
147- let privKey = try CurveSecp256k1 . generatePrivateKey ( )
148- let privKeyBigUInt = BigUInt ( privKey, radix: 16 )
147+ let privKey = SecretKey ( )
148+ let privKeyBigUInt = BigUInt ( try privKey. serialize ( ) , radix: 16 )
149149 let privKeyBigInt = BigInt ( sign: . plus, magnitude: privKeyBigUInt!)
150- let publicKey = try CurveSecp256k1 . privateToPublic ( privateKey : SecretKey ( hex : privKey ) , compressed : false )
150+ let publicKey = try privKey . toPublic ( )
151151 try distributeShares ( privKey: privKeyBigInt, parties: parties, endpoints: endpoints, localClientIndex: localClientIndex, session: session)
152- return ( Data ( hexString: privKey) !, Data ( hexString: publicKey) !)
152+ return ( Data ( hexString: try privKey. serialize ( ) ) !, Data ( hexString: try publicKey. serialize ( compressed : false ) ) !)
153153 }
154154
155155 private func generateEndpoints( parties: Int , clientIndex: Int32 ) -> ( [ String ? ] , [ String ? ] , [ Int32 ] ) {
@@ -177,7 +177,7 @@ final class tss_client_swiftTests: XCTestCase {
177177 let msg = " hello world "
178178 let msgHash = TSSHelpers . hashMessage ( message: msg)
179179 let clientIndex = Int32 ( parties - 1 )
180- let randomKey = BigUInt ( try CurveSecp256k1 . generatePrivateKey ( ) , radix: 16 )
180+ let randomKey = BigUInt ( try SecretKey ( ) . serialize ( ) , radix: 16 )
181181 let random = BigInt ( sign: . plus, magnitude: randomKey!) + BigInt( Date ( ) . timeIntervalSince1970)
182182 let randomNonce = TSSHelpers . hashMessage ( message: String ( random) )
183183 let testingRouteIdentifier = " testingShares "
@@ -207,7 +207,7 @@ final class tss_client_swiftTests: XCTestCase {
207207 let pk = try ! TSSHelpers . recoverPublicKey ( msgHash: msgHash, s: s, r: r, v: v)
208208 _ = try ! TSSHelpers . hexUncompressedPublicKey ( pubKey: Data ( hexString: pk) !, return64Bytes: true )
209209 let pkHex65 = try ! TSSHelpers . hexUncompressedPublicKey ( pubKey: Data ( hexString: pk) !, return64Bytes: false )
210- let skToPkHex = try CurveSecp256k1 . privateToPublic ( privateKey : SecretKey ( hex: privateKey. hexString) )
210+ let skToPkHex = try SecretKey ( hex: privateKey. hexString) . toPublic ( ) . serialize ( compressed : false )
211211 XCTAssert ( pkHex65 == skToPkHex)
212212
213213 print ( try ! TSSHelpers . hexSignature ( s: s, r: r, v: v) )
0 commit comments