From b0d42efb7c7fefa607a8e77801b9153c97a73371 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Tue, 20 Aug 2024 10:14:56 -0700 Subject: [PATCH] Schnorr.kt,Ecdsa.kt: Use println and string interpolation This makes for more readable/idiomatic Kotlin --- .../java/org/bitcoinj/secp/kotlin/examples/Ecdsa.kt | 10 +++++----- .../java/org/bitcoinj/secp/kotlin/examples/Schnorr.kt | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Ecdsa.kt b/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Ecdsa.kt index 948707b..14e4e7f 100644 --- a/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Ecdsa.kt +++ b/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Ecdsa.kt @@ -69,11 +69,11 @@ object Ecdsa { /* Verify a signature. This will return true if it's valid and false if it's not. */ val is_signature_valid = secp.ecdsaVerify(sig2, msg_hash, pubkey2).get() - System.out.printf("Is the signature valid? %s\n", is_signature_valid) - System.out.printf("Secret Key: %s\n", privKey.s.toString(16)) - System.out.printf("Public Key (as ECPoint): %s\n", pubkey) - System.out.printf("Public Key (Compressed): %s\n", formatter.formatHex(compressed_pubkey.bytes())) - System.out.printf("Signature: %s\n", formatter.formatHex(serialized_signature.bytes())) + println("Is the signature valid? $is_signature_valid") + println("Secret Key: ${privKey.s.toString(16)}") + println("Public Key (as ECPoint): $pubkey") + println("Public Key (Compressed): ${formatter.formatHex(compressed_pubkey.bytes())}") + println("Signature: ${formatter.formatHex(serialized_signature.bytes())}") /* It's best practice to try to clear secrets from memory after using them. * This is done because some bugs can allow an attacker to leak memory, for diff --git a/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Schnorr.kt b/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Schnorr.kt index b33f1be..eb8af45 100644 --- a/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Schnorr.kt +++ b/secp-examples-kotlin/src/main/java/org/bitcoinj/secp/kotlin/examples/Schnorr.kt @@ -58,10 +58,10 @@ object Schnorr { val is_signature_valid = secp.schnorrSigVerify(signature, msg_hash2, xOnly2).get() - System.out.printf("Is the signature valid? %s\n", is_signature_valid) - System.out.printf("Secret Key: %s\n", keyPair.s.toString(16)) - System.out.printf("Public Key (as ECPoint): %s\n", xOnly2) - System.out.printf("Signature: %s\n", formatter.formatHex(signature)) + println("Is the signature valid? $is_signature_valid") + println("Secret Key: ${keyPair.s.toString(16)}") + println("Public Key (as ECPoint): $xOnly2") + println("Signature: ${formatter.formatHex(signature)}") /* It's best practice to try to clear secrets from memory after using them. * This is done because some bugs can allow an attacker to leak memory, for