Coder Social home page Coder Social logo

Comments (4)

survived avatar survived commented on June 20, 2024 2

We still have serde::{Serialize, Deserialize} implemented for points/scalars. Can be checked in the documenation, see: point serialization, deserialization (the same for scalars). Serialization/deserialization traits can be derived in this way:

use curv::elliptic::curves::{Scalar, Secp256k1};

#[derive(Serialize, Deserialize)]
struct OhWowSuchStructMuchFE {
    doge: Scalar<Secp256k1>,
    bonk: Scalar<Secp256k1>,
}

If your struct is generic over choice of curve, then you need to use this trick:

use curv::elliptic::curves::{Scalar, Curve};

#[derive(Serialize, Deserialize)]
#[serde(bound="")]
struct OhWowSuchStructMuchFE<E: Curve> {
    doge: Scalar<E>,
    bonk: Scalar<E>,
}

This little line #[serde(bound="")] does all the magic. It's required because serde, by default, tries to bound generic params to be (de)serializable (ie. it puts E: Serialize + Deserialize), and this little line disables this behaviour.

from curv.

survived avatar survived commented on June 20, 2024

On which version of curv you encountered this problem? Latest curv v0.8.0-rc3 serializes points in compressed form (including secp256k1)

from curv.

DmytroTym avatar DmytroTym commented on June 20, 2024

It's v0.7 used by multi-party-ecdsa. We tried using v0.8.0-rc3 instead, but It seems there are some conflicts:

Updating crates.io index
error: failed to select a version for signature.
... required by package ecdsa v0.12.1
... which is depended on by p256 v0.9.0
... which is depended on by curv-kzen v0.8.0-rc3
... which is depended on by multi-party-ecdsa v0.7.3
versions that meet the requirements >=1.3.0, <1.4.0 are: 1.3.1, 1.3.0

all possible versions conflict with previously selected packages.

previously selected package signature v1.2.2
... which is depended on by ecdsa v0.8.0
... which is depended on by p256 v0.5.0
... which is depended on by curv-kzen v0.7.1
... which is depended on by bulletproof v1.1.6 (https://github.com/KZen-networks/bulletproofs?tag=v1.1.6#39e94f7b)
... which is depended on by centipede v0.2.12 (https://github.com/KZen-networks/centipede?tag=v0.2.12#d426710e)
... which is depended on by multi-party-ecdsa v0.7.3

from curv.

nskybytskyi avatar nskybytskyi commented on June 20, 2024

@survived I've got one more question related to this issue. Secp256k1Scalar in v0.7.3 used to implement serde::Serialize, but it was inefficient, as already noted by @DmytroTym

Now, curv v0.8.0-rc3 implements efficient serialization to bytes, but it does it via the .serialize() method instead. Can I ask what is the reasoning behind this decision?

It appears to me that the previous design was handier for users. Specifically, it is much easier to derive serde::Serialize for custom structures like

#[derive(Serialize)]
struct OhWowSuchStructMuchFE {
    doge: FE,
    bonk: FE,
}

than to implement it by hand for every such struct.

However, this no longer works with curv v0.8.0-rc3 😢

from curv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.