Skip to content

Commit

Permalink
Merge pull request #5121 from onflow/tarak/use-onflow-crypto
Browse files Browse the repository at this point in the history
Import new module `onflow/crypto`
  • Loading branch information
tarakby authored Jan 24, 2024
2 parents 0979fb2 + cf75dac commit 5ea8999
Show file tree
Hide file tree
Showing 289 changed files with 2,186 additions and 2,096 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ go-math-rand-check:
# `exclude` should only specify non production code (test, bench..).
# If this check fails, try updating your code by using:
# - "crypto/rand" or "flow-go/utils/rand" for non-deterministic randomness
# - "flow-go/crypto/random" for deterministic randomness
# - "onflow/crypto/random" for deterministic randomness
grep --include=\*.go \
--exclude=*test* --exclude=*helper* --exclude=*example* --exclude=*fixture* --exclude=*benchmark* --exclude=*profiler* \
--exclude-dir=*test* --exclude-dir=*helper* --exclude-dir=*example* --exclude-dir=*fixture* --exclude-dir=*benchmark* --exclude-dir=*profiler* -rnw '"math/rand"'; \
Expand Down
6 changes: 3 additions & 3 deletions access/legacy/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"errors"
"fmt"

"github.com/onflow/crypto"
"github.com/onflow/crypto/hash"
accessproto "github.com/onflow/flow/protobuf/go/flow/legacy/access"
entitiesproto "github.com/onflow/flow/protobuf/go/flow/legacy/entities"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/onflow/flow-go/access"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/crypto/hash"
"github.com/onflow/flow-go/engine/common/rpc/convert"
"github.com/onflow/flow-go/model/flow"
)
Expand Down Expand Up @@ -69,7 +69,7 @@ func MessageToTransaction(m *entitiesproto.Transaction, chain flow.Chain) (flow.
t.SetScript(m.GetScript())
t.SetArguments(m.GetArguments())
t.SetReferenceBlockID(flow.HashToID(m.GetReferenceBlockId()))
t.SetGasLimit(m.GetGasLimit())
t.SetComputeLimit(m.GetGasLimit())

return *t, nil
}
Expand Down
5 changes: 2 additions & 3 deletions access/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import (
"errors"
"fmt"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/state"

"github.com/onflow/cadence/runtime/parser"
"github.com/onflow/crypto"

"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/state"
"github.com/onflow/flow-go/state/protocol"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
badger "github.com/ipfs/go-ds-badger2"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/routing"
"github.com/onflow/crypto"
"github.com/onflow/flow/protobuf/go/flow/access"
"github.com/onflow/go-bitswap"
"github.com/rs/zerolog"
Expand All @@ -34,7 +35,6 @@ import (
hotstuffvalidator "github.com/onflow/flow-go/consensus/hotstuff/validator"
"github.com/onflow/flow-go/consensus/hotstuff/verification"
recovery "github.com/onflow/flow-go/consensus/recovery/protocol"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/engine"
"github.com/onflow/flow-go/engine/access/ingestion"
pingeng "github.com/onflow/flow-go/engine/access/ping"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/access_keygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"strings"
"time"

"github.com/onflow/crypto"
"github.com/spf13/cobra"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/utils/grpcutils"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/bootstrap/cmd/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package cmd
import (
"fmt"

"github.com/onflow/crypto"

bootstrapDKG "github.com/onflow/flow-go/cmd/bootstrap/dkg"
"github.com/onflow/flow-go/crypto"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/dkg"
"github.com/onflow/flow-go/model/encodable"
Expand Down
10 changes: 4 additions & 6 deletions cmd/bootstrap/cmd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ import (
"net"
"strconv"

"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/bootstrap/utils"
p2putils "github.com/onflow/flow-go/network/p2p/utils"

"github.com/multiformats/go-multiaddr"
"github.com/onflow/crypto"
"github.com/spf13/cobra"

"github.com/onflow/flow-go/crypto"

"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/bootstrap/utils"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
p2putils "github.com/onflow/flow-go/network/p2p/utils"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions cmd/bootstrap/cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package cmd
import (
"fmt"

"github.com/onflow/flow-go/crypto/hash"
"github.com/onflow/crypto/hash"

"github.com/onflow/flow-go/cmd/bootstrap/utils"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/crypto"

model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/encodable"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/machine_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"path/filepath"
"strings"

"github.com/onflow/crypto"
"github.com/spf13/cobra"

"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/crypto"
model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
ioutils "github.com/onflow/flow-go/utils/io"
Expand Down
6 changes: 2 additions & 4 deletions cmd/bootstrap/cmd/machine_account_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"fmt"
"path"

"github.com/onflow/flow-go/crypto"

"github.com/onflow/flow-go/cmd/bootstrap/utils"

"github.com/onflow/crypto"
"github.com/spf13/cobra"

"github.com/onflow/flow-go/cmd/bootstrap/utils"
model "github.com/onflow/flow-go/model/bootstrap"
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/bootstrap/cmd/observer_network_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"fmt"
"os"

"github.com/onflow/crypto"
"github.com/spf13/cobra"

"github.com/onflow/flow-go/crypto"

"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/bootstrap/utils"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/observer_network_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"strings"
"testing"

"github.com/onflow/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/utils/io"
"github.com/onflow/flow-go/utils/unittest"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/partner_infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"strings"

"github.com/onflow/cadence"
"github.com/onflow/crypto"
"github.com/spf13/cobra"

client "github.com/onflow/flow-go-sdk/access/grpc"
"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/encodable"
"github.com/onflow/flow-go/model/flow"
Expand Down
3 changes: 2 additions & 1 deletion cmd/bootstrap/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"os"
"path/filepath"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/crypto"

model "github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/utils/io"
Expand Down
3 changes: 2 additions & 1 deletion cmd/bootstrap/dkg/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package dkg
import (
"fmt"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/crypto"

model "github.com/onflow/flow-go/model/dkg"
"github.com/onflow/flow-go/module/signature"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/dkg/dkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dkg
import (
"testing"

"github.com/onflow/crypto"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/utils/unittest"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/bootstrap/run/execution_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"path/filepath"
"testing"

"github.com/onflow/crypto"
"github.com/onflow/crypto/hash"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/crypto/hash"
"github.com/onflow/flow-go/fvm"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/run/qc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package run
import (
"fmt"

"github.com/onflow/crypto"
"github.com/rs/zerolog"

"github.com/onflow/flow-go/consensus/hotstuff"
Expand All @@ -12,7 +13,6 @@ import (
"github.com/onflow/flow-go/consensus/hotstuff/validator"
"github.com/onflow/flow-go/consensus/hotstuff/verification"
"github.com/onflow/flow-go/consensus/hotstuff/votecollector"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/dkg"
"github.com/onflow/flow-go/model/flow"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/run/qc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"crypto/rand"
"testing"

"github.com/onflow/crypto"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/signature"
Expand Down
8 changes: 3 additions & 5 deletions cmd/bootstrap/utils/key_generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import (
gohash "hash"
"io"

sdk "github.com/onflow/flow-go-sdk"

"github.com/onflow/flow-go/model/encodable"

"github.com/onflow/crypto"
"golang.org/x/crypto/hkdf"

sdk "github.com/onflow/flow-go-sdk"
sdkcrypto "github.com/onflow/flow-go-sdk/crypto"

"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/encodable"
"github.com/onflow/flow-go/model/flow"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap/utils/key_generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"testing"

"github.com/onflow/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

sdkcrypto "github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go/crypto"

"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dynamic_startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"strings"
"time"

"github.com/onflow/crypto"
"github.com/rs/zerolog"
"github.com/sethvargo/go-retry"

client "github.com/onflow/flow-go-sdk/access/grpc"
"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/state/protocol"
badgerstate "github.com/onflow/flow-go/state/protocol/badger"
Expand Down
2 changes: 1 addition & 1 deletion cmd/node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (

"github.com/dgraph-io/badger/v2"
madns "github.com/multiformats/go-multiaddr-dns"
"github.com/onflow/crypto"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/zerolog"
"github.com/spf13/pflag"

"github.com/onflow/flow-go/admin/commands"
"github.com/onflow/flow-go/config"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/fvm"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module"
Expand Down
3 changes: 1 addition & 2 deletions cmd/observer/node_builder/observer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/routing"
"github.com/onflow/crypto"
"github.com/rs/zerolog"
"github.com/spf13/pflag"

"google.golang.org/grpc/credentials"

"github.com/onflow/flow-go/cmd"
Expand All @@ -28,7 +28,6 @@ import (
hotstuffvalidator "github.com/onflow/flow-go/consensus/hotstuff/validator"
"github.com/onflow/flow-go/consensus/hotstuff/verification"
recovery "github.com/onflow/flow-go/consensus/recovery/protocol"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/engine/access/apiproxy"
"github.com/onflow/flow-go/engine/access/rest"
restapiproxy "github.com/onflow/flow-go/engine/access/rest/apiproxy"
Expand Down
2 changes: 1 addition & 1 deletion cmd/testclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func main() {
prepare(signer: AuthAccount) { log(signer.address) }
}
`)).
SetGasLimit(100).
SetComputeLimit(100).
SetProposalKey(addr, accountKey.Index, nonce).
SetReferenceBlockID(latest.ID).
SetPayer(addr).
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/ledger/migrations/cadence_data_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/interpreter"
"github.com/onflow/crypto/hash"

"github.com/onflow/flow-go/cmd/util/ledger/reporters"
"github.com/onflow/flow-go/cmd/util/ledger/util"
"github.com/onflow/flow-go/crypto/hash"
"github.com/onflow/flow-go/ledger"
)

Expand Down
3 changes: 2 additions & 1 deletion consensus/hotstuff/committees/leader/leader_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"fmt"
"math"

"github.com/onflow/flow-go/crypto/random"
"github.com/onflow/crypto/random"

"github.com/onflow/flow-go/model/flow"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"sort"
"testing"

"github.com/onflow/crypto/random"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/crypto/random"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/filter"
"github.com/onflow/flow-go/utils/unittest"
Expand Down
3 changes: 2 additions & 1 deletion consensus/hotstuff/committees/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package committees
import (
"fmt"

"github.com/onflow/crypto"

"github.com/onflow/flow-go/consensus/hotstuff"
"github.com/onflow/flow-go/consensus/hotstuff/model"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/state/protocol"
)
Expand Down
Loading

0 comments on commit 5ea8999

Please sign in to comment.