ed25519-dalek
ed25519-dalek copied to clipboard
Signature and PublicKey could have better deserialisation support
Signature and PublicKey are also affected.
Originally posted by @rainhead in https://github.com/dalek-cryptography/ed25519-dalek/issues/111#issuecomment-592994350
Hi all,
I just came around the problem, that the ed25519_dalek::Keypair is not able to serialize and deserialize afterwards the same data.
I tested it like the following
let mut csprng = OsRng {};
let key = Ed25519Keypair::generate(&mut csprng);
println!("KEY: {:?}", key);
let bytes = serde_json::to_vec(&key).unwrap();
let new_key : Ed25519Keypair = serde_json::from_slice(&bytes).unwrap();
println!("NEW KEY: {:?}", new_key);
The following error occurs
KEY: Keypair { secret: SecretKey: [188, 223, 177, 97, 175, 196, 28, 195, 116, 104, 241, 76, 219, 172, 196, 45, 176, 250, 66, 110, 77, 147, 78, 107, 199, 66, 182, 251, 71, 30, 10, 222], public: PublicKey(CompressedEdwardsY: [64, 201, 56, 196, 42, 232, 143, 225, 121, 18, 202, 17, 73, 190, 127, 101, 173, 95, 238, 178, 145, 122, 91, 127, 50, 33, 169, 241, 225, 9, 81, 188]), EdwardsPoint{
X: FieldElement51([687946466869619, 107360584677275, 298199894910233, 1211619723616352, 651182423837054]),
Y: FieldElement51([1508208775280693, 158435790617717, 1644081860630336, 1874423471707253, 122428325338618]),
Z: FieldElement51([261165033366735, 1451298753928703, 1804282745001967, 391348286045173, 1385537188942500]),
T: FieldElement51([702606775487581, 471739482787318, 1120642760984846, 1234200999468521, 610789072190272])
}) }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("invalid type: sequence, expected An ed25519 keypair, 64 bytes in total where the secret key is the first 32 bytes and is in unexpanded form, and the second 32 bytes is a compressed point for a public key.", line: 1, column: 1)', src/main.rs:21:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
We are blocked with this here: hap-rs#15
@isislovecruft With the pre release 4 this is fixed now. Thank you!