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

EIP-712 messages as confidential requests #164

Closed
wants to merge 11 commits into from

Conversation

ferranbt
Copy link
Collaborator

📝 Summary

📚 References


  • I have seen and agree to CONTRIBUTING.md

@@ -1908,6 +1908,50 @@ func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionAr
return &SignTransactionResult{data, tx}, nil
}

func (s *TransactionAPI) SendRawTransaction2(ctx context.Context, eip712Envelope *types.ConfidentialComputeRequest2, input hexutil.Bytes) (common.Hash, error) {
// Entrypoint for signed eip-712 messages
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: Verify that the message and the signature match.

@@ -89,6 +91,97 @@ func (tx *ConfidentialComputeRecord) setSignatureValues(chainID, v, r, s *big.In
tx.ChainID, tx.V, tx.R, tx.S = chainID, v, r, s
}

type ConfidentialComputeRequest2 struct {
EIP712 *eip712.EIP712TypedData `json:"eip712"`
Signature []byte `json:"signature"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Signature values in the record are deprecated because you are signing the EIP-712 message, not the record.

type ConfidentialComputeRequest2 struct {
EIP712 *eip712.EIP712TypedData `json:"eip712"`
Signature []byte `json:"signature"`
Sender common.Address `json:"sender"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is hacky thing because Geth expects all the signatures in the v, r, s form but in this case is just []byte.

@@ -89,6 +91,97 @@ func (tx *ConfidentialComputeRecord) setSignatureValues(chainID, v, r, s *big.In
tx.ChainID, tx.V, tx.R, tx.S = chainID, v, r, s
}

type ConfidentialComputeRequest2 struct {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a transaction type, we could say that is the EIP-712 transaction type. Record is only the message type, like the Suave intent-format.

ccr = txdata
case *ConfidentialComputeRequest2:
// BIG TODO: signature validation, forget about v, r and s, just use the signautre field?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Skip signature check

suave/sdk/sdk.go Outdated
Data: calldata,
ConfidentialInputsHash: crypto.Keccak256Hash(confidentialDataBytes), // ?

// initialize empty fields
Copy link
Collaborator Author

@ferranbt ferranbt Jan 17, 2024

Choose a reason for hiding this comment

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

Initialise them because the EIP-712 library cannot handle nils, but they will go out.

suave/sdk/sdk.go Outdated
}
*/

domain := &eip712.EIP712Domain{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feedback on this fields is welcomed.

suave/sdk/sdk.go Outdated
domain := &eip712.EIP712Domain{
Name: "suave?",
Version: "1.0",
VerifyingContract: "0x0000000000000000000000000000000000000000", // ??
Copy link
Member

Choose a reason for hiding this comment

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

this is included in the eip712 spec because these signatures are typically validated by a smart contract; the contract would check that msg.verifyingContract == address(this).
Since we're validating signatures offchain, I think this can be ignored and filled with a dummy value

suave/sdk/sdk.go Outdated
Name: "suave?",
Version: "1.0",
VerifyingContract: "0x0000000000000000000000000000000000000000", // ??
ChainId: big.NewInt(1), // suave chain id?
Copy link
Member

Choose a reason for hiding this comment

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

yes, since the primary message is for suave

suave/sdk/sdk.go Outdated
ConfidentialInputsHash: crypto.Keccak256Hash(confidentialDataBytes), // ?

// initialize empty fields
ChainID: big.NewInt(1337), // suave chain id?
Copy link
Member

Choose a reason for hiding this comment

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

suave/sdk/sdk.go Outdated

// initialize empty fields
ChainID: big.NewInt(1337), // suave chain id?
V: big.NewInt(0),
Copy link
Member

Choose a reason for hiding this comment

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

do/should we have a version of this struct without v,r,s?

@zeroXbrock
Copy link
Member

good first stab! so the client builds a CCRecord and encodes it into an EIP-712 payload , then signs and sends that to the eth_sendRawTransaction2 endpoint in a CCRequest2 envelope with confidentialInputs appended. I think this'll work. Just needs signature verification.

@ferranbt ferranbt closed this Jun 27, 2024
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.

2 participants