From fca9b02f8ebe92decd55522610dd7c3cf4955263 Mon Sep 17 00:00:00 2001 From: Vitor Gabriel Date: Tue, 12 Mar 2019 20:13:35 -0300 Subject: [PATCH 1/6] Updating ecdsa-java --- .gitignore | 7 +- README.md | 76 +++++++++++++----- message.txt | 9 +++ privateKey.pem | 8 ++ publicKey.pem | 4 + signatureBinary.txt | Bin 0 -> 71 bytes src/main/java/ReadFile.java | 19 +++++ src/main/java/VerifyKeys.java | 25 ++++++ .../com/starkbank/ellipticcurve/Ecdsa.java | 2 +- .../com/starkbank/ellipticcurve/Math.java | 2 + .../starkbank/ellipticcurve/utils/Base64.java | 2 +- .../ellipticcurve/utils/ByteString.java | 7 +- .../starkbank/ellipticcurve/utils/Der.java | 6 +- .../starkbank/ellipticcurve/utils/File.java | 42 ++++++++++ src/main/java/message.txt | 1 + src/main/java/privateKey.pem | 8 ++ src/main/java/publicKey.pem | 4 + src/main/java/signatureBinary.txt | Bin 0 -> 71 bytes 18 files changed, 190 insertions(+), 32 deletions(-) create mode 100644 message.txt create mode 100644 privateKey.pem create mode 100644 publicKey.pem create mode 100644 signatureBinary.txt create mode 100644 src/main/java/ReadFile.java create mode 100644 src/main/java/VerifyKeys.java create mode 100644 src/main/java/com/starkbank/ellipticcurve/utils/File.java create mode 100644 src/main/java/message.txt create mode 100644 src/main/java/privateKey.pem create mode 100644 src/main/java/publicKey.pem create mode 100644 src/main/java/signatureBinary.txt diff --git a/.gitignore b/.gitignore index 8a14b3b..40e0b21 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,9 @@ nb-configuration.xml ########################## ## OS X ########################## -.DS_Store \ No newline at end of file +.DS_Store + +########################## +## Example Files +########################## +src/main/java/Generate* diff --git a/README.md b/README.md index aae9f55..cd9f531 100644 --- a/README.md +++ b/README.md @@ -19,19 +19,32 @@ We currently support `secp256k1`, but it's super easy to add more curves to the How to use it: ```java -// Generate Keys -PrivateKey privateKey = new PrivateKey(); -PublicKey publicKey = privateKey.publicKey(); +import com.starkbank.ellipticcurve.PrivateKey; +import com.starkbank.ellipticcurve.PublicKey; +import com.starkbank.ellipticcurve.Signature; +import com.starkbank.ellipticcurve.Ecdsa; -String message = "My test message"; +public class GenerateKeys{ -// Generate Signature -Signature signature = Ecsda.sign(message, privateKey); -// Verify if signature is valid -System.out.println(Ecsda.verify(message, signature, publicKey)); -``` + public static void main(String[] args){ + // Generate Keys + PrivateKey pvtKey = new PrivateKey(); + PublicKey publicKey = pvtKey.publicKey(); + + String message = "Testing message"; + // Generate Signature + Signature signature = Ecdsa.sign(message, pvtKey); + + // Verify if signature is valid + boolean verified = Ecdsa.verify(message, signature, publicKey) ; + // Return the signature verification status + System.out.println("Verified: " + verified); + + } +} +``` ### OpenSSL This library is compatible with OpenSSL, so you can use it to generate keys: @@ -50,14 +63,31 @@ openssl dgst -sha256 -sign privateKey.pem -out signatureBinary.txt message.txt It's time to verify: ```java -String publicKeyPem = new String(Files.readAllBytes(Path.get("publicKey.pem"))); -byte[] signatureBin = Files.readAllBytes(Path.get("signatureBinary.txt")); -String message = new String(Files.readAllBytes(Path.get("message.txt"))); +import com.starkbank.ellipticcurve.Ecdsa; +import com.starkbank.ellipticcurve.PublicKey; +import com.starkbank.ellipticcurve.Signature; +import com.starkbank.ellipticcurve.utils.ByteString; +import com.starkbank.ellipticcurve.utils.File; -PublicKey publicKey = PublicKey.fromPem(publicKeyPem); -Signature signature = Signature.fromDer(signatureBin); +public class VerifyKeys { -System.out.println(Ecdsa.verify(message, signature, publicKey)); + + public static void main(String[] args){ + // Read files + String publicKeyPem = File.read("publicKey.pem"); + byte[] signatureBin = File.readBytes("signatureBinary.txt"); + String message = File.read("message.txt"); + + ByteString byteString = new ByteString(signatureBin); + + PublicKey publicKey = PublicKey.fromPem(publicKeyPem); + Signature signature = Signature.fromDer(byteString); + + // Get verification status: + boolean verified = Ecdsa.verify(message, signature, publicKey); + System.out.println("Verification status: " + verified); + } +} ``` You can also verify it on terminal: @@ -75,11 +105,21 @@ openssl base64 -in signatureBinary.txt -out signatureBase64.txt With this library, you can do it: ```java -byte[] signatureBin = Files.readAllBytes(Path.get("signatureBinary.txt")); +import com.starkbank.ellipticcurve.utils.ByteString; +import com.starkbank.ellipticcurve.Signature; +import com.starkbank.ellipticcurve.utils.File; + +public class GenerateSignature { -Signature signature = Signature.fromDer(new ByteString(signatureBin)); -System.out.println(signature.toBase64()); + public static void main(String[] args) { + // Load signature file + byte[] signaturteBin = File.readBytes("signatureBinary.txt"); + Signature signature = Signature.fromDer(new ByteString(signaturteBin)); + // Print signature + System.out.println(signature.toBase64()); + } +} ``` [Stark Bank]: https://starkbank.com diff --git a/message.txt b/message.txt new file mode 100644 index 0000000..2a2a972 --- /dev/null +++ b/message.txt @@ -0,0 +1,9 @@ +{ + "transaction": { + "amount": 5000, + "receiver": "", + "description": "Sample transfer between workspaces", + "externalId": "123456", + "tags": ["john", "smith"] + } +} \ No newline at end of file diff --git a/privateKey.pem b/privateKey.pem new file mode 100644 index 0000000..7134664 --- /dev/null +++ b/privateKey.pem @@ -0,0 +1,8 @@ +-----BEGIN EC PARAMETERS----- +BgUrgQQACg== +-----END EC PARAMETERS----- +-----BEGIN EC PRIVATE KEY----- +MHQCAQEEIGHC8GzocXd1yc0AEnS+TfB/LIFSp6ZFqsMHiRn2Zr1foAcGBSuBBAAK +oUQDQgAEdKdXQH63V3sMtXznLikMKP77Tj5D8avb5Wu3ImdRnp+abjZigzsy3H/m +ouPtq1zNhySDV/SpRzHuHbU8Gt+Snw== +-----END EC PRIVATE KEY----- diff --git a/publicKey.pem b/publicKey.pem new file mode 100644 index 0000000..93ad403 --- /dev/null +++ b/publicKey.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEdKdXQH63V3sMtXznLikMKP77Tj5D8avb +5Wu3ImdRnp+abjZigzsy3H/mouPtq1zNhySDV/SpRzHuHbU8Gt+Snw== +-----END PUBLIC KEY----- diff --git a/signatureBinary.txt b/signatureBinary.txt new file mode 100644 index 0000000000000000000000000000000000000000..c134b72eaef031535e0268378ed0fefacf907318 GIT binary patch literal 71 zcmV-N0J#4!MFJrJo$g?L(8#^|xM8J?=3SVZGPd@gk+TzH@qHIk!%8)Z0w8hC4)X4i dPZD*R@NY6jA4*OwOewYVj!*VwWo>w(-d^KsB5wcy literal 0 HcmV?d00001 diff --git a/src/main/java/ReadFile.java b/src/main/java/ReadFile.java new file mode 100644 index 0000000..a896490 --- /dev/null +++ b/src/main/java/ReadFile.java @@ -0,0 +1,19 @@ +import com.starkbank.ellipticcurve.utils.File; + +import java.io.IOException; +import java.nio.file.*; + +public class ReadFile { + + + public static void main(String[] args)throws IOException{ + + String fileName = "message.txt"; + String byteFile = "privateKey.pem"; + String byteTestFile = "signatureBinary.txt"; + File.read(fileName); + File.read(byteFile); + File.readBytes(byteTestFile); + System.out.println(File.readBytes(byteTestFile).toString()); + } +} diff --git a/src/main/java/VerifyKeys.java b/src/main/java/VerifyKeys.java new file mode 100644 index 0000000..1e1bb1c --- /dev/null +++ b/src/main/java/VerifyKeys.java @@ -0,0 +1,25 @@ +import com.starkbank.ellipticcurve.Ecdsa; +import com.starkbank.ellipticcurve.PublicKey; +import com.starkbank.ellipticcurve.Signature; +import com.starkbank.ellipticcurve.utils.ByteString; +import com.starkbank.ellipticcurve.utils.File; + +public class VerifyKeys { + + + public static void main(String[] args){ + // Read files + String publicKeyPem = File.read("publicKey.pem"); + byte[] signatureBin = File.readBytes("signatureBinary.txt"); + String message = File.read("message.txt"); + + ByteString byteString = new ByteString(signatureBin); + + PublicKey publicKey = PublicKey.fromPem(publicKeyPem); + Signature signature = Signature.fromDer(byteString); + + // Get verification status: + boolean verified = Ecdsa.verify(message, signature, publicKey); + System.out.println("Verification status: " + verified); + } +} diff --git a/src/main/java/com/starkbank/ellipticcurve/Ecdsa.java b/src/main/java/com/starkbank/ellipticcurve/Ecdsa.java index 7173b8e..47b7961 100644 --- a/src/main/java/com/starkbank/ellipticcurve/Ecdsa.java +++ b/src/main/java/com/starkbank/ellipticcurve/Ecdsa.java @@ -6,7 +6,7 @@ import java.security.NoSuchAlgorithmException; -public final class Ecdsa { +public class Ecdsa { public static Signature sign(String message, PrivateKey privateKey, MessageDigest hashfunc) { byte[] hashMessage = hashfunc.digest(message.getBytes()); diff --git a/src/main/java/com/starkbank/ellipticcurve/Math.java b/src/main/java/com/starkbank/ellipticcurve/Math.java index 9b4bb0c..f2dc1a9 100644 --- a/src/main/java/com/starkbank/ellipticcurve/Math.java +++ b/src/main/java/com/starkbank/ellipticcurve/Math.java @@ -27,6 +27,7 @@ public static Point multiply(Point p, BigInteger n, BigInteger N, BigInteger A, * @param P Prime number in the module of the equation Y^2 = X^3 + A*X + B (mod P) * @return Point that represents the sum of First and Second Point */ + public static Point add(Point p, Point q, BigInteger A, BigInteger P) { return fromJacobian(jacobianAdd(toJacobian(p), toJacobian(q), A, P), P); } @@ -66,6 +67,7 @@ public static BigInteger inv(BigInteger x, BigInteger n) { * @return Point in Jacobian coordinates */ public static Point toJacobian(Point p) { + return new Point(p.x, p.y, BigInteger.ONE); } diff --git a/src/main/java/com/starkbank/ellipticcurve/utils/Base64.java b/src/main/java/com/starkbank/ellipticcurve/utils/Base64.java index 8bf5e92..0a0e66e 100644 --- a/src/main/java/com/starkbank/ellipticcurve/utils/Base64.java +++ b/src/main/java/com/starkbank/ellipticcurve/utils/Base64.java @@ -440,7 +440,7 @@ private final static byte[] getDecodabet( int options ) { /** Defeats instantiation. */ - private Base64(){} + public Base64(){} diff --git a/src/main/java/com/starkbank/ellipticcurve/utils/ByteString.java b/src/main/java/com/starkbank/ellipticcurve/utils/ByteString.java index 1d033ed..606170e 100644 --- a/src/main/java/com/starkbank/ellipticcurve/utils/ByteString.java +++ b/src/main/java/com/starkbank/ellipticcurve/utils/ByteString.java @@ -2,12 +2,7 @@ import java.io.UnsupportedEncodingException; import java.util.Arrays; -/** - * Company: SFL LLC - * Created on 20-Jan-19 - * - * @author Taron Petrosyan - */ + public class ByteString { private byte[] bytes; diff --git a/src/main/java/com/starkbank/ellipticcurve/utils/Der.java b/src/main/java/com/starkbank/ellipticcurve/utils/Der.java index bda0f05..9602122 100644 --- a/src/main/java/com/starkbank/ellipticcurve/utils/Der.java +++ b/src/main/java/com/starkbank/ellipticcurve/utils/Der.java @@ -7,11 +7,7 @@ import static com.starkbank.ellipticcurve.utils.BinaryAscii.*; -/** - * Created on 05-Jan-19 - * - * @author Taron Petrosyan - */ + public class Der { private Der() { diff --git a/src/main/java/com/starkbank/ellipticcurve/utils/File.java b/src/main/java/com/starkbank/ellipticcurve/utils/File.java new file mode 100644 index 0000000..067ebd8 --- /dev/null +++ b/src/main/java/com/starkbank/ellipticcurve/utils/File.java @@ -0,0 +1,42 @@ +package com.starkbank.ellipticcurve.utils; + +import java.io.IOException; +import java.nio.file.*; + +/* + *This class handles the fileinput types as filename string + *If using bytearray file as "signatureBinary.txt" + *Use the readByte method + **/ +public class File { + + public static String read(String fileName) + { + String content = ""; + try + { + content = new String(Files.readAllBytes(Paths.get(fileName))); + } + catch (IOException e) + { + e.printStackTrace(); + } + return content; + } + + public static byte[] readBytes(String fileName) + { + byte[] content = null; + try + { + content = Files.readAllBytes(Paths.get(fileName)); + } + catch (IOException e) + { + e.printStackTrace(); + } + + return content; + } + +} \ No newline at end of file diff --git a/src/main/java/message.txt b/src/main/java/message.txt new file mode 100644 index 0000000..52821ea --- /dev/null +++ b/src/main/java/message.txt @@ -0,0 +1 @@ +bla bla TesTing meSSage diff --git a/src/main/java/privateKey.pem b/src/main/java/privateKey.pem new file mode 100644 index 0000000..9fccdc3 --- /dev/null +++ b/src/main/java/privateKey.pem @@ -0,0 +1,8 @@ +-----BEGIN EC PARAMETERS----- +BgUrgQQACg== +-----END EC PARAMETERS----- +-----BEGIN EC PRIVATE KEY----- +MHQCAQEEIKTydWIgf88mU1XDpEfyLWSZho04p2ucFVZRWzQMQGU6oAcGBSuBBAAK +oUQDQgAESagqufDw7OKvPgEcFi2VmN2OFfOdFDu9+bwtSzzhAFez5/TglQ8niPk8 +OEGYo7GscPMlEHOzy7LavTvcAvpEJQ== +-----END EC PRIVATE KEY----- diff --git a/src/main/java/publicKey.pem b/src/main/java/publicKey.pem new file mode 100644 index 0000000..4d5752f --- /dev/null +++ b/src/main/java/publicKey.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAESagqufDw7OKvPgEcFi2VmN2OFfOdFDu9 ++bwtSzzhAFez5/TglQ8niPk8OEGYo7GscPMlEHOzy7LavTvcAvpEJQ== +-----END PUBLIC KEY----- diff --git a/src/main/java/signatureBinary.txt b/src/main/java/signatureBinary.txt new file mode 100644 index 0000000000000000000000000000000000000000..e81bbd8c305510bdea33957ef143fbb036f9d3f3 GIT binary patch literal 71 zcmV-N0J#4!MFJpu;ggY&U1c&$T_NG=DKfdXd5hb&aToCFdBT)Q&YxHUAposfBO_wF dw4@4dYI>ywAjs$3o8CBPe(d4(MO0cUKr)qMAxQuL literal 0 HcmV?d00001 From bdef24a3eb4d15429080861ea2cd6f1593705ff5 Mon Sep 17 00:00:00 2001 From: Vitor Gabriel Date: Tue, 12 Mar 2019 20:14:55 -0300 Subject: [PATCH 2/6] Updating ecdsa-java --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 40e0b21..1e054d9 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,7 @@ nb-configuration.xml ## Example Files ########################## src/main/java/Generate* +message.txt +publicKey.pem +privateKey.pem +signatureBinary.txt From 849ee69585a360fed7f4a1c23c9e43b1f194c2b3 Mon Sep 17 00:00:00 2001 From: Vitor Gabriel Date: Tue, 12 Mar 2019 20:22:23 -0300 Subject: [PATCH 3/6] Changed README --- message.txt | 9 --------- privateKey.pem | 8 -------- publicKey.pem | 4 ---- signatureBinary.txt | Bin 71 -> 0 bytes 4 files changed, 21 deletions(-) delete mode 100644 message.txt delete mode 100644 privateKey.pem delete mode 100644 publicKey.pem delete mode 100644 signatureBinary.txt diff --git a/message.txt b/message.txt deleted file mode 100644 index 2a2a972..0000000 --- a/message.txt +++ /dev/null @@ -1,9 +0,0 @@ -{ - "transaction": { - "amount": 5000, - "receiver": "", - "description": "Sample transfer between workspaces", - "externalId": "123456", - "tags": ["john", "smith"] - } -} \ No newline at end of file diff --git a/privateKey.pem b/privateKey.pem deleted file mode 100644 index 7134664..0000000 --- a/privateKey.pem +++ /dev/null @@ -1,8 +0,0 @@ ------BEGIN EC PARAMETERS----- -BgUrgQQACg== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MHQCAQEEIGHC8GzocXd1yc0AEnS+TfB/LIFSp6ZFqsMHiRn2Zr1foAcGBSuBBAAK -oUQDQgAEdKdXQH63V3sMtXznLikMKP77Tj5D8avb5Wu3ImdRnp+abjZigzsy3H/m -ouPtq1zNhySDV/SpRzHuHbU8Gt+Snw== ------END EC PRIVATE KEY----- diff --git a/publicKey.pem b/publicKey.pem deleted file mode 100644 index 93ad403..0000000 --- a/publicKey.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEdKdXQH63V3sMtXznLikMKP77Tj5D8avb -5Wu3ImdRnp+abjZigzsy3H/mouPtq1zNhySDV/SpRzHuHbU8Gt+Snw== ------END PUBLIC KEY----- diff --git a/signatureBinary.txt b/signatureBinary.txt deleted file mode 100644 index c134b72eaef031535e0268378ed0fefacf907318..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 71 zcmV-N0J#4!MFJrJo$g?L(8#^|xM8J?=3SVZGPd@gk+TzH@qHIk!%8)Z0w8hC4)X4i dPZD*R@NY6jA4*OwOewYVj!*VwWo>w(-d^KsB5wcy From 92314083b67fc950729bc107832cc3cbdf279ad1 Mon Sep 17 00:00:00 2001 From: Vitor Gabriel Date: Tue, 12 Mar 2019 20:25:36 -0300 Subject: [PATCH 4/6] Updated README --- README.md | 4 +++- src/main/java/ReadFile.java | 19 ------------------- src/main/java/VerifyKeys.java | 25 ------------------------- src/main/java/message.txt | 1 - src/main/java/privateKey.pem | 8 -------- src/main/java/publicKey.pem | 4 ---- src/main/java/signatureBinary.txt | Bin 71 -> 0 bytes 7 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/ReadFile.java delete mode 100644 src/main/java/VerifyKeys.java delete mode 100644 src/main/java/message.txt delete mode 100644 src/main/java/privateKey.pem delete mode 100644 src/main/java/publicKey.pem delete mode 100644 src/main/java/signatureBinary.txt diff --git a/README.md b/README.md index cd9f531..b5933db 100644 --- a/README.md +++ b/README.md @@ -136,4 +136,6 @@ public class GenerateSignature { ``` ### Run all unit tests -gradle test \ No newline at end of file +```shell +gradle test +``` diff --git a/src/main/java/ReadFile.java b/src/main/java/ReadFile.java deleted file mode 100644 index a896490..0000000 --- a/src/main/java/ReadFile.java +++ /dev/null @@ -1,19 +0,0 @@ -import com.starkbank.ellipticcurve.utils.File; - -import java.io.IOException; -import java.nio.file.*; - -public class ReadFile { - - - public static void main(String[] args)throws IOException{ - - String fileName = "message.txt"; - String byteFile = "privateKey.pem"; - String byteTestFile = "signatureBinary.txt"; - File.read(fileName); - File.read(byteFile); - File.readBytes(byteTestFile); - System.out.println(File.readBytes(byteTestFile).toString()); - } -} diff --git a/src/main/java/VerifyKeys.java b/src/main/java/VerifyKeys.java deleted file mode 100644 index 1e1bb1c..0000000 --- a/src/main/java/VerifyKeys.java +++ /dev/null @@ -1,25 +0,0 @@ -import com.starkbank.ellipticcurve.Ecdsa; -import com.starkbank.ellipticcurve.PublicKey; -import com.starkbank.ellipticcurve.Signature; -import com.starkbank.ellipticcurve.utils.ByteString; -import com.starkbank.ellipticcurve.utils.File; - -public class VerifyKeys { - - - public static void main(String[] args){ - // Read files - String publicKeyPem = File.read("publicKey.pem"); - byte[] signatureBin = File.readBytes("signatureBinary.txt"); - String message = File.read("message.txt"); - - ByteString byteString = new ByteString(signatureBin); - - PublicKey publicKey = PublicKey.fromPem(publicKeyPem); - Signature signature = Signature.fromDer(byteString); - - // Get verification status: - boolean verified = Ecdsa.verify(message, signature, publicKey); - System.out.println("Verification status: " + verified); - } -} diff --git a/src/main/java/message.txt b/src/main/java/message.txt deleted file mode 100644 index 52821ea..0000000 --- a/src/main/java/message.txt +++ /dev/null @@ -1 +0,0 @@ -bla bla TesTing meSSage diff --git a/src/main/java/privateKey.pem b/src/main/java/privateKey.pem deleted file mode 100644 index 9fccdc3..0000000 --- a/src/main/java/privateKey.pem +++ /dev/null @@ -1,8 +0,0 @@ ------BEGIN EC PARAMETERS----- -BgUrgQQACg== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MHQCAQEEIKTydWIgf88mU1XDpEfyLWSZho04p2ucFVZRWzQMQGU6oAcGBSuBBAAK -oUQDQgAESagqufDw7OKvPgEcFi2VmN2OFfOdFDu9+bwtSzzhAFez5/TglQ8niPk8 -OEGYo7GscPMlEHOzy7LavTvcAvpEJQ== ------END EC PRIVATE KEY----- diff --git a/src/main/java/publicKey.pem b/src/main/java/publicKey.pem deleted file mode 100644 index 4d5752f..0000000 --- a/src/main/java/publicKey.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAESagqufDw7OKvPgEcFi2VmN2OFfOdFDu9 -+bwtSzzhAFez5/TglQ8niPk8OEGYo7GscPMlEHOzy7LavTvcAvpEJQ== ------END PUBLIC KEY----- diff --git a/src/main/java/signatureBinary.txt b/src/main/java/signatureBinary.txt deleted file mode 100644 index e81bbd8c305510bdea33957ef143fbb036f9d3f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 71 zcmV-N0J#4!MFJpu;ggY&U1c&$T_NG=DKfdXd5hb&aToCFdBT)Q&YxHUAposfBO_wF dw4@4dYI>ywAjs$3o8CBPe(d4(MO0cUKr)qMAxQuL From 1723bbc5ca3d8fc1e92e2489e387006a3c339e48 Mon Sep 17 00:00:00 2001 From: Vitor Gabriel Date: Tue, 12 Mar 2019 20:31:50 -0300 Subject: [PATCH 5/6] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b5933db..fe540e2 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ import com.starkbank.ellipticcurve.PublicKey; import com.starkbank.ellipticcurve.Signature; import com.starkbank.ellipticcurve.Ecdsa; -public class GenerateKeys{ +public class GenerateKeys{ public static void main(String[] args){ // Generate Keys @@ -69,8 +69,8 @@ import com.starkbank.ellipticcurve.Signature; import com.starkbank.ellipticcurve.utils.ByteString; import com.starkbank.ellipticcurve.utils.File; -public class VerifyKeys { +public class VerifyKeys { public static void main(String[] args){ // Read files @@ -109,8 +109,8 @@ import com.starkbank.ellipticcurve.utils.ByteString; import com.starkbank.ellipticcurve.Signature; import com.starkbank.ellipticcurve.utils.File; -public class GenerateSignature { +public class GenerateSignature { public static void main(String[] args) { // Load signature file From 388a846ca0ff23381f723c36d216f569dd69e631 Mon Sep 17 00:00:00 2001 From: Vitor Gabriel Date: Tue, 12 Mar 2019 20:35:24 -0300 Subject: [PATCH 6/6] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fe540e2..a5e55a4 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,12 @@ public class GenerateKeys{ public static void main(String[] args){ // Generate Keys - PrivateKey pvtKey = new PrivateKey(); - PublicKey publicKey = pvtKey.publicKey(); + PrivateKey privateKey = new PrivateKey(); + PublicKey publicKey = privateKey.publicKey(); String message = "Testing message"; // Generate Signature - Signature signature = Ecdsa.sign(message, pvtKey); + Signature signature = Ecdsa.sign(message, privateKey); // Verify if signature is valid boolean verified = Ecdsa.verify(message, signature, publicKey) ;