algebra
algebra copied to clipboard
Serialization with modes
When I was implementing serialization for certain data structures (manually), there appears to be a lot of repeated code that just calls the underlying function differently (e.g., deserialize
vs deserialize_uncompressed
).
This is similar to what has happened to AllocVar
(https://github.com/arkworks-rs/r1cs-std/blob/master/src/alloc.rs#L9), which we eventually introduce modes:
/// Describes the mode that a variable should be allocated in within
/// a `ConstraintSystem`.
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Copy, Clone)]
pub enum AllocationMode {
/// Indicate to the `ConstraintSystem` that the high-level variable should
/// be allocated as a constant. That is, no `Variable`s should be
/// generated.
Constant = 0,
/// Indicate to the `ConstraintSystem` that the high-level variable should
/// be allocated as a public input to the `ConstraintSystem`.
Input = 1,
/// Indicate to the `ConstraintSystem` that the high-level variable should
/// be allocated as a private witness to the `ConstraintSystem`.
Witness = 2,
}
See also the discussion here: https://github.com/arkworks-rs/algebra/pull/130#issuecomment-745746326