Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
islamaliev committed Mar 4, 2025
1 parent b4597ce commit a6dbb68
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 77 deletions.
2 changes: 1 addition & 1 deletion acp/identity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/cyware/ssi-sdk/crypto"
"github.com/cyware/ssi-sdk/did/key"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jws"
"github.com/lestrrat-go/jwx/v2/jwt"
Expand Down
2 changes: 1 addition & 1 deletion acp/identity/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/cyware/ssi-sdk/crypto"
"github.com/cyware/ssi-sdk/did/key"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion acp/identity/raw_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package identity
import (
"encoding/hex"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
)

// RawIdentity holds the raw bytes that make up an actor's identity.
Expand Down
2 changes: 1 addition & 1 deletion cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"os/signal"
"syscall"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/sourcenetwork/immutable"
"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"path/filepath"
"time"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/sourcenetwork/immutable"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"crypto/ed25519"
"crypto/rand"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
)

// GenerateSecp256k1 generates a new secp256k1 private key.
Expand Down
32 changes: 21 additions & 11 deletions crypto/signature_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
// Copyright 2025 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package crypto

import (
"crypto/ed25519"
"crypto/sha256"
"testing"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -140,12 +150,12 @@ func TestVerify_TamperedMessage(t *testing.T) {
tests := []struct {
name string
sigType SignatureType
setupKeys func(t *testing.T) (pubKey, privKey interface{})
setupKeys func(t *testing.T) (pubKey, privKey any)
}{
{
name: "ECDSA tampered message",
sigType: SignatureTypeECDSA256K,
setupKeys: func(t *testing.T) (pubKey, privKey interface{}) {
setupKeys: func(t *testing.T) (pubKey, privKey any) {
priv, err := GenerateSecp256k1()
require.NoError(t, err)
return priv.PubKey(), priv
Expand All @@ -154,7 +164,7 @@ func TestVerify_TamperedMessage(t *testing.T) {
{
name: "Ed25519 tampered message",
sigType: SignatureTypeEd25519,
setupKeys: func(t *testing.T) (pubKey, privKey interface{}) {
setupKeys: func(t *testing.T) (pubKey, privKey any) {
pub, priv, err := ed25519.GenerateKey(nil)
require.NoError(t, err)
return pub, priv
Expand All @@ -181,12 +191,12 @@ func TestVerify_TamperedSignature(t *testing.T) {
tests := []struct {
name string
sigType SignatureType
setupKeys func(t *testing.T) (pubKey, privKey interface{})
setupKeys func(t *testing.T) (pubKey, privKey any)
}{
{
name: "ECDSA tampered signature",
sigType: SignatureTypeECDSA256K,
setupKeys: func(t *testing.T) (pubKey, privKey interface{}) {
setupKeys: func(t *testing.T) (pubKey, privKey any) {
priv, err := GenerateSecp256k1()
require.NoError(t, err)
return priv.PubKey(), priv
Expand All @@ -195,7 +205,7 @@ func TestVerify_TamperedSignature(t *testing.T) {
{
name: "Ed25519 tampered signature",
sigType: SignatureTypeEd25519,
setupKeys: func(t *testing.T) (pubKey, privKey interface{}) {
setupKeys: func(t *testing.T) (pubKey, privKey any) {
pub, priv, err := ed25519.GenerateKey(nil)
require.NoError(t, err)
return pub, priv
Expand Down Expand Up @@ -241,13 +251,13 @@ func TestVerify_WrongPublicKey(t *testing.T) {
tests := []struct {
name string
sigType SignatureType
setupKeys func(t *testing.T) (correctPub, correctPriv, wrongPub interface{})
setupKeys func(t *testing.T) (correctPub, correctPriv, wrongPub any)
expectErr error
}{
{
name: "ECDSA wrong public key",
sigType: SignatureTypeECDSA256K,
setupKeys: func(t *testing.T) (correctPub, correctPriv, wrongPub interface{}) {
setupKeys: func(t *testing.T) (correctPub, correctPriv, wrongPub any) {
priv1, err := GenerateSecp256k1()
require.NoError(t, err)
priv2, err := GenerateSecp256k1()
Expand All @@ -259,7 +269,7 @@ func TestVerify_WrongPublicKey(t *testing.T) {
{
name: "Ed25519 wrong public key",
sigType: SignatureTypeEd25519,
setupKeys: func(t *testing.T) (correctPub, correctPriv, wrongPub interface{}) {
setupKeys: func(t *testing.T) (correctPub, correctPriv, wrongPub any) {
pub1, priv1, err := ed25519.GenerateKey(nil)
require.NoError(t, err)
pub2, _, err := ed25519.GenerateKey(nil)
Expand Down Expand Up @@ -288,7 +298,7 @@ func TestVerify_InvalidInputs(t *testing.T) {
tests := []struct {
name string
sigType SignatureType
pubKey interface{}
pubKey any
message []byte
signature []byte
expectErr error
Expand Down
8 changes: 4 additions & 4 deletions internal/core/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"sort"
"strings"

"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
cid "github.com/ipfs/go-cid"
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/node/bindnode"
"github.com/ipld/go-ipld-prime/schema"
"github.com/multiformats/go-multicodec"
multicodec "github.com/multiformats/go-multicodec"

"github.com/sourcenetwork/defradb/internal/core"
"github.com/sourcenetwork/defradb/internal/core/crdt"
Expand Down Expand Up @@ -214,7 +214,7 @@ func New(delta core.Delta, links []DAGLink, heads ...cid.Cid) *Block {
// Sort the links lexicographically by CID.
// We need to do this to ensure that the block is deterministic.
sort.Slice(links, func(i, j int) bool {
return strings.Compare(links[i].Cid.String(), links[j].Cid.String()) < 0
return strings.Compare(links[i].Link.Cid.String(), links[j].Link.Cid.String()) < 0
})

blockLinks := make([]DAGLink, 0, len(links))
Expand Down
2 changes: 1 addition & 1 deletion internal/core/block/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package coreblock
import (
"testing"

"github.com/ipld/go-ipld-prime"
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/linking"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/node/basicnode"
Expand Down
2 changes: 1 addition & 1 deletion internal/core/block/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
package coreblock

import (
"github.com/ipld/go-ipld-prime"
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/node/bindnode"
)

Expand Down
3 changes: 2 additions & 1 deletion internal/core/block/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
package coreblock

import (
"github.com/ipld/go-ipld-prime"
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/linking"
"github.com/ipld/go-ipld-prime/node/bindnode"

"github.com/sourcenetwork/defradb/crypto"
)

Expand Down
32 changes: 24 additions & 8 deletions internal/core/block/signature_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
// Copyright 2025 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package coreblock

import (
"crypto/ed25519"
"testing"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/ipld/go-ipld-prime"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
ipld "github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/linking"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/ipld/go-ipld-prime/storage/memstore"
"github.com/stretchr/testify/require"

"github.com/sourcenetwork/defradb/crypto"
"github.com/sourcenetwork/defradb/internal/core/crdt"
"github.com/stretchr/testify/require"
)

type signatureTestKeys struct {
Expand Down Expand Up @@ -62,7 +73,8 @@ func createSignedBlock(t *testing.T, lsys *linking.LinkSystem, block *Block, sig

sigBlockLink, err := lsys.Store(ipld.LinkContext{}, GetLinkPrototype(), sigBlock.GenerateNode())
require.NoError(t, err)
sigLink := sigBlockLink.(cidlink.Link)
sigLink, ok := sigBlockLink.(cidlink.Link)
require.True(t, ok)
block.Signature = &sigLink
}

Expand Down Expand Up @@ -117,7 +129,8 @@ func TestBlockMarshal_IfSignatureNotSet_ShouldNotContainSignatureField(t *testin
sigBlockLink, err := lsys.Store(ipld.LinkContext{}, GetLinkPrototype(), sigBlock.GenerateNode())
require.NoError(t, err)

link := sigBlockLink.(cidlink.Link)
link, ok := sigBlockLink.(cidlink.Link)
require.True(t, ok)

block := Block{
Delta: crdt.CRDT{
Expand Down Expand Up @@ -165,7 +178,8 @@ func TestBlockWithSignatureAndEncryption(t *testing.T) {
}
encBlockLink, err := lsys.Store(ipld.LinkContext{}, GetLinkPrototype(), encBlock.GenerateNode())
require.NoError(t, err)
encLink := encBlockLink.(cidlink.Link)
encLink, ok := encBlockLink.(cidlink.Link)
require.True(t, ok)

// Create signature block
sigBlock := Signature{
Expand All @@ -177,7 +191,8 @@ func TestBlockWithSignatureAndEncryption(t *testing.T) {
}
sigBlockLink, err := lsys.Store(ipld.LinkContext{}, GetLinkPrototype(), sigBlock.GenerateNode())
require.NoError(t, err)
sigLink := sigBlockLink.(cidlink.Link)
sigLink, ok := sigBlockLink.(cidlink.Link)
require.True(t, ok)

// Create block with both encryption and signature
block := Block{
Expand Down Expand Up @@ -282,7 +297,8 @@ func TestVerifyBlockSignature_UnsupportedType(t *testing.T) {

sigBlockLink, err := lsys.Store(ipld.LinkContext{}, GetLinkPrototype(), sigBlock.GenerateNode())
require.NoError(t, err)
sigLink := sigBlockLink.(cidlink.Link)
sigLink, ok := sigBlockLink.(cidlink.Link)
require.True(t, ok)
block.Signature = &sigLink

err = VerifyBlockSignature(&block, lsys)
Expand Down
2 changes: 1 addition & 1 deletion internal/merkle/clock/clock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Democratized Data Foundation
// Copyright 2025 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/acp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"sync/atomic"
"time"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
toml "github.com/pelletier/go-toml"
"github.com/sourcenetwork/immutable"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"math/rand"
"strconv"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/sourcenetwork/immutable"
"github.com/stretchr/testify/require"

Expand Down
1 change: 1 addition & 0 deletions tests/integration/signature/branchable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"

"github.com/onsi/gomega"

coreblock "github.com/sourcenetwork/defradb/internal/core/block"
testUtils "github.com/sourcenetwork/defradb/tests/integration"
)
Expand Down
1 change: 1 addition & 0 deletions tests/integration/signature/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"

"github.com/onsi/gomega"

coreblock "github.com/sourcenetwork/defradb/internal/core/block"
testUtils "github.com/sourcenetwork/defradb/tests/integration"
)
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/signature/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ package signature
import (
"testing"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
"github.com/sourcenetwork/immutable"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

func TestDocSignature_WithEnabledSigning_ShouldQuery(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/state.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Democratized Data Foundation
// Copyright 2025 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
Expand All @@ -14,7 +14,7 @@ import (
"context"
"testing"

"github.com/ipfs/go-cid"
cid "github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"

"github.com/sourcenetwork/defradb/client"
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_case.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Democratized Data Foundation
// Copyright 2025 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
Expand Down Expand Up @@ -70,8 +70,8 @@ type TestCase struct {

// Configuration for KMS to be used in the test
KMS KMS
// If set to true DAG blocks will be signed with a separate block that

// If set to true DAG blocks will be signed with a separate block that
EnabledBlockSigning bool
}

Expand Down
Loading

0 comments on commit a6dbb68

Please sign in to comment.