-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flat ConfidentialComputeRequest (#65)
* Flattens the confidential compute request
- Loading branch information
Showing
17 changed files
with
304 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package types | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/crypto" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCCR(t *testing.T) { | ||
testKey, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") | ||
require.NoError(t, err) | ||
|
||
signer := NewSuaveSigner(new(big.Int)) | ||
unsignedTx := NewTx(&ConfidentialComputeRequest{}) | ||
signedTx, err := SignTx(unsignedTx, signer, testKey) | ||
require.NoError(t, err) | ||
|
||
recoveredSender, err := signer.Sender(signedTx) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, crypto.PubkeyToAddress(testKey.PublicKey), recoveredSender) | ||
|
||
marshalledTxBytes, err := signedTx.MarshalBinary() | ||
require.NoError(t, err) | ||
|
||
unmarshalledTx := new(Transaction) | ||
require.NoError(t, unmarshalledTx.UnmarshalBinary(marshalledTxBytes)) | ||
|
||
recoveredUnmarshalledSender, err := signer.Sender(unmarshalledTx) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, crypto.PubkeyToAddress(testKey.PublicKey), recoveredUnmarshalledSender) | ||
} | ||
|
||
func TestSuaveTx(t *testing.T) { | ||
testKey, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") | ||
require.NoError(t, err) | ||
|
||
signer := NewSuaveSigner(new(big.Int)) | ||
|
||
signedCCR, err := SignTx(NewTx(&ConfidentialComputeRequest{ | ||
ExecutionNode: crypto.PubkeyToAddress(testKey.PublicKey), | ||
}), signer, testKey) | ||
require.NoError(t, err) | ||
|
||
unsignedTx := NewTx(&SuaveTransaction{ | ||
ExecutionNode: crypto.PubkeyToAddress(testKey.PublicKey), | ||
ConfidentialComputeRequest: *signedCCR, | ||
}) | ||
signedTx, err := SignTx(unsignedTx, signer, testKey) | ||
require.NoError(t, err) | ||
|
||
recoveredSender, err := signer.Sender(signedTx) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, crypto.PubkeyToAddress(testKey.PublicKey), recoveredSender) | ||
|
||
marshalledTxBytes, err := signedTx.MarshalBinary() | ||
require.NoError(t, err) | ||
|
||
unmarshalledTx := new(Transaction) | ||
require.NoError(t, unmarshalledTx.UnmarshalBinary(marshalledTxBytes)) | ||
|
||
recoveredUnmarshalledSender, err := signer.Sender(unmarshalledTx) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, crypto.PubkeyToAddress(testKey.PublicKey), recoveredUnmarshalledSender) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.