@@ -8,6 +8,7 @@ import io.iohk.ethereum.utils.ByteStringUtils
8
8
9
9
import scala .util .{Failure , Success , Try }
10
10
11
+ // scalastyle:off regex
11
12
object SignatureValidator extends App with SecureRandomBuilder with JsonMethodsImplicits {
12
13
13
14
args match {
@@ -19,16 +20,21 @@ object SignatureValidator extends App with SecureRandomBuilder with JsonMethodsI
19
20
signature.flatMap(_.publicKey(msg))
20
21
} match {
21
22
case Failure (exception) =>
22
- System .err.println(s " Can't recover public key from signature [ $sig] and msg [ $msgHash]: ERROR: ${exception.getMessage}" )
23
+ System .err.println(
24
+ s " Can't recover public key from signature [ $sig] and msg [ $msgHash]: ERROR: ${exception.getMessage}"
25
+ )
23
26
sys.exit(1 )
24
27
case Success (recoveredPk) =>
25
28
val publicKey = ByteStringUtils .string2hash(pk)
26
29
recoveredPk match {
27
30
case Some (pk) =>
28
- if (pk == publicKey) {
29
- System .err.println(s " Recovered public key [ ${ByteStringUtils .hash2string(pk)}] is the same as given one " )
31
+ if (pk == publicKey) {
32
+ System .err.println(
33
+ s " Recovered public key [ ${ByteStringUtils .hash2string(pk)}] is the same as given one "
34
+ )
30
35
} else {
31
- System .err.println(s " Recovered public key [ ${ByteStringUtils .hash2string(pk)}] is different than given [ ${ByteStringUtils .hash2string(publicKey)}] " )
36
+ System .err.println(s " Recovered public key [ ${ByteStringUtils
37
+ .hash2string(pk)}] is different than given [ ${ByteStringUtils .hash2string(publicKey)}] " )
32
38
sys.exit(1 )
33
39
}
34
40
case None =>
@@ -43,7 +49,9 @@ object SignatureValidator extends App with SecureRandomBuilder with JsonMethodsI
43
49
val hashStr = ByteStringUtils .hash2string(ByteString (hash))
44
50
val signature = ECDSASignature .sign(hash, keyPair)
45
51
val sigStr = ByteStringUtils .hash2string(signature.toBytes)
46
- System .err.println(s " Bad Input. Example usage: [signature-validator publicKey signature message_hash]. Example: [signature-validator $pkStr $sigStr $hashStr] " )
52
+ System .err.println(
53
+ s " Bad Input. Example usage: [signature-validator publicKey signature message_hash]. Example: [signature-validator $pkStr $sigStr $hashStr] "
54
+ )
47
55
sys.exit(1 )
48
56
}
49
57
}
0 commit comments