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

Not able to serialize and deserialize the PrimeField #121

Open
AnmolBansalDEV opened this issue Jan 27, 2025 · 0 comments
Open

Not able to serialize and deserialize the PrimeField #121

AnmolBansalDEV opened this issue Jan 27, 2025 · 0 comments

Comments

@AnmolBansalDEV
Copy link

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!

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

No branches or pull requests

1 participant