-
Notifications
You must be signed in to change notification settings - Fork 524
Limit the longest validity period allowed for key registration to pre… #3181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4802b0a
35c7a52
af915dc
05f9ddc
0aee48a
1e23154
db298a9
a1dd729
6807398
5bc8a3c
eb5e3ee
bd074ea
e186b15
e222b1f
76e65ef
20a2aca
eff1253
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,3 +58,14 @@ func TestConsensusUpgradeWindow(t *testing.T) { | |
| } | ||
| } | ||
| } | ||
|
|
||
| func TestConsensusCompactCertParams(t *testing.T) { | ||
| partitiontest.PartitionTest(t) | ||
|
|
||
| for _, params := range Consensus { | ||
| if params.CompactCertRounds != 0 { | ||
| require.Equal(t, uint64(1<<16), (params.MaxKeyregValidPeriod+1)/params.CompactCertRounds, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the "16" be replaced by an existing variable representing that value?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can use merklearray.MaxTreeDepth, but what about the consensus parameters (MaxKeyregValidPeriod for example), should it use that as well? If not there might be some inconsistency in the future.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's postpone this parameter issue to a later PR. #3257 |
||
| "Validity period divided by CompactCertRounds should allow for no more than %d generated keys", 1<<16) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import ( | |
| "context" | ||
| "database/sql" | ||
| "fmt" | ||
| "github.com/algorand/go-algorand/config" | ||
Aharonee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "strconv" | ||
| "testing" | ||
|
|
||
|
|
@@ -35,6 +36,9 @@ import ( | |
|
|
||
| type TestMessage string | ||
|
|
||
| // TODO: change to CurrentVersion when updated | ||
| var CompactCertRounds = config.Consensus[protocol.ConsensusFuture].CompactCertRounds | ||
Aharonee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func (m TestMessage) ToBeHashed() (protocol.HashID, []byte) { | ||
| return protocol.Message, []byte(m) | ||
| } | ||
|
|
@@ -70,7 +74,7 @@ func createParticipantSliceWithWeight(totalWeight, numberOfParticipant int, key | |
| return parts | ||
| } | ||
|
|
||
| func generateTestSigner(name string, firstValid uint64, lastValid uint64, interval uint64, a *require.Assertions) (*merklekeystore.Signer, db.Accessor) { | ||
| func generateTestSigner(name string, firstValid uint64, lastValid uint64, a *require.Assertions) (*merklekeystore.Signer, db.Accessor) { | ||
algonautshant marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| store, err := db.MakeAccessor(name, false, true) | ||
| a.NoError(err) | ||
| a.NotNil(store) | ||
|
|
@@ -84,7 +88,7 @@ func generateTestSigner(name string, firstValid uint64, lastValid uint64, interv | |
| }) | ||
| a.NoError(err) | ||
|
|
||
| signer, err := merklekeystore.New(firstValid, lastValid, interval, crypto.FalconType, store) | ||
| signer, err := merklekeystore.New(firstValid, lastValid, CompactCertRounds, crypto.FalconType, store) | ||
| a.NoError(err) | ||
|
|
||
| err = signer.Persist() | ||
|
|
@@ -117,11 +121,11 @@ func TestBuildVerify(t *testing.T) { | |
| ProvenWeight: uint64(totalWeight / 2), | ||
| SigRound: currentRound, | ||
| SecKQ: 128, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a sound design to have crypto independent of the consensus parameters. However, the hard-coded values in the tests which are repeating the consensus values does not look right. And since the compiler-enforced link of these values to the consensus parameters is broken, this can be problematic in the event the consensus values change. CompactCertRounds is getting its value from go-algorand/config, but SecKQ is not. They need to be uniform.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's postpone this #3257 |
||
| CompactCertRounds: 128, | ||
| CompactCertRounds: CompactCertRounds, | ||
| } | ||
|
|
||
| // Share the key; we allow the same vote key to appear in multiple accounts.. | ||
| key, dbAccessor := generateTestSigner(t.Name()+".db", 0, uint64(param.CompactCertRounds)+1, param.CompactCertRounds, a) | ||
| key, dbAccessor := generateTestSigner(t.Name()+".db", 0, uint64(param.CompactCertRounds)+1, a) | ||
| defer dbAccessor.Close() | ||
| require.NotNil(t, dbAccessor, "failed to create signer") | ||
| var parts []basics.Participant | ||
|
|
@@ -192,14 +196,14 @@ func BenchmarkBuildVerify(b *testing.B) { | |
| ProvenWeight: uint64(totalWeight / 2), | ||
| SigRound: 128, | ||
| SecKQ: 128, | ||
| CompactCertRounds: 128, | ||
| CompactCertRounds: CompactCertRounds, | ||
| } | ||
|
|
||
| var parts []basics.Participant | ||
| var partkeys []*merklekeystore.Signer | ||
| var sigs []merklekeystore.Signature | ||
| for i := 0; i < npart; i++ { | ||
| key, dbAccessor := generateTestSigner(b.Name()+"_"+strconv.Itoa(i)+"_crash.db", 0, uint64(param.CompactCertRounds)+1, param.CompactCertRounds, a) | ||
| key, dbAccessor := generateTestSigner(b.Name()+"_"+strconv.Itoa(i)+"_crash.db", 0, uint64(param.CompactCertRounds)+1, a) | ||
| defer dbAccessor.Close() | ||
| require.NotNil(b, dbAccessor, "failed to create signer") | ||
| part := basics.Participant{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the 128 be substituted by the variable representing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3257