Discussion:
ECPoint and Java serialization
Andreas Schildbach
2014-07-03 13:50:48 UTC
Permalink
ECPoint instances (more specifically: ECPoint$Fp) are not serializable.
Is this a deliberate decision or has it just not been looked at?

I need to move ECPoint instances between Android components, and for
that you need some form of serialization (Java serialization is easiest,
despite the problems if you use it as a persistent store). Is there any
recommended serialization method?
o***@public.gmane.org
2014-07-04 07:08:00 UTC
Permalink
Just ASN.1-encode the EC point to convert it to a byte array.

----Ursprüngliche Nachricht----
Von : andreas-***@public.gmane.org
Datum : 03/07/2014 - 15:50 (GMT)
An : dev-crypto-***@public.gmane.org
Betreff : [dev-crypto] ECPoint and Java serialization

ECPoint instances (more specifically: ECPoint$Fp) are not serializable.
Is this a deliberate decision or has it just not been looked at?

I need to move ECPoint instances between Android components, and for
that you need some form of serialization (Java serialization is easiest,
despite the problems if you use it as a persistent store). Is there any
recommended serialization method?
Andreas Schildbach
2014-07-04 19:02:59 UTC
Permalink
I must admit that I'm a bit puzzled. I don't see any obvious methods on
ECPoint to convert that into a byte array and back. Did not find any
reference by Google either. Can you give a small code example?


On 07/04/2014 09:08 AM,
Post by o***@public.gmane.org
Just ASN.1-encode the EC point to convert it to a byte array.
----Ursprüngliche Nachricht----
Datum : 03/07/2014 - 15:50 (GMT)
Betreff : [dev-crypto] ECPoint and Java serialization
ECPoint instances (more specifically: ECPoint$Fp) are not serializable.
Is this a deliberate decision or has it just not been looked at?
I need to move ECPoint instances between Android components, and for
that you need some form of serialization (Java serialization is easiest,
despite the problems if you use it as a persistent store). Is there any
recommended serialization method?
o***@public.gmane.org
2014-07-07 20:12:08 UTC
Permalink
Try the following:
- ECPoint.Fp.getEncoded() converts the ECPoint to an ASN.1-encoded byte[]

Converting the byte[] back to an ECPoint is a bit more tricky:
- ASN1Primitive.fromByteArray(byte[])
- Cast the ASN1Primitive to an ASN1OctetString
- Look at the constructors of X9ECPoint, you will need the EC curve here
- X9ECPoint.getPoint()

I haven't tried it out, hope it works. Maybe there's an easier way to do this.
Olaf

----Ursprüngliche Nachricht----
Von : andreas-***@public.gmane.org
Datum : 04/07/2014 - 21:02 (GMT)
An : dev-crypto-***@public.gmane.org
Betreff : [dev-crypto] Re: ECPoint and Java serialization

I must admit that I'm a bit puzzled. I don't see any obvious methods on
ECPoint to convert that into a byte array and back. Did not find any
reference by Google either. Can you give a small code example?


On 07/04/2014 09:08 AM,
Post by o***@public.gmane.org
Just ASN.1-encode the EC point to convert it to a byte array.
----Ursprüngliche Nachricht----
Datum : 03/07/2014 - 15:50 (GMT)
Betreff : [dev-crypto] ECPoint and Java serialization
ECPoint instances (more specifically: ECPoint$Fp) are not serializable.
Is this a deliberate decision or has it just not been looked at?
I need to move ECPoint instances between Android components, and for
that you need some form of serialization (Java serialization is easiest,
despite the problems if you use it as a persistent store). Is there any
recommended serialization method?
Loading...