tlsnotary / tlsn

Rust implementation of the TLSNotary protocol
https://tlsnotary.org
277 stars 73 forks source link

bug: cannot serialize Attestation and Secrets from NotarizationOutputs #598

Closed 0xtsukino closed 1 month ago

0xtsukino commented 1 month ago

https://github.com/tlsnotary/tlsn/blob/dev/crates/wasm/src/prover/mod.rs#L138-L141

For some reason a json object is returned here instead of a serializable class

Screenshot 2024-09-20 at 4 15 24 PM

heeckhau commented 1 month ago

Are you sure it is json? tsify did create an interface NotarizationOutput automatically: https://github.com/tlsnotary/tlsn-js/blob/cdd70e365e14bc12eec9cb5bbc68563ae5b83f34/wasm/pkg/tlsn_wasm.d.ts#L85 ?

sinui0 commented 1 month ago

My intention was for you to move the attestation and secrets out and serialize them separately

0xtsukino commented 1 month ago

Are you sure it is json? tsify did create an interface NotarizationOutput automatically: https://github.com/tlsnotary/tlsn-js/blob/cdd70e365e14bc12eec9cb5bbc68563ae5b83f34/wasm/pkg/tlsn_wasm.d.ts#L85 ?

Yep, you can try running the react demo example in tlsn-js alpha7 branch

My intention was for you to move the attestation and secrets out and serialize them separately

I want to serialize them separately too, but the output is a json object, and both Attestation and Secrets doesn't have a method that allows me to serialize them from json

0xtsukino commented 1 month ago

for more context, i am trying to serialize them here: https://github.com/tlsnotary/tlsn-js/pull/67/files#diff-e59662795ab51f95e1bf2a44d30dd0debbc194a499adffd1bb6a197bd188d4b5R233-R236

const output = await prover.notarize(commit);

return {
  attestation: output.attestation.serialize(),
  secrets: output.secrets.serialize(),
};

for whatever reason, the output from notarize didn't return Attestation and Secrets as expected.

sinui0 commented 1 month ago

I see the problem. wasm-bindgen shenanigans again. Apparently in order to expose those fields as classes we have to clone them.