From 36c3412fae06610c1e4f52b722e66f735bd2c0cc Mon Sep 17 00:00:00 2001 From: Andrey Pechkurov Date: Fri, 22 Mar 2024 19:54:06 +0200 Subject: [PATCH] fix(client): keep Go 1.19 compatibility --- .github/workflows/build.yml | 2 +- go.mod | 2 +- tcp_sender.go | 21 +++++---------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55f9e41..b3e25f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.20.x] + go-version: [1.19.x, 1.20.x] name: Build with Go ${{ matrix.go-version }} steps: - name: Checkout repository diff --git a/go.mod b/go.mod index 7ee044f..76e48f5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/questdb/go-questdb-client/v3 -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.9.0 diff --git a/tcp_sender.go b/tcp_sender.go index ffde51d..6d3e07c 100644 --- a/tcp_sender.go +++ b/tcp_sender.go @@ -28,7 +28,6 @@ import ( "bufio" "context" "crypto" - "crypto/ecdh" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" @@ -67,21 +66,11 @@ func newTcpLineSender(ctx context.Context, conf *lineSenderConfig) (*tcpLineSend if err != nil { return nil, fmt.Errorf("failed to decode auth key: %v", err) } - // elliptic.P256().ScalarBaseMult is deprecated, so we use ecdh key - // and convert it to the ecdsa one. - ecdhKey, err := ecdh.P256().NewPrivateKey(rawKey) - if err != nil { - return nil, fmt.Errorf("invalid auth key: %v", err) - } - ecdhPubKey := ecdhKey.PublicKey().Bytes() - key = &ecdsa.PrivateKey{ - PublicKey: ecdsa.PublicKey{ - Curve: elliptic.P256(), - X: big.NewInt(0).SetBytes(ecdhPubKey[1:33]), - Y: big.NewInt(0).SetBytes(ecdhPubKey[33:]), - }, - D: big.NewInt(0).SetBytes(ecdhKey.Bytes()), - } + // TODO(puzpuzpuz): migrate to crypto/ecdh one we don't need to support Go 1.19 + key = new(ecdsa.PrivateKey) + key.PublicKey.Curve = elliptic.P256() + key.PublicKey.X, key.PublicKey.Y = key.PublicKey.Curve.ScalarBaseMult(rawKey) + key.D = new(big.Int).SetBytes(rawKey) } if conf.tlsMode == tlsDisabled {