@@ -15,7 +15,7 @@ public enum TransactionSignerError: Error {
15
15
}
16
16
17
17
public struct Web3Signer {
18
- public static func signTX( transaction: inout EthereumTransaction , keystore: AbstractKeystore , account: EthereumAddress , password: String , useExtraEntropy: Bool = true ) throws {
18
+ public static func signTX( transaction: inout EthereumTransaction , keystore: AbstractKeystore , account: EthereumAddress , password: String , useExtraEntropy: Bool = false ) throws {
19
19
var privateKey = try keystore. UNSAFE_getPrivateKeyData ( password: password, account: account)
20
20
defer { Data . zero ( & privateKey) }
21
21
if ( transaction. chainID != nil ) {
@@ -24,12 +24,12 @@ public struct Web3Signer {
24
24
try FallbackSigner . sign ( transaction: & transaction, privateKey: privateKey, useExtraEntropy: useExtraEntropy)
25
25
}
26
26
}
27
- public static func signIntermediate( intermediate: inout TransactionIntermediate , keystore: AbstractKeystore , account: EthereumAddress , password: String , useExtraEntropy: Bool = true ) throws {
27
+ public static func signIntermediate( intermediate: inout TransactionIntermediate , keystore: AbstractKeystore , account: EthereumAddress , password: String , useExtraEntropy: Bool = false ) throws {
28
28
var tx = intermediate. transaction
29
29
try Web3Signer . signTX ( transaction: & tx, keystore: keystore, account: account, password: password, useExtraEntropy: useExtraEntropy)
30
30
intermediate. transaction = tx
31
31
}
32
- public static func signPersonalMessage( _ personalMessage: Data , keystore: AbstractKeystore , account: EthereumAddress , password: String , useExtraEntropy: Bool = true ) throws -> Data ? {
32
+ public static func signPersonalMessage( _ personalMessage: Data , keystore: AbstractKeystore , account: EthereumAddress , password: String , useExtraEntropy: Bool = false ) throws -> Data ? {
33
33
var privateKey = try keystore. UNSAFE_getPrivateKeyData ( password: password, account: account)
34
34
defer { Data . zero ( & privateKey) }
35
35
guard let hash = Web3 . Utils. hashPersonalMessage ( personalMessage) else { return nil }
@@ -38,7 +38,7 @@ public struct Web3Signer {
38
38
}
39
39
40
40
public struct EIP155Signer {
41
- public static func sign( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = true ) throws {
41
+ public static func sign( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = false ) throws {
42
42
for _ in 0 ..< 1024 {
43
43
let result = self . attemptSignature ( transaction: & transaction, privateKey: privateKey, useExtraEntropy: useExtraEntropy)
44
44
if ( result) {
@@ -48,7 +48,7 @@ public struct Web3Signer {
48
48
throw AbstractKeystoreError . invalidAccountError
49
49
}
50
50
51
- private static func attemptSignature( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = true ) -> Bool {
51
+ private static func attemptSignature( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = false ) -> Bool {
52
52
guard let chainID = transaction. chainID else { return false }
53
53
guard let hash = transaction. hashForSignature ( chainID: chainID) else { return false }
54
54
let signature = SECP256K1 . signForRecovery ( hash: hash, privateKey: privateKey, useExtraEntropy: useExtraEntropy)
@@ -69,7 +69,7 @@ public struct Web3Signer {
69
69
}
70
70
71
71
public struct FallbackSigner {
72
- public static func sign( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = true ) throws {
72
+ public static func sign( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = false ) throws {
73
73
for _ in 0 ..< 1024 {
74
74
let result = self . attemptSignature ( transaction: & transaction, privateKey: privateKey)
75
75
if ( result) {
@@ -79,7 +79,7 @@ public struct Web3Signer {
79
79
throw AbstractKeystoreError . invalidAccountError
80
80
}
81
81
82
- private static func attemptSignature( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = true ) -> Bool {
82
+ private static func attemptSignature( transaction: inout EthereumTransaction , privateKey: Data , useExtraEntropy: Bool = false ) -> Bool {
83
83
guard let hash = transaction. hashForSignature ( chainID: nil ) else { return false }
84
84
let signature = SECP256K1 . signForRecovery ( hash: hash, privateKey: privateKey, useExtraEntropy: useExtraEntropy)
85
85
guard let serializedSignature = signature. serializedSignature else { return false }
0 commit comments