paritytech / libsecp256k1

Pure Rust Implementation of secp256k1.
Apache License 2.0
175 stars 84 forks source link

Bincode Serialization Broken For PublicKey #97

Closed tvanderstad closed 2 years ago

tvanderstad commented 2 years ago

Hi friends :wave: When trying to serialize and deserialize a PublicKey using bincode like this:

        bincode::deserialize::<libsecp256k1::PublicKey>(
            &bincode::serialize(&libsecp256k1::PublicKey::from_secret_key(
                &libsecp256k1::SecretKey::random(&mut rand::rngs::OsRng),
            ))
            .unwrap(),
        )
        .unwrap();

I get the following runtime error:

thread 'test::repro' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("invalid type: byte array, expected a bytestring of either 33 (compressed), 64 (raw), or 65 bytes in length")'

I am using the following versions of things:

bincode = "1.3.3"
rand = "0.8.4"
libsecp256k1 = "0.7.0"