Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Serialize and Deserialize traits for "Output" types? #525

Open
gatoWololo opened this issue Apr 22, 2024 · 2 comments
Open

Implement Serialize and Deserialize traits for "Output" types? #525

gatoWololo opened this issue Apr 22, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@gatoWololo
Copy link

We currently have some "output" types which are the outputs of running our sub-protocols, e.g. keygen::Output and auxinfo::Output. These types do no currently implement the Serialize and Deserialize traits. It is still possible to serialize/deserialize these types.

For example:

/// Output type from key generation, including all parties' public key shares,
/// this party's private key share, and a bit of global randomness.
#[derive(Debug, Clone)]
pub struct Output {
    public_key_shares: Vec<KeySharePublic>,
    private_key_share: KeySharePrivate,
    rid: [u8; 32],
}

This keygen::Output type does not implement Serialize, but the sub-type KeySharePublic does. Meanwhile KeySharePrivate can be serialized by calling the into_bytes method.

While this works, it is quite painful to work with these types. It would be a lot more convenient to implement serialize/deserialize for these types.

It seems not implementing serialize/deserialize was done on purpose for this type. I believe the argument is: Developers should explicitly call the serialize method (into_bytes) as a type of misuse resistance. I don't believe this buys us much though...

@gatoWololo gatoWololo added the enhancement New feature or request label Apr 22, 2024
@gatoWololo
Copy link
Author

@krs85 Since you asked here is an example of a type AuxinfoPrivate which does not implement serialize. Instead there are method into_bytes and try_from_bytes

@krs85
Copy link

krs85 commented Apr 24, 2024

Thank you for pointing me to this example. I agree that just implementing serialize is the right way to do it, having these "workarounds" is more confusing than helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants