From 4fb8a3812278b7fc63ad68672d2c66c20a1473ff Mon Sep 17 00:00:00 2001 From: Andras Slemmer Date: Thu, 4 Aug 2016 12:14:25 +0100 Subject: [PATCH] core, node: Rename Stirng.toPublicKey to parsePublicKeyBase58 --- core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt | 2 +- node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt b/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt index e45016ad5a..dcd0261f29 100644 --- a/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt +++ b/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt @@ -148,7 +148,7 @@ fun PrivateKey.signWithECDSA(bitsToSign: ByteArray, publicKey: PublicKey): Digit val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512) -fun String.toPublicKey() = EdDSAPublicKey(EdDSAPublicKeySpec(Base58.decode(this), ed25519Curve)) +fun parsePublicKeyBase58(base58String: String) = EdDSAPublicKey(EdDSAPublicKeySpec(Base58.decode(base58String), ed25519Curve)) fun PublicKey.toBase58String() = Base58.encode((this as EdDSAPublicKey).abyte) fun KeyPair.signWithECDSA(bitsToSign: ByteArray) = private.signWithECDSA(bitsToSign, public) diff --git a/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt b/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt index 128406700d..54e8224f3d 100644 --- a/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt +++ b/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt @@ -144,7 +144,7 @@ object JsonSupport { object PublicKeyDeserializer : JsonDeserializer() { override fun deserialize(parser: JsonParser, context: DeserializationContext): EdDSAPublicKey { return try { - parser.text.toPublicKey() + parsePublicKeyBase58(parser.text) } catch (e: Exception) { throw JsonParseException(parser, "Invalid public key ${parser.text}: ${e.message}") }