proof-systems icon indicating copy to clipboard operation
proof-systems copied to clipboard

[serialization] safer serialization

Open mimoo opened this issue 4 years ago • 8 comments

In https://github.com/o1-labs/proof-systems/pull/160 I propose to use serde for serialization and deserialization.

There are a few problems with that:

  1. we skip some fields, because in our current logic we do not deserialize them. This means that when you deserialize these structs, the Default implementation of these fields is used. You thus have to remember to fill them yourself. A better alternative would be to have an enum that prevents you to use the field if it hasn't been set. For example:
    #[serde(skip)]
    pub fr_sponge_params: ArithmeticSpongeParams<F>,
    
    or
     #[serde(skip)]
     pub srs: SRSValue<'a, G>,
    
  2. we do not necessarily perform cryptographic validations on deserialization. For example, curve points might need to be checked to make sure they are on the curve. This is something that might not be relevant in the current use-case (caching structs to filesystem), but if we use this to serialize and deserialize types before sending them over the network this is something we need to be careful with.

mimoo avatar Oct 04 '21 17:10 mimoo

Stale issue message

github-actions[bot] avatar Dec 04 '21 07:12 github-actions[bot]

I don't think the validation matters for now. We should have separate functions for that if we ever deserialize from untrusted source. But we should have these skipped fields be options.

mimoo avatar Dec 04 '21 17:12 mimoo

Stale issue message

github-actions[bot] avatar Feb 03 '22 07:02 github-actions[bot]

In addition, we should remove serialization logic from the stubs in mina

mimoo avatar Feb 04 '22 00:02 mimoo

Stale issue message

github-actions[bot] avatar Apr 05 '22 07:04 github-actions[bot]

Stale issue message

github-actions[bot] avatar Jun 05 '22 07:06 github-actions[bot]

Stale issue message

github-actions[bot] avatar Aug 08 '22 07:08 github-actions[bot]

Stale issue message

github-actions[bot] avatar Oct 08 '22 07:10 github-actions[bot]

Stale issue message

github-actions[bot] avatar Dec 08 '22 07:12 github-actions[bot]

Stale issue message

github-actions[bot] avatar Feb 11 '23 07:02 github-actions[bot]

Stale issue message

github-actions[bot] avatar Apr 16 '23 07:04 github-actions[bot]