diff --git a/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt b/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt index b825883de8..520b54588c 100644 --- a/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt +++ b/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt @@ -260,14 +260,16 @@ object WireTransactionSerializer : Serializer() { @ThreadSafe object Ed25519PrivateKeySerializer : Serializer() { val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512) + val seedSize = 64 override fun write(kryo: Kryo, output: Output, obj: EdDSAPrivateKey) { check(obj.params.equals(ed25519Curve)) - kryo.writeClassAndObject(output, obj.seed) + check(obj.seed.size == seedSize) + output.writeBytes(obj.seed) } override fun read(kryo: Kryo, input: Input, type: Class): EdDSAPrivateKey { - val seed = kryo.readClassAndObject(input) as ByteArray + val seed = input.readBytes(seedSize) return EdDSAPrivateKey(EdDSAPrivateKeySpec(seed, ed25519Curve)) } } @@ -276,14 +278,16 @@ object Ed25519PrivateKeySerializer : Serializer() { @ThreadSafe object Ed25519PublicKeySerializer : Serializer() { val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512) + val ASize = 32 override fun write(kryo: Kryo, output: Output, obj: EdDSAPublicKey) { check(obj.params.equals(ed25519Curve)) - kryo.writeClassAndObject(output, obj.abyte) + check(obj.abyte.size == ASize) + output.writeBytes(obj.abyte) } override fun read(kryo: Kryo, input: Input, type: Class): EdDSAPublicKey { - val A = kryo.readClassAndObject(input) as ByteArray + val A = input.readBytes(ASize) return EdDSAPublicKey(EdDSAPublicKeySpec(A, ed25519Curve)) } }