2
2
// Created by Alex Vlasov.
3
3
// Copyright © 2018 Alex Vlasov. All rights reserved.
4
4
//
5
- // Refactor to support EIP-2718 Enveloping by Mark Loit 2022
5
+ // Refactor to support EIP-2718 Enveloping by Mark Loit 2022
6
6
7
7
import Foundation
8
8
import BigInt
@@ -27,7 +27,9 @@ public struct Web3Signer {
27
27
var privateKey = try keystore. UNSAFE_getPrivateKeyData ( password: password, account: account)
28
28
defer { Data . zero ( & privateKey) }
29
29
guard let hash = Utilities . hashPersonalMessage ( personalMessage) else { return nil }
30
- let ( compressedSignature, _) = SECP256K1 . signForRecovery ( hash: hash, privateKey: privateKey, useExtraEntropy: useExtraEntropy)
30
+ let ( compressedSignature, _) = SECP256K1 . signForRecovery ( hash: hash,
31
+ privateKey: privateKey,
32
+ useExtraEntropy: useExtraEntropy)
31
33
return compressedSignature
32
34
}
33
35
@@ -38,15 +40,15 @@ public struct Web3Signer {
38
40
password: String ? = nil ,
39
41
chainId: BigUInt ? = nil ) throws -> Data {
40
42
41
- let domainSeparator : EIP712DomainHashable = EIP712Domain ( chainId: chainId, verifyingContract: verifyingContract)
42
-
43
- let password = password ?? " "
43
+ let domainSeparator : EIP712Hashable = EIP712Domain ( chainId: chainId, verifyingContract: verifyingContract)
44
44
let hash = try eip712encode ( domainSeparator: domainSeparator, message: eip712Hashable)
45
-
46
- guard let signature = try Web3Signer . signPersonalMessage ( hash, keystore: keystore, account: account, password: password) else {
45
+ guard let signature = try Web3Signer . signPersonalMessage ( hash,
46
+ keystore: keystore,
47
+ account: account,
48
+ password: password ?? " " )
49
+ else {
47
50
throw Web3Error . dataError
48
51
}
49
-
50
52
return signature
51
53
}
52
54
}
0 commit comments