arkworks-rs / snark

Interfaces for Relations and SNARKs for these relations
https://www.arkworks.rs
Apache License 2.0
776 stars 209 forks source link

Add unchecked serialization/deserialization #253

Closed Pratyush closed 4 years ago

Pratyush commented 4 years ago

Add unchecked serialization and deserialization, for the case when one knows that the serialized output will be stored in a trusted location (for example: serialized and deserialized by the same machine).

cc @ChaitanyaKonda @iAmMichaelConnor, this might solve your use case in a cleaner way.

cc also @kobigurk @paberr

Pratyush commented 4 years ago

Did you choose to use an explicit bool for performance reasons?

I did omit the flag handling for affine structs for performance reasons, but I should check that it actually makes a difference by benchmarking.

kobigurk commented 4 years ago

This is very useful! I actually might need something like this soon. That said, I'm highly in favor of making it compatible with the normal decompression. @Pratyush do you think you're going to decide by benchmarking?

Pratyush commented 4 years ago

@kobigurk @paberr I think I'll just make it compatible with normal decompression, because I suspect most of the overhead is due to subgroup checks, and not due to bit manipulation. (I'm writing benchmarks right now to verify this)

Pratyush commented 4 years ago

I suspect most of the overhead is due to subgroup checks, and not due to bit manipulation.

Indeed, most of the overhead is due to the prime-group check.