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 @@ -231,22 +231,8 @@ public struct Utilities {
231
231
/// Recover the Ethereum address from recoverable secp256k1 signature. Message is first hashed using the "personal hash" protocol.
232
232
/// BE WARNED - changing a message will result in different Ethereum address, but not in an error.
233
233
public static func personalECRecover( _ personalMessage: Data , signature: Data ) -> EthereumAddress ? {
234
- if signature. count != 65 { return nil }
235
- let rData = signature [ 0 ..< 32 ] . bytes
236
- let sData = signature [ 32 ..< 64 ] . bytes
237
- var vData = signature [ 64 ]
238
- if vData >= 27 && vData <= 30 {
239
- vData -= 27
240
- } else if vData >= 31 && vData <= 34 {
241
- vData -= 31
242
- } else if vData >= 35 && vData <= 38 {
243
- vData -= 35
244
- }
245
-
246
- guard let signatureData = SECP256K1 . marshalSignature ( v: vData, r: rData, s: sData) else { return nil }
247
234
guard let hash = Utilities . hashPersonalMessage ( personalMessage) else { return nil }
248
- guard let publicKey = SECP256K1 . recoverPublicKey ( hash: hash, signature: signatureData) else { return nil }
249
- return Utilities . publicToAddress ( publicKey)
235
+ return hashECRecover ( hash: hash, signature: signature)
250
236
}
251
237
252
238
/// Recover the Ethereum address from recoverable secp256k1 signature.
You can’t perform that action at this time.
0 commit comments