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

feat: Sign TeeProof in notary #477

Merged
merged 13 commits into from
Feb 19, 2025
Merged

feat: Sign TeeProof in notary #477

merged 13 commits into from
Feb 19, 2025

Conversation

piotr-roslaniec
Copy link
Contributor

@piotr-roslaniec piotr-roslaniec commented Feb 17, 2025

@piotr-roslaniec piotr-roslaniec force-pushed the feat/sign-tee-proof branch 5 times, most recently from caf3c24 to ae9adf2 Compare February 18, 2025 13:50
Copy link
Contributor

@Autoparallel Autoparallel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some feedback for you. Good work! I think that this cleaned up a lot.

I also think another review would be good from @mattes or @lonerapier perhaps to make sure I'm not missing anything.


let response = ManifestResponse::from_payload(&response_header, &response_body)?;
debug!("{:?}", response);
// TODO: Should TeeProof and other proofs be moved to `proofs` crate?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proofs crate is really for working with client-side-prover and doing NIVC folding proofs. So, no, not in my opinion.

We're going to pull that crate out of here eventually (probably)

let response = ManifestResponse::from_payload(&response_header, &response_body)?;
debug!("{:?}", response);
// TODO: Should TeeProof and other proofs be moved to `proofs` crate?
// Otherwise, adding TeeProof::manifest necessitates extra dependencies on the client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need something like a web-prover-core crate or something. I see what you mean. Given the way we want to abstract the proofs crate, we wouldn't want any of our specific manifest stuff in there anyway. Good comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created: #490


/// Check if `manifest`, `request`, and `response` all fulfill requirements necessary for
/// a proof to be created
fn validate_notarization_legal(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in here we also need to check the JSON path exists and contains a value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is what should happen in <Request|Response>.is_subset_of. Currently, they match the existence of keys and not the value. I can address this one case in this PR but I'd rather start working on the "condition DSL" straight away instead:

// TODO: We are NOT checking the body contents yet! So this "DSL" is not supported:
// "body": {
// "json": [
// "hello"
// ],
// "contains": "world"
// }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created: #491

@piotr-roslaniec piotr-roslaniec force-pushed the feat/sign-tee-proof branch 3 times, most recently from 49968a1 to e844774 Compare February 18, 2025 17:16
Comment on lines 256 to 263
let to_sign = VerifyReply {
value: format!("0x{}", hex::encode(manifest_hash)),
manifest: manifest.clone(),
};
let origo_sig = sign_verification(to_sign, State(state)).unwrap();
let as_bytes = hex::decode(&origo_sig.signature[2..]).unwrap();
let signature = hex::encode(&as_bytes);
Ok(TeeProof { data, signature })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty close to what I was using for verification in the contracts for the origo flow. Is there a change we could match it up? Essentially we return this object here:

pub struct SignedVerificationReply {

where the leaves are a 32byte hash of the value and a 32byte hash of the manifest, Then the digest is the root.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the same struct, SignedVerificationReply for some reason (compatibility between modes, onchain verification, etc)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are able to keep it the same struct our on-chain logic will work with it which is nice. If we can use the same hashing and signing logic we used for the origo mode to populate the struct then it should work with the contract verification seamlessly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should have the Tee proof return a SignedVerificationReply and the Data

@piotr-roslaniec piotr-roslaniec force-pushed the feat/sign-tee-proof branch 3 times, most recently from 440ac27 to a9f74ca Compare February 18, 2025 21:14
@mattes
Copy link
Contributor

mattes commented Feb 18, 2025

The wasm issue is resolved by merging latest main.

@piotr-roslaniec piotr-roslaniec force-pushed the feat/sign-tee-proof branch 2 times, most recently from ebc259b to f500c5d Compare February 19, 2025 10:34
.unwrap()
.insert(query.session_id.to_string(), VerifierInputs { request_messages, response_messages });
state.verifier_sessions.lock().unwrap().insert(query.session_id.to_string(), VerifierInputs {
request_messages: request_messages.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why needing a clone here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, it's not needed. Probably an artifact of some refactor I missed.

@@ -82,6 +82,24 @@ pub struct Manifest {
pub response: ManifestResponse,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think we can move manifest completely out of proofs into a web-prover-core as @Autoparallel mentioned, and just keep origo related inputs code in proofs crate?

maybe we can create a origoManifest on top of Manifest separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the separation between Origo and TEE/Proxy manifest makes sense.

Created: #490

@piotr-roslaniec
Copy link
Contributor Author

Thanks everyone for looking into this. I received more feedback for the draft than I anticipated, so if there are no other comments (and the tests pass) we are good to merge.

@piotr-roslaniec piotr-roslaniec merged commit f0fc22c into main Feb 19, 2025
22 checks passed
@piotr-roslaniec piotr-roslaniec deleted the feat/sign-tee-proof branch February 19, 2025 17:43
@0xJepsen 0xJepsen mentioned this pull request Feb 19, 2025
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

Successfully merging this pull request may close these issues.

6 participants