-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversation
internal/ethapi/api.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
core/types/confidential.go
Outdated
@@ -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"` |
There was a problem hiding this comment.
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.
core/types/confidential.go
Outdated
type ConfidentialComputeRequest2 struct { | ||
EIP712 *eip712.EIP712TypedData `json:"eip712"` | ||
Signature []byte `json:"signature"` | ||
Sender common.Address `json:"sender"` |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
core/types/transaction_signing.go
Outdated
ccr = txdata | ||
case *ConfidentialComputeRequest2: | ||
// BIG TODO: signature validation, forget about v, r and s, just use the signautre field? |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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", // ?? |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
good first stab! so the client builds a CCRecord and encodes it into an EIP-712 payload , then signs and sends that to the |
📝 Summary
📚 References