a16z / jolt

The simplest and most extensible zkVM. Fast and fully open source from a16z crypto and friends. ⚡
https://jolt.a16zcrypto.com
MIT License
587 stars 106 forks source link

Is it Possible to Get Binary Representation of the Proof? #335

Closed khandar-william closed 2 months ago

khandar-william commented 2 months ago

Is there a way to get the binary representation of the Proof object?

Looking at the host_utils::Proof methods, it has a save_to_file method but no method to get just the binary representation of it. I'm thinking of doing something like this in the host code

    let (prove_fib, verify_fib) = guest::build_fib();
    let (output, proof) = prove_fib(50);
    let binary = proof.serialize(); // <-- something like this

If I look at host_utils.rs, it seems that Proof has internal function serialize_compressed but it's not exposed publicly.

sragss commented 2 months ago

The Proof struct implements Arkworks' CanonicalSerialize / CanonicalDeserialize. You should be able to call proof.serialize_compressed(writer).

fn serialize_compressed<W: Write>(
        &self,
        writer: W
    ) -> Result<(), SerializationError> { ... }

To access this function you'll need to import use ark_serialize::CanonicalSerialize.

sragss commented 2 months ago

Closing as I believe this solves your issue. Feel free to ping here if not.