-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Description
I want to be able to reconstruct the PrimeField and also be able to store it in a db/text file or any other thing so that if my node goes down I'm able to recover my Field.
Serde doesn't automatically serialize the PrimeField, so I'm trying to write a custom serializer but not able to figure out. I think my serializer is working but can't figure out deserializer.
pub fn serialize<S, T>(field: &T, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
T: PrimeField,
{
let bytes = field.to_repr();
let bits = bytes.as_bits::<Lsb0>();
let str = bits.to_string();
serializer.serialize_str(&str)
}
Would appreciate help writing a deserializer as well. Thanks for the help!
Metadata
Metadata
Assignees
Labels
No labels