Open jeffallen opened 4 years ago
OK, I wrote a small test:
data := []byte{}
p := (&edwards25519.SuiteEd25519{}).Point()
p.Embed(data, random.New())
d, err := p.Data()
if err != nil{
log.Fatal(err)
}
log.Printf("%+v", d)
log.Print(p.MarshalBinary())
This works. But if data := nil
, then it fails - sometimes, as it depends what the beginning of the point looks like...
Looking at the implementation in edwards25519
, it seems that it's a choice of returning a random point if data := nil
- which doesn't make sense to me. @bford @Daeinar ?
So: what should p.Embed
do with a nil
data? If it would return an error, we could return it there. Unfortunately it only returns a Point. My order of preference:
panic
if a nil
data is entered255
for nil and interpret this as a nil
to be returned by Data
nil
data the same as []byte{}
and embed a 0-length data slicenil
Point to indicate an errorBut perhaps you can think of other solutions?
In the evoting app, I tried decoding and counting a ballot which had been encrypted as follows:
The second argument to lib.Encrypt is a []byte. So I asked to embed 0 bytes into a point and then transform the point via ElGamal encryption.
When I decoded the ballot later, I got:
iteration 1 invalid ballot: Error: invalid embedded data length
. I would have expected instead to not get an exception from point.data(), but instead to get zero bytes back, and then it would be up to my ballot decoder to notice that zero bytes is not a valid ballot.