Skip to content

Commit

Permalink
clients/go: Bump oasis-core to 23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Feb 21, 2024
1 parent 5eabcd3 commit 4e2787c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
16 changes: 8 additions & 8 deletions clients/go/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"net/http"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/oasisprotocol/curve25519-voi/primitives/x25519"
"github.com/oasisprotocol/deoxysii"
"github.com/oasisprotocol/oasis-core/go/common/cbor"
mraeApi "github.com/oasisprotocol/oasis-core/go/common/crypto/mrae/api"
mrae "github.com/oasisprotocol/oasis-core/go/common/crypto/mrae/deoxysii"
"golang.org/x/crypto/curve25519"
)

type Kind uint64
Expand Down Expand Up @@ -76,7 +76,7 @@ func (c PlainCipher) Encrypt(plaintext []byte) (ciphertext []byte, nonce []byte)
return plaintext, nonce
}

func (c PlainCipher) Decrypt(nonce []byte, ciphertext []byte) (plaintext []byte, err error) {
func (c PlainCipher) Decrypt(_ []byte, ciphertext []byte) (plaintext []byte, err error) {
return ciphertext, nil
}

Expand Down Expand Up @@ -129,13 +129,13 @@ type X25519DeoxysIICipher struct {
}

type Curve25519KeyPair struct {
PublicKey [curve25519.PointSize]byte
SecretKey [curve25519.ScalarSize]byte
PublicKey x25519.PublicKey
SecretKey x25519.PrivateKey
}

// NewCurve25519KeyPair generates a random keypair suitable for use with the X25519DeoxysII cipher.
func NewCurve25519KeyPair() (*Curve25519KeyPair, error) {
public, private, err := mraeApi.GenerateKeyPair(rand.Reader)
public, private, err := x25519.GenerateKey(nil)
if err != nil {
return nil, err
}
Expand All @@ -145,7 +145,7 @@ func NewCurve25519KeyPair() (*Curve25519KeyPair, error) {
}, nil
}

func NewX25519DeoxysIICipher(keypair Curve25519KeyPair, peerPublicKey [curve25519.PointSize]byte) (*X25519DeoxysIICipher, error) {
func NewX25519DeoxysIICipher(keypair Curve25519KeyPair, peerPublicKey x25519.PublicKey) (*X25519DeoxysIICipher, error) {
var sharedKey [deoxysii.KeySize]byte
mrae.Box.DeriveSymmetricKey(sharedKey[:], &peerPublicKey, &keypair.SecretKey)
cipher, err := deoxysii.New(sharedKey[:])
Expand Down Expand Up @@ -252,7 +252,7 @@ func (c X25519DeoxysIICipher) DecryptEncoded(response []byte) ([]byte, error) {
}

// GetRuntimePublicKey fetches the runtime calldata public key from the default Sapphire gateway.
func GetRuntimePublicKey(chainID uint64) (*[32]byte, error) {
func GetRuntimePublicKey(chainID uint64) (*x25519.PublicKey, error) {
network, exists := Networks[chainID]
if !exists {
return nil, fmt.Errorf("could not fetch public key for network with chain id %d", chainID)
Expand Down Expand Up @@ -290,7 +290,7 @@ func GetRuntimePublicKey(chainID uint64) (*[32]byte, error) {
if len(pubKey.PublicKey) != 32 {
return nil, fmt.Errorf("invalid public key length")
}
return (*[32]byte)(pubKey.PublicKey), nil
return (*x25519.PublicKey)(pubKey.PublicKey), nil
}

type Request struct {
Expand Down
7 changes: 4 additions & 3 deletions clients/go/cipher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/oasisprotocol/curve25519-voi/primitives/x25519"
"github.com/oasisprotocol/deoxysii"
"github.com/oasisprotocol/oasis-core/go/common/cbor"
)
Expand Down Expand Up @@ -84,11 +85,11 @@ func TestDeoxysIICipher(t *testing.T) {
originalText := "keep building anyway"

pair := Curve25519KeyPair{
PublicKey: *(*[32]byte)(publicKey),
SecretKey: *(*[32]byte)(privateKey),
PublicKey: x25519.PublicKey(publicKey),
SecretKey: x25519.PrivateKey(privateKey),
}

cipher, err := NewX25519DeoxysIICipher(pair, *(*[32]byte)(publicKey))
cipher, err := NewX25519DeoxysIICipher(pair, x25519.PublicKey(publicKey))
if err != nil {
t.Fatalf("could not init deoxysii cipher: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions clients/go/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"math/big"
"sync"

"github.com/ethereum/go-ethereum"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/fxamacker/cbor/v2"
cbor "github.com/fxamacker/cbor/v2"
)

const (
Expand Down
24 changes: 14 additions & 10 deletions clients/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
module github.com/oasisprotocol/sapphire-paratime/clients/go

go 1.19
go 1.21

require github.com/ethereum/go-ethereum v1.13.4
toolchain go1.21.3

require (
github.com/ethereum/go-ethereum v1.13.4
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce
)

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
Expand All @@ -17,7 +22,6 @@ require (
github.com/holiman/uint256 v1.2.3 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
Expand All @@ -40,20 +44,20 @@ require (
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7
github.com/oasisprotocol/oasis-core/go v0.2202.1
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/oasisprotocol/oasis-core/go v0.2300.9
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.17.0
golang.org/x/sys v0.15.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
16 changes: 16 additions & 0 deletions clients/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
Expand Down Expand Up @@ -91,22 +93,34 @@ github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqky
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae h1:FatpGJD2jmJfhZiFDElaC0QhZUDQnxUeAwTGkfAHN3I=
github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce h1:/pEpMk55wH0X+E5zedGEMOdLuWmV8P4+4W3+LZaM6kg=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230110094441-db37f07504ce/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 h1:1102pQc2SEPp5+xrS26wEaeb26sZy6k9/ZXlZN+eXE4=
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7/go.mod h1:UqoUn6cHESlliMhOnKLWr+CBH+e3bazUPvFj1XZwAjs=
github.com/oasisprotocol/oasis-core/go v0.2202.1 h1:8A3tVoiTo6/fTrWNptNlqzPSf1PVWVRUrPoavUiQ55s=
github.com/oasisprotocol/oasis-core/go v0.2202.1/go.mod h1:hKUgtuPPq371HokUQL5ashT5MZLZxK/VkWNKRLb9m+w=
github.com/oasisprotocol/oasis-core/go v0.2300.9 h1:4Og8s40BRZzeZbyfm+GcXA2kJmLnsR1Kw9jj1JZOplk=
github.com/oasisprotocol/oasis-core/go v0.2300.9/go.mod h1:3ub+3LT8GEjuzeAXrve9pZEDkM/goL1HKBXVp4queNM=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE=
Expand Down Expand Up @@ -157,6 +171,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
Expand Down

0 comments on commit 4e2787c

Please sign in to comment.