summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShant Karakashian <55754073+algonautshant@users.noreply.github.com>2022-01-12 16:51:05 -0500
committerGitHub <noreply@github.com>2022-01-12 16:51:05 -0500
commit3904ed8f42bd8403931585a6cc0f5fe4f3748412 (patch)
treee852ff0cf25222f03ad07673a5d0d9d7e2243608
parente19fafbee1e073ebfc9840b635f70003ac5b7a06 (diff)
signer.KeyDilution need not depend on config package (#3265)
crypto package need not depend on config. There is an unnecessary dependency on config. signer.KeyDilution takes the `config.ConsensusParams` as argument to pick the DefaultKeyDilution from it. This introduces dependency from the crypto package to config package. Instead, only the DefaultKeyDilution value can be passed to signer.KeyDilution.
-rw-r--r--agreement/cryptoVerifier_test.go2
-rw-r--r--agreement/vote.go2
-rw-r--r--crypto/onetimesig.go8
-rw-r--r--node/netprio.go2
4 files changed, 6 insertions, 8 deletions
diff --git a/agreement/cryptoVerifier_test.go b/agreement/cryptoVerifier_test.go
index 939f8aa71..a42ffd9b0 100644
--- a/agreement/cryptoVerifier_test.go
+++ b/agreement/cryptoVerifier_test.go
@@ -72,7 +72,7 @@ func makeUnauthenticatedVote(l Ledger, sender basics.Address, selection *crypto.
m, _ := membership(l, rv.Sender, rv.Round, rv.Period, rv.Step)
cred := committee.MakeCredential(&selection.SK, m.Selector)
- ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(config.Consensus[protocol.ConsensusCurrentVersion]))
+ ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(config.Consensus[protocol.ConsensusCurrentVersion].DefaultKeyDilution))
sig := voting.Sign(ephID, rv)
return unauthenticatedVote{
diff --git a/agreement/vote.go b/agreement/vote.go
index b1bded68b..99973d5ef 100644
--- a/agreement/vote.go
+++ b/agreement/vote.go
@@ -163,7 +163,7 @@ func makeVote(rv rawVote, voting crypto.OneTimeSigner, selection *crypto.VRFSecr
}
}
- ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(proto))
+ ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(proto.DefaultKeyDilution))
sig := voting.Sign(ephID, rv)
if (sig == crypto.OneTimeSignature{}) {
return unauthenticatedVote{}, fmt.Errorf("makeVote: got back empty signature for vote")
diff --git a/crypto/onetimesig.go b/crypto/onetimesig.go
index 6196a99ee..119119d37 100644
--- a/crypto/onetimesig.go
+++ b/crypto/onetimesig.go
@@ -20,11 +20,9 @@ import (
"encoding/binary"
"fmt"
- "github.com/algorand/go-deadlock"
-
- "github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
+ "github.com/algorand/go-deadlock"
)
// A OneTimeSignature is a cryptographic signature that is produced a limited
@@ -432,10 +430,10 @@ type OneTimeSigner struct {
}
// KeyDilution returns the appropriate key dilution value for a OneTimeSigner.
-func (ots OneTimeSigner) KeyDilution(params config.ConsensusParams) uint64 {
+func (ots OneTimeSigner) KeyDilution(defaultKeyDilution uint64) uint64 {
if ots.OptionalKeyDilution != 0 {
return ots.OptionalKeyDilution
}
- return params.DefaultKeyDilution
+ return defaultKeyDilution
}
diff --git a/node/netprio.go b/node/netprio.go
index c8d7031a6..c322155eb 100644
--- a/node/netprio.go
+++ b/node/netprio.go
@@ -97,7 +97,7 @@ func (node *AlgorandFullNode) MakePrioResponse(challenge string) []byte {
}
signer := maxPart.VotingSigner()
- ephID := basics.OneTimeIDForRound(voteRound, signer.KeyDilution(proto))
+ ephID := basics.OneTimeIDForRound(voteRound, signer.KeyDilution(proto.DefaultKeyDilution))
rs.Round = voteRound
rs.Sender = maxPart.Address()