ZenGo-X / curv

Rust language general purpose elliptic curve cryptography.
MIT License
265 stars 111 forks source link

Deserialization fails for `Secp256k1Scalar` #180

Open ssantos21 opened 1 year ago

ssantos21 commented 1 year ago

I'm trying to deserialize a String to Secp256k1Scalar, but I am getting the error error[E0277]: the trait bound "Secp256k1Scalar: Deserialize<'_>" is not satisfied, as shown below.

The code is:

let s2: Secp256k1Scalar = serde_json::from_str(&text).unwrap();

How can I deserialize a String to Secp256k1Scalar ?

error[E0277]: the trait bound `Secp256k1Scalar: Deserialize<'_>` is not satisfied
    --> server/src/protocol/ecdsa.rs:134:32
     |
134  |                     Some(s) => serde_json::from_str(&s).unwrap(),
     |                                ^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `Secp256k1Scalar`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               &'a RawStr
               &'a UncasedStr
               &'a [u8]
               &'a rocket::form::name::Key
               &'a rocket::form::name::Name
               &'a serde_bytes::bytes::Bytes
               &'a std::path::Path
               &'a str
             and 459 others
note: required by a bound in `serde_json::from_str`
    --> /home/node/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.99/src/de.rs:2603:8
     |
2603 |     T: de::Deserialize<'a>,
     |        ^^^^^^^^^^^^^^^^^^^ required by this bound in `from_str`