@@ -86,19 +86,19 @@ extension SECP256K1 {
86
86
internal static func recoverPublicKey( hash: Data , recoverableSignature: inout secp256k1_ecdsa_recoverable_signature ) -> secp256k1_pubkey ? {
87
87
guard let context = context, hash. count == 32 else { return nil }
88
88
var publicKey : secp256k1_pubkey = secp256k1_pubkey ( )
89
- let result = hash. withUnsafeBytes ( { ( hashRawBufferPointer: UnsafeRawBufferPointer ) -> Int32 ? in
89
+ let result = hash. withUnsafeBytes { ( hashRawBufferPointer: UnsafeRawBufferPointer ) -> Int32 ? in
90
90
if let hashRawPointer = hashRawBufferPointer. baseAddress, hashRawBufferPointer. count > 0 {
91
91
let hashPointer = hashRawPointer. assumingMemoryBound ( to: UInt8 . self)
92
- return withUnsafePointer ( to: & recoverableSignature, { ( signaturePointer: UnsafePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
93
- withUnsafeMutablePointer ( to: & publicKey, { ( pubKeyPtr: UnsafeMutablePointer < secp256k1_pubkey > ) -> Int32 in
92
+ return withUnsafePointer ( to: & recoverableSignature) { ( signaturePointer: UnsafePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
93
+ withUnsafeMutablePointer ( to: & publicKey) { ( pubKeyPtr: UnsafeMutablePointer < secp256k1_pubkey > ) -> Int32 in
94
94
let res = secp256k1_ecdsa_recover ( context, pubKeyPtr, signaturePointer, hashPointer)
95
95
return res
96
- } )
97
- } )
96
+ }
97
+ }
98
98
} else {
99
99
return nil
100
100
}
101
- } )
101
+ }
102
102
guard let res = result, res != 0 else {
103
103
return nil
104
104
}
@@ -131,16 +131,16 @@ extension SECP256K1 {
131
131
let result = serializedPubkey. withUnsafeMutableBytes { serializedPubkeyRawBuffPointer -> Int32 ? in
132
132
if let serializedPkRawPointer = serializedPubkeyRawBuffPointer. baseAddress, serializedPubkeyRawBuffPointer. count > 0 {
133
133
let serializedPubkeyPointer = serializedPkRawPointer. assumingMemoryBound ( to: UInt8 . self)
134
- return withUnsafeMutablePointer ( to: & keyLength, { ( keyPtr: UnsafeMutablePointer < Int > ) -> Int32 in
135
- withUnsafeMutablePointer ( to: & publicKey, { ( pubKeyPtr: UnsafeMutablePointer < secp256k1_pubkey > ) -> Int32 in
134
+ return withUnsafeMutablePointer ( to: & keyLength) { ( keyPtr: UnsafeMutablePointer < Int > ) -> Int32 in
135
+ withUnsafeMutablePointer ( to: & publicKey) { ( pubKeyPtr: UnsafeMutablePointer < secp256k1_pubkey > ) -> Int32 in
136
136
let res = secp256k1_ec_pubkey_serialize ( context,
137
137
serializedPubkeyPointer,
138
138
keyPtr,
139
139
pubKeyPtr,
140
140
UInt32 ( compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED) )
141
141
return res
142
- } )
143
- } )
142
+ }
143
+ }
144
144
} else {
145
145
return nil
146
146
}
@@ -188,10 +188,10 @@ extension SECP256K1 {
188
188
let result = serializedSignature. withUnsafeBytes { ( serRawBufferPtr: UnsafeRawBufferPointer ) -> Int32 ? in
189
189
if let serRawPtr = serRawBufferPtr. baseAddress, serRawBufferPtr. count > 0 {
190
190
let serPtr = serRawPtr. assumingMemoryBound ( to: UInt8 . self)
191
- return withUnsafeMutablePointer ( to: & recoverableSignature, { ( signaturePointer: UnsafeMutablePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
191
+ return withUnsafeMutablePointer ( to: & recoverableSignature) { ( signaturePointer: UnsafeMutablePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
192
192
let res = secp256k1_ecdsa_recoverable_signature_parse_compact ( context, signaturePointer, serPtr, v)
193
193
return res
194
- } )
194
+ }
195
195
} else {
196
196
return nil
197
197
}
@@ -210,10 +210,10 @@ extension SECP256K1 {
210
210
if let serSignatureRawPointer = serSignatureRawBufferPointer. baseAddress, serSignatureRawBufferPointer. count > 0 {
211
211
let serSignaturePointer = serSignatureRawPointer. assumingMemoryBound ( to: UInt8 . self)
212
212
return withUnsafePointer ( to: & recoverableSignature) { ( signaturePointer: UnsafePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
213
- withUnsafeMutablePointer ( to: & v, { ( vPtr: UnsafeMutablePointer < Int32 > ) -> Int32 in
213
+ withUnsafeMutablePointer ( to: & v) { ( vPtr: UnsafeMutablePointer < Int32 > ) -> Int32 in
214
214
let res = secp256k1_ecdsa_recoverable_signature_serialize_compact ( context, serSignaturePointer, vPtr, signaturePointer)
215
215
return res
216
- } )
216
+ }
217
217
}
218
218
} else {
219
219
return nil
@@ -244,24 +244,24 @@ extension SECP256K1 {
244
244
let result = hash. withUnsafeBytes { hashRBPointer -> Int32 ? in
245
245
if let hashRPointer = hashRBPointer. baseAddress, hashRBPointer. count > 0 {
246
246
let hashPointer = hashRPointer. assumingMemoryBound ( to: UInt8 . self)
247
- return privateKey. withUnsafeBytes ( { privateKeyRBPointer -> Int32 ? in
247
+ return privateKey. withUnsafeBytes { privateKeyRBPointer -> Int32 ? in
248
248
if let privateKeyRPointer = privateKeyRBPointer. baseAddress, privateKeyRBPointer. count > 0 {
249
249
let privateKeyPointer = privateKeyRPointer. assumingMemoryBound ( to: UInt8 . self)
250
- return extraEntropy. withUnsafeBytes ( { extraEntropyRBPointer -> Int32 ? in
250
+ return extraEntropy. withUnsafeBytes { extraEntropyRBPointer -> Int32 ? in
251
251
if let extraEntropyRPointer = extraEntropyRBPointer. baseAddress, extraEntropyRBPointer. count > 0 {
252
252
let extraEntropyPointer = extraEntropyRPointer. assumingMemoryBound ( to: UInt8 . self)
253
- return withUnsafeMutablePointer ( to: & recoverableSignature, { ( recSignaturePtr: UnsafeMutablePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
253
+ return withUnsafeMutablePointer ( to: & recoverableSignature) { ( recSignaturePtr: UnsafeMutablePointer < secp256k1_ecdsa_recoverable_signature > ) -> Int32 in
254
254
let res = secp256k1_ecdsa_sign_recoverable ( context, recSignaturePtr, hashPointer, privateKeyPointer, nil , useExtraEntropy ? extraEntropyPointer : nil )
255
255
return res
256
- } )
256
+ }
257
257
} else {
258
258
return nil
259
259
}
260
- } )
260
+ }
261
261
} else {
262
262
return nil
263
263
}
264
- } )
264
+ }
265
265
} else {
266
266
return nil
267
267
}
0 commit comments