Closed ghost closed 3 years ago
Can you explain what fails in https://github.com/w3f/schnorrkel/blob/master/src/serdey.rs please? A priori I'd expect visit_seq
should fail when invoked upon a simple byte array because that's what visit_bytes
does, no?
Appears ed25519-dalek used serde_bytes without using Bytes
anyplace.
I don't understand why the issue was closed...? There's nothing failing in serdey per se, it's just that not all format specialise sequence of bytes as just bytes, json being one of those... This poses an issue with the current implementation during deserialization, with the reported error, where a sequence is encountered but serdey doesn't handle it
I just pressed the wrong button due to it being late..
Do we need a serde_bytes feature like ed25519-dalek added? If so, we're basically replaying https://github.com/dalek-cryptography/ed25519-dalek/commit/69eccda4449b564aff57a776c6a0ed51fce01123 yes? I'll accept a PR for that of course.
There's a problem in implementing the deserialization part, namely a BytesBuf
becomes somewhat necessary if you want sequence support since Bytes
doesn't implement visit_sequence
, probably since the size is now known so you'd need to allocate.
I'm probably gonna impl with Bytes
and if alloc
is provided as feature then use ByteBuf
instead
I think a serde_bytes feature flag sounds good, mostly because ed25519-dalek did so.
During testing I encountered an error when trying to deserialize a
PublicKey
from aserde_json::Value
Error:
example code can be found here.
I think this can be fixed in multiple ways, either by implementing
visit_seq
or by making use of serde_bytes (even tho it will probably mean that it'll be necessary to wrap withBytes
during serialization / deserialization manually instead of using the attributes offered)