Comments (4)
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.
On which version of curv you encountered this problem? Latest curv v0.8.0-rc3
serializes points in compressed form (including secp256k1)
from curv.
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 forsignature
.
... required by packageecdsa v0.12.1
... which is depended on byp256 v0.9.0
... which is depended on bycurv-kzen v0.8.0-rc3
... which is depended on bymulti-party-ecdsa v0.7.3
versions that meet the requirements>=1.3.0, <1.4.0
are: 1.3.1, 1.3.0all possible versions conflict with previously selected packages.
previously selected package
signature v1.2.2
... which is depended on byecdsa v0.8.0
... which is depended on byp256 v0.5.0
... which is depended on bycurv-kzen v0.7.1
... which is depended on bybulletproof v1.1.6 (https://github.com/KZen-networks/bulletproofs?tag=v1.1.6#39e94f7b)
... which is depended on bycentipede v0.2.12 (https://github.com/KZen-networks/centipede?tag=v0.2.12#d426710e)
... which is depended on bymulti-party-ecdsa v0.7.3
from curv.
@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)
- Update `hmac` dependency HOT 1
- Feature request: serialization in v0.7 HOT 1
- suggested additions to Polynomial HOT 2
- Zero Polynomial degree is returning 0
- Implement Zeroize for `Point<E>`
- ed25519::GE fails in serialization and deserialization HOT 10
- Serialization doesn't work with bincode
- Build error: could not find `traits` in `super` HOT 4
- Update crate to latest revision of source code. HOT 1
- generate pk should know the curve
- Bump p256 to 0.11.1 HOT 3
- Incorrect documentation for `check_point_order_equals_group_order` HOT 2
- Updating `curv` dependency in `kzen-paillier`
- Choices between G1Point and Point<Bls12_381_1> in v0.10.0
- Add support for RustCrypto's crypto-bigint HOT 3
- Why use a point as generator instead of a number in feldman vss?
- Deserialization fails for `Secp256k1Scalar`
- Is pairing still considered experimental?
- Build failing on rust 1.73.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curv.