mirror of
https://github.com/corda/corda.git
synced 2024-12-23 14:52:29 +00:00
core: switch to static size bytearray serialization of keypairs
This commit is contained in:
parent
22567d11b5
commit
376b73b823
@ -260,14 +260,16 @@ object WireTransactionSerializer : Serializer<WireTransaction>() {
|
|||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
object Ed25519PrivateKeySerializer : Serializer<EdDSAPrivateKey>() {
|
object Ed25519PrivateKeySerializer : Serializer<EdDSAPrivateKey>() {
|
||||||
val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512)
|
val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512)
|
||||||
|
val seedSize = 64
|
||||||
|
|
||||||
override fun write(kryo: Kryo, output: Output, obj: EdDSAPrivateKey) {
|
override fun write(kryo: Kryo, output: Output, obj: EdDSAPrivateKey) {
|
||||||
check(obj.params.equals(ed25519Curve))
|
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>): EdDSAPrivateKey {
|
override fun read(kryo: Kryo, input: Input, type: Class<EdDSAPrivateKey>): EdDSAPrivateKey {
|
||||||
val seed = kryo.readClassAndObject(input) as ByteArray
|
val seed = input.readBytes(seedSize)
|
||||||
return EdDSAPrivateKey(EdDSAPrivateKeySpec(seed, ed25519Curve))
|
return EdDSAPrivateKey(EdDSAPrivateKeySpec(seed, ed25519Curve))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,14 +278,16 @@ object Ed25519PrivateKeySerializer : Serializer<EdDSAPrivateKey>() {
|
|||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
object Ed25519PublicKeySerializer : Serializer<EdDSAPublicKey>() {
|
object Ed25519PublicKeySerializer : Serializer<EdDSAPublicKey>() {
|
||||||
val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512)
|
val ed25519Curve = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512)
|
||||||
|
val ASize = 32
|
||||||
|
|
||||||
override fun write(kryo: Kryo, output: Output, obj: EdDSAPublicKey) {
|
override fun write(kryo: Kryo, output: Output, obj: EdDSAPublicKey) {
|
||||||
check(obj.params.equals(ed25519Curve))
|
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>): EdDSAPublicKey {
|
override fun read(kryo: Kryo, input: Input, type: Class<EdDSAPublicKey>): EdDSAPublicKey {
|
||||||
val A = kryo.readClassAndObject(input) as ByteArray
|
val A = input.readBytes(ASize)
|
||||||
return EdDSAPublicKey(EdDSAPublicKeySpec(A, ed25519Curve))
|
return EdDSAPublicKey(EdDSAPublicKeySpec(A, ed25519Curve))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user