File tree Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Original file line number Diff line number Diff line change @@ -206,22 +206,8 @@ public struct Utilities {
206
206
///
207
207
/// Input parameters should be Data objects.
208
208
public static func personalECRecover( _ personalMessage: Data , signature: Data ) -> EthereumAddress ? {
209
- if signature. count != 65 { return nil }
210
- let rData = signature [ 0 ..< 32 ] . bytes
211
- let sData = signature [ 32 ..< 64 ] . bytes
212
- var vData = signature [ 64 ]
213
- if vData >= 27 && vData <= 30 {
214
- vData -= 27
215
- } else if vData >= 31 && vData <= 34 {
216
- vData -= 31
217
- } else if vData >= 35 && vData <= 38 {
218
- vData -= 35
219
- }
220
-
221
- guard let signatureData = SECP256K1 . marshalSignature ( v: vData, r: rData, s: sData) else { return nil }
222
209
guard let hash = Utilities . hashPersonalMessage ( personalMessage) else { return nil }
223
- guard let publicKey = SECP256K1 . recoverPublicKey ( hash: hash, signature: signatureData) else { return nil }
224
- return Utilities . publicToAddress ( publicKey)
210
+ return hashECRecover ( hash: hash, signature: signature)
225
211
}
226
212
227
213
/// Recover the Ethereum address from recoverable secp256k1 signature.
You can’t perform that action at this time.
0 commit comments