Skip to content
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

Integrate State Proof keys #2990

Merged
merged 345 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 233 commits
Commits
Show all changes
345 commits
Select commit Hold shift + click to select a range
c9c3d03
WIP: adding round commitment to the merklekeystore keys
algonathan Jul 21, 2021
4805692
added const to EphemeralPublicKey ToBeHashed
algonathan Jul 21, 2021
8de8ebd
extended unit tests
algonathan Jul 21, 2021
b0d8e51
fix: 'make sanity'
algonathan Jul 21, 2021
8e75eaf
api change
algonathan Jul 21, 2021
994d938
fix: lexicographic order
algonathan Jul 21, 2021
0f741fa
fix: import style convention
algonathan Jul 21, 2021
6020752
removed unused variable
algonathan Jul 21, 2021
0625577
changed name of ephemralpk
algonathan Jul 22, 2021
238f10c
fix: msgpack for merklekeystore.Verifier
algonathan Jul 22, 2021
2b5f0b1
changed signature test in merklekeystore
algonathan Jul 22, 2021
b5cb25e
fix: comment for EphemralKeys in merklekeystore
algonathan Jul 22, 2021
27bc1bd
fix: bug in unit test
algonathan Jul 22, 2021
15b74a8
fix: comment for EphemralKeys in merklekeystore
algonathan Jul 22, 2021
ecf4d60
removed some spaces
algonathan Jul 22, 2021
d546e32
removed unneeded firstRound param from signer
algonathan Jul 25, 2021
03918f9
added a trimming function to the merklekeystore.
algonathan Jul 25, 2021
1eeba1a
added comments in merkle key store to fields in EphemeralKeys,Signer
algonathan Jul 25, 2021
9a85e36
removed test for valid blockproofPK - no such check for new type of key
algonathan Jul 25, 2021
c6dc936
fix: comparision of merklekeystore.Signer inside tests
algonathan Jul 25, 2021
fe868c4
fix: bad comment over Trim function
algonathan Jul 25, 2021
df16663
fix: using error.new instead of fmt.Errorf when possible
algonathan Jul 28, 2021
80ff497
fix: import conventions
algonathan Jul 28, 2021
b727b7e
fix: comment in participation struct
algonathan Jul 28, 2021
36d935b
fix: removed errors from Trim
algonathan Jul 28, 2021
a3105eb
fix: removed bad comments
algonathan Jul 28, 2021
d260bbd
WIP: dividing key rounds in merklekeystore
algonathan Jul 28, 2021
31dfdd3
fix: sanity checks
algonathan Jul 28, 2021
cc8f2fe
decided not to support zero key, because it doesn't make sense
algonathan Jul 28, 2021
0f201ae
fix: merklekeystore signer will not return invalid verifier
algonathan Jul 28, 2021
d1f0101
fix: bug in libgoal/participation - did not check errors
algonathan Jul 28, 2021
f8e8256
fix: signature and verification align with key spaces
algonathan Jul 28, 2021
5d753c0
fix code panic on 0 divisor
algonathan Jul 28, 2021
d1d91a4
fix: forgot to copy merklekeystore.signer originRound
algonathan Jul 28, 2021
a6e0495
ensuring no verification for round zero
algonathan Jul 28, 2021
fed6f50
added test for divisor >1 in deletion tests
algonathan Jul 28, 2021
a2dc8c2
WIP: fixing trim
algonathan Jul 29, 2021
781724f
renamed divisor into interval
algonathan Jul 29, 2021
e33b60f
renaming merklekeystore bases
algonathan Jul 29, 2021
a4be043
trim is set to work with specific keys only
algonathan Jul 29, 2021
75f64ec
changed codec name, and removed unused field from verifier
algonathan Aug 1, 2021
5a2a2a7
removed commented out code
algonathan Aug 1, 2021
c14d35a
fix: removed unused function numkeys, changed names of params
algonathan Aug 1, 2021
64eb11c
renamed field divisor to interval in merklekeystore.New function
algonathan Aug 1, 2021
b482cfc
removed unused code
algonathan Aug 1, 2021
ed490c2
explicit init for ArrayBase
algonathan Aug 1, 2021
e0f864c
fix: using round instead of indexToRound in verify func
algonathan Aug 1, 2021
858e275
fix: added Status to verifier
algonathan Aug 1, 2021
4ef8990
reverted one commit back
algonathan Aug 1, 2021
5254c1e
renamed firstValid
algonathan Aug 1, 2021
a0376c3
removed unneeded structure (EphemeralKeys) and merged into signer
algonathan Aug 1, 2021
b62872d
fix: changed receiver name to match signer first initial
algonathan Aug 1, 2021
8fe1fd0
fix: renamed functionality to get indices and rounds
algonathan Aug 1, 2021
ac77b57
fix: bug in new signer - overflow in roundToIndex, fixed by explicit …
algonathan Aug 1, 2021
f3190a7
added unit tests
algonathan Aug 1, 2021
3bcb5f9
added a way to dicern empty verifier from verifier that is tied to a …
algonathan Aug 1, 2021
4cf11f6
fix: fmt
algonathan Aug 1, 2021
7cdf8ad
Squashed Review commits, all messages are present below:
algonathan Aug 1, 2021
3bbf7b1
concluded TODO in participation/account is not needed anymore
algonathan Aug 1, 2021
80e8450
removing valid testing for signatureAlgos
algonathan Aug 2, 2021
e87acad
fix:msggen
algonathan Aug 2, 2021
3fb37e9
dillithiumkey basic integration:
algonathan Aug 2, 2021
25bbf53
squashed changes from master
algonathan Aug 4, 2021
811d5a9
placeholder key turned into dilithium key
algonathan Aug 4, 2021
954050c
participation key creation will use concensus params to determine the…
algonathan Aug 4, 2021
04bea3f
WIP: dilithium cgo, -o3 flag. still needs some configurations
algonathan Aug 4, 2021
d58958d
fix: go fmt
algonathan Aug 4, 2021
e943929
new participation key will use keydilution as compactcertround parame…
algonathan Aug 5, 2021
199c846
renamed dilithium library
algonathan Aug 5, 2021
4c6d3b8
fix lint checks
algonathan Aug 5, 2021
f2003eb
check for arm64 integration tests
algonathan Aug 5, 2021
d03a327
merged from main branch
algonathan Aug 5, 2021
609c6c6
added unit test to crypto/dilithium
algonathan Aug 9, 2021
2933533
fix: typos in dilithium.go comments
algonathan Aug 9, 2021
0326a01
rearanging cdilithium directories, cdillithium to use dil3, and rando…
algonathan Aug 9, 2021
398a9b7
changed functions used from api.h
algonathan Aug 9, 2021
419ef35
added constant values
algonathan Aug 9, 2021
63227b5
changing the codec name of dilithium public key
algonathan Aug 11, 2021
5ccfb53
cannot have empty signature
algonathan Aug 11, 2021
2492570
compiling withoung rnadomised sig flag
algonathan Aug 11, 2021
a36c0d8
moved cdilithium wrapper to a different fork
algonathan Aug 11, 2021
1be5466
increased interval
algonathan Aug 11, 2021
ab7e54d
upgraded go-mod version of the algorand/dilithium fork
algonathan Aug 11, 2021
98da7af
added test for dilithium hashable
algonathan Aug 11, 2021
d1e68e1
fixing partitiontest in msgpack tests
Aug 19, 2021
b170684
Subsetsum (#2786)
algonathan Aug 25, 2021
2b53ef0
Compcert sumhash integration (#2816)
algonathan Sep 5, 2021
baf32d2
fix: codegen_verification
algonathan Sep 5, 2021
33b68f4
the compact certificate code now uses the state proof.
Sep 6, 2021
611330f
CR fix
Sep 9, 2021
352bda9
fix layer bug.
Sep 10, 2021
24caaf6
using copy instead of append
Sep 10, 2021
c6e7418
reduce the default number of rounds
Sep 12, 2021
6afa138
added benchmark to participation. refactored fillDB benchmark too.
algonathan Sep 14, 2021
c40c149
fix for review
algonathan Sep 29, 2021
0d2d977
concensus can keep on sending money after reaching version future fro…
algonathan Sep 23, 2021
3c83615
refactored the way testing for upgrade and sending txns work
algonathan Sep 23, 2021
244ce11
added a test that inspects old keys can be made up to the version upg…
algonathan Sep 23, 2021
7c8e55b
refactored func signature to not pass fields of Fixture object
algonathan Sep 24, 2021
d0c415b
added test for participating after concensus upgrade
algonathan Sep 24, 2021
92e92a6
changed comments
algonathan Sep 24, 2021
d88665b
added large participation key registration
algonathan Sep 25, 2021
d0e868e
added a scenario that makes certain compact cert are being made after…
algonathan Sep 25, 2021
ff1bced
added partitionTest to each test
algonathan Sep 29, 2021
8bdd470
changed todo
algonathan Sep 29, 2021
7f51668
removed test
algonathan Sep 29, 2021
7cdd4ff
remove the long test.
Sep 29, 2021
4847851
fixing comments and add PartitionTest
Oct 4, 2021
cb5ad44
adding sync tests
Oct 4, 2021
13c807e
fix fmt problems.
Oct 4, 2021
fca0eb9
rebase corrections
algonautshant Oct 13, 2021
5afa037
msgp regenerated
algonautshant Oct 13, 2021
7e05919
fix integration error
algonautshant Oct 14, 2021
cddceb2
Fix for TestAccountStorageWithBlockProofID broken after ledger refact…
algonautshant Oct 14, 2021
116dc52
fix gofmt (test still failng)
algonautshant Oct 15, 2021
e028ee0
Persistent keystore (#3073)
Aharonee Oct 15, 2021
40ef097
Fix for TestKeysWithoutStateProofKeyCannotRegister and TestAccountSto…
algonautshant Oct 15, 2021
4421cf3
certs now uses sumhash to build merkle tree
Oct 18, 2021
d6e32ba
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Oct 19, 2021
98e8104
regenerated msgp
algonautshant Oct 19, 2021
f50fd16
fix TestTxnGroupEncodingReflection (#3115)
algonautshant Oct 21, 2021
9927833
Change default genesis partkey round validity to 3,000,000 and add a …
Aharonee Oct 21, 2021
12d5214
crypto interfaces api fix (#3097)
algonathan Oct 22, 2021
da63e1a
add test verbositiy to validate participation period
Oct 22, 2021
48a8255
rename blockproof->stateproof (#3133)
id-ms Oct 24, 2021
e06c7b7
fix CC test bug
Oct 24, 2021
b8eee52
Added HashType to ProofResponse REST endpoint (#3104)
Aharonee Oct 25, 2021
6498416
Revised roundToIndex and indexToRound functions and tests (#3081)
algonautshant Oct 26, 2021
a79c255
Algokey print for participation keys (#3140)
algonathan Oct 26, 2021
10ba9bf
Fix encode bug+reduce type sized (#3136)
id-ms Oct 26, 2021
4659d1d
Refactoring and minor fixes (#3150)
Aharonee Oct 28, 2021
f3e7d2e
added benchmarks for sumhash in the merklearray (#3144)
algonathan Oct 28, 2021
5d5f289
Remove containskeys field from verifier (#3146)
id-ms Oct 28, 2021
5788c52
Add some cleanup if writing keys to DB fails
Aharonee Oct 28, 2021
32597c7
Merge branch 'master' into feature/dilithium-scheme-integration
Aharonee Oct 28, 2021
96e55f0
refactor for angry linter
Aharonee Oct 28, 2021
39f4034
z -> h -> z -> h -> ...
Aharonee Oct 28, 2021
2fa0a09
fix msgpack error
Oct 28, 2021
1388110
Expose `StateProofPK` in TEAL (#3114)
jasonpaulos Oct 30, 2021
d6a7181
Refactoring and small fixes
Aharonee Oct 31, 2021
fca5470
Accounts endpoint update (#3141)
algonathan Oct 31, 2021
c3c2ff7
fix broken API
Oct 31, 2021
d6bfce3
merge with master
algonautshant Nov 1, 2021
e8fcc1e
fix merge issue
algonautshant Nov 1, 2021
57b17d9
fix flaky test (#3170)
id-ms Nov 2, 2021
6b3b389
fix copy by value issue
Nov 2, 2021
ad2853a
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Nov 3, 2021
cb4c3ef
use updated version of sumhashfunction (#3180)
id-ms Nov 3, 2021
1066186
generate routs:
algonautshant Nov 3, 2021
c01591d
Merge branch 'master' into feature/dilithium-scheme-integration
Nov 4, 2021
76f9648
FillDBWithParticipationKeys return object on error (#3184)
algonautshant Nov 9, 2021
91a0958
turn up no_output_default from 30m to 60m for dilithium branch
cce Nov 9, 2021
3c45629
change gotestsum format from testname to standard-verbose
cce Nov 9, 2021
c9f71ef
Merge pull request #3199 from cce/dilithium-longer-timeout
cce Nov 10, 2021
d9b945a
Add MT missing bounds (#3171)
algonautshant Nov 12, 2021
8987db4
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Nov 12, 2021
674dba8
Integrate falcon scheme (#3179)
id-ms Nov 16, 2021
744399f
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Nov 17, 2021
aa047b6
msgp and routs
algonautshant Nov 17, 2021
ca7ddf8
fix merge issues.
algonautshant Nov 17, 2021
25171bb
Disabling 3m round checks since not so many will be generated with fa…
algonautshant Nov 18, 2021
d879b7b
partial fix for rest-participation-key.sh
algonautshant Nov 20, 2021
ea61ca0
Adding missing msgp bounds (#3196)
algonautshant Nov 22, 2021
5a71da5
Limit the longest validity period allowed for key registration to pre…
Aharonee Nov 30, 2021
3f996ff
use sha512_256 instead of sumhash to speed up merkle tests
Dec 1, 2021
c94180e
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Dec 1, 2021
cb8715b
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Dec 6, 2021
c01a9e2
routs
algonautshant Dec 6, 2021
6aabe46
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Dec 8, 2021
9b54a6e
msgp regenerated
algonautshant Dec 8, 2021
0219e92
update the test baseline
algonautshant Dec 8, 2021
f8173ff
Merge branch 'master' into feature/dilithium-scheme-integration
Dec 14, 2021
0631b3e
verbose test output to detect which test in not finishing in time
algonautshant Dec 15, 2021
77258d3
Merge remote-tracking branch 'upstream/master' into feature/dilithium…
algonautshant Dec 17, 2021
6d01f6b
fix merge conflict
algonautshant Dec 17, 2021
cd4a466
regenerate paths
algonautshant Dec 17, 2021
ca652fe
msgp regenerated
algonautshant Dec 17, 2021
309c751
run only TestArchivalFromNonArchival for testing
algonautshant Dec 20, 2021
efac333
Reducing the number of blocks to 1000.
algonautshant Dec 20, 2021
965cf04
use 1500 blocks
algonautshant Dec 20, 2021
efe6c77
Merge branch 'master' into feature/dilithium-scheme-integration
Jan 2, 2022
ca330c6
license update for feature branch
Jan 2, 2022
ea5485d
Falcon key gen time: set LastPartKeyRound 3K (#3280)
algonautshant Jan 4, 2022
244b5f2
Use gc to avoid trashing. (#3363)
algonautshant Jan 6, 2022
b93f0e5
Make merkle signer SNARK friendly (#3263)
id-ms Jan 11, 2022
2f2dd3d
Integrate stateproof with the updated account manager (#3350)
Aharonee Jan 13, 2022
d786394
Fix stateproof in goal (#3425)
id-ms Jan 17, 2022
6f12712
Merge branch 'master' into feature/dilithium-scheme-integration
Jan 17, 2022
6d44afc
Add vector commitment (#3370)
id-ms Jan 26, 2022
92d9b68
Merge branch 'master' into feature/dilithium-scheme-integration
Jan 27, 2022
b501f4a
regenerate routes + resotre circleCI config
Jan 27, 2022
3750eb7
Integrate mss and vc (#3512)
id-ms Jan 27, 2022
a4d2ed5
Rename + change compact cert rounds (#3517)
id-ms Jan 27, 2022
3a00dae
fix install bug (#3535)
id-ms Jan 30, 2022
32ac35d
update falcon lib + speed-up participation test
Jan 30, 2022
564fc05
Remove sig abstraction (#3541)
id-ms Feb 1, 2022
0711e2a
Merge branch 'master' into feature/dilithium-scheme-integration
Feb 1, 2022
b8f2ee2
fix memory consumption problem in testing (#3548)
id-ms Feb 2, 2022
cedc835
cr fix
Feb 2, 2022
cd1c60c
nits and CR fixes
Feb 3, 2022
c9adc44
update state proof branch for go 1.13 style errors
cce Feb 7, 2022
9507aca
Refactoring and CR fixes
Aharonee Feb 7, 2022
572ef06
Merge branch 'feature/dilithium-scheme-integration' into stateproofs-…
Aharonee Feb 8, 2022
af0c721
Merge pull request #3585 from cce/stateproofs-go1.13
Aharonee Feb 8, 2022
91e612b
Update error check in unit test
Aharonee Feb 8, 2022
1431b04
changes in keyBuilder
tsachiherman Feb 8, 2022
7bbf683
Merge pull request #3593 from tsachiherman/tsachi/dilithium-keys-builder
Aharonee Feb 8, 2022
de20e30
refactoring and fixes
Aharonee Feb 8, 2022
45f0097
Merge branch 'master' into feature/dilithium-scheme-integration
jannotti Feb 8, 2022
7436433
generated results
jannotti Feb 8, 2022
7ab2c45
Use context instead of an atomic var.
tsachiherman Feb 8, 2022
b01a301
few minor updates.
tsachiherman Feb 9, 2022
35a9c83
Use ErrorIs
jannotti Feb 9, 2022
368a93f
Merge pull request #3597 from algorand/c2c-merge
Aharonee Feb 9, 2022
ab6571f
Merge branch 'feature/dilithium-scheme-integration' into tsachi/keybu…
Aharonee Feb 9, 2022
8c625b7
Merge pull request #3599 from tsachiherman/tsachi/keybuilder2
Aharonee Feb 9, 2022
94f34ab
fix indentation
Aharonee Feb 9, 2022
46eb2b8
Merge pull request #3601 from tsachiherman/tsachi/updateimports
Aharonee Feb 9, 2022
8c37d5e
Iterate over participation data from the registry instead of the old …
Aharonee Feb 9, 2022
fd65cba
fix reviewdog
tsachiherman Feb 9, 2022
c96d6cd
prepare statement stateproofkeys insert
Aharonee Feb 9, 2022
977c517
Merge pull request #3602 from tsachiherman/tsachi/fixrd
Aharonee Feb 9, 2022
dd98456
few db persistence CR
tsachiherman Feb 9, 2022
70abe5b
Merge branch 'feature/dilithium-scheme-integration' into tsachi/fixpmss
tsachiherman Feb 9, 2022
a242d16
update
tsachiherman Feb 9, 2022
bef7804
small change.
tsachiherman Feb 9, 2022
b139765
Merge pull request #3603 from tsachiherman/tsachi/fixpmss
Aharonee Feb 9, 2022
075dfb1
faster implementation.
tsachiherman Feb 9, 2022
0862843
Merge pull request #3604 from tsachiherman/tsachi/faster_txnMerkleToRaw
Aharonee Feb 9, 2022
83f9a05
database schema testing.
tsachiherman Feb 9, 2022
83c8510
Merge pull request #3606 from tsachiherman/tsachi/dilithium_database_…
Aharonee Feb 9, 2022
bd7fcc8
pass flag instead of ConsensusParams to function
Aharonee Feb 9, 2022
90c3248
fix performance regression.
tsachiherman Feb 9, 2022
0d35440
Merge branch 'feature/dilithium-scheme-integration' of github.com:alg…
tsachiherman Feb 9, 2022
aea9374
fix broken test
tsachiherman Feb 9, 2022
7db102d
make test consts non exported
Aharonee Feb 9, 2022
ed6efa5
update e2e_subs test
Aharonee Feb 9, 2022
674688d
changes
tsachiherman Feb 9, 2022
8c2b31a
Merge pull request #3608 from tsachiherman/tsachi/fixtxnMerkleToRawre…
tsachiherman Feb 9, 2022
005e3f1
Merge branch 'feature/dilithium-scheme-integration' into tsachi/sigle…
tsachiherman Feb 9, 2022
01fdce0
replace error strings with error type
Aharonee Feb 10, 2022
617f69f
Update crypto/merklearray/merkle.go
Aharonee Feb 10, 2022
74d31b9
update per peer review
tsachiherman Feb 10, 2022
8d10050
Merge pull request #3609 from tsachiherman/tsachi/siglentest
tsachiherman Feb 10, 2022
268ee6d
reuse code in GetStateProofForRound
Aharonee Feb 10, 2022
e4302da
docstring
Aharonee Feb 10, 2022
1dc185c
rename
Aharonee Feb 10, 2022
3fa00c3
replace error strings with type
Aharonee Feb 10, 2022
9cc0800
newline for goal output
Aharonee Feb 10, 2022
83f96ab
newline for goal output
Aharonee Feb 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \
UNIT_TEST_SOURCES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | grep -v /go-algorand/test/ ))
ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd daemon/algod/api; go list ./... ))

MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert ./txnsync ./data/pooldata
MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/merklearray ./crypto/merklekeystore ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert ./txnsync ./data/pooldata

default: build

Expand Down
5 changes: 5 additions & 0 deletions cmd/algokey/part.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ var partGenerateCmd = &cobra.Command{
partdb, err := db.MakeErasableAccessor(partKeyfile)
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot open partkey database %s: %v\n", partKeyfile, err)
os.Remove(partKeyfile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Remove() returns an error type. what happens if this call fails and partKeyfile didn't get removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's much to do even if it fails and returns an error, I'll add a log that removing the file failed though

os.Exit(1)
}

partkey, err := account.FillDBWithParticipationKeys(partdb, parent, basics.Round(partFirstRound), basics.Round(partLastRound), partKeyDilution)
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot generate partkey database %s: %v\n", partKeyfile, err)
os.Remove(partKeyfile)
os.Exit(1)
}

Expand Down Expand Up @@ -146,6 +148,9 @@ func printPartkey(partkey account.Participation) {
fmt.Printf("Parent address: %s\n", partkey.Parent.String())
fmt.Printf("VRF public key: %s\n", base64.StdEncoding.EncodeToString(partkey.VRF.PK[:]))
fmt.Printf("Voting public key: %s\n", base64.StdEncoding.EncodeToString(partkey.Voting.OneTimeSignatureVerifier[:]))
if partkey.StateProofSecrets != nil && !partkey.StateProofSecrets.GetVerifier().IsEmpty() {
fmt.Printf("State proof key: %s\n", base64.StdEncoding.EncodeToString(partkey.StateProofSecrets.GetVerifier().Root[:]))
}
fmt.Printf("First round: %d\n", partkey.FirstValid)
fmt.Printf("Last round: %d\n", partkey.LastValid)
fmt.Printf("Key dilution: %d\n", partkey.KeyDilution)
Expand Down
10 changes: 8 additions & 2 deletions cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import (
"sort"
"strings"

"github.com/spf13/cobra"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/crypto/merklekeystore"
"github.com/algorand/go-algorand/crypto/passphrase"
generatedV2 "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated"
algodAcct "github.com/algorand/go-algorand/data/account"
Expand All @@ -39,6 +38,8 @@ import (
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/util"
"github.com/algorand/go-algorand/util/db"

"github.com/spf13/cobra"
)

var (
Expand Down Expand Up @@ -1283,6 +1284,7 @@ type partkeyInfo struct {
LastValid basics.Round `codec:"last"`
VoteID crypto.OneTimeSignatureVerifier `codec:"vote"`
SelectionID crypto.VRFVerifier `codec:"sel"`
StateProofID merklekeystore.Verifier `codec:"stprf"`
VoteKeyDilution uint64 `codec:"voteKD"`
}

Expand All @@ -1305,6 +1307,7 @@ var partkeyInfoCmd = &cobra.Command{

for filename, part := range parts {
fmt.Println("------------------------------------------------------------------")

info := partkeyInfo{
Address: part.Address().String(),
FirstValid: part.FirstValid,
Expand All @@ -1313,6 +1316,9 @@ var partkeyInfoCmd = &cobra.Command{
SelectionID: part.VRFSecrets().PK,
VoteKeyDilution: part.KeyDilution,
}
if certSigner := part.StateProofSigner(); certSigner != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ParticipationKeysResponse object returned by client.ListParticipationKeys() isn't going to have this method, so this code probably won't compile.

The legacy function was renamed client.ListParticipationKeyFiles(), but we should avoid using it here. I think we need to create a followup ticket specifically to include state-proof information in the new REST endpoints. After that, we can uncomment the PKI TODO lines.

info.StateProofID = *certSigner.GetVerifier()
}
infoString := protocol.EncodeJSON(&info)
fmt.Printf("File: %s\n%s\n", filename, string(infoString))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/goal/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var networkCreateCmd = &cobra.Command{
consensus, _ = config.PreloadConfigurableConsensusProtocols(dataDir)
}

network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus)
network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, false)
if err != nil {
if noClean {
reportInfof(" ** failed ** - Preserving network rootdir '%s'", networkRootDir)
Expand Down
4 changes: 2 additions & 2 deletions compactcert/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"database/sql"
"fmt"

"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/crypto/merklekeystore"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/protocol"
)
Expand All @@ -47,7 +47,7 @@ var schema = []string{

type pendingSig struct {
signer basics.Address
sig crypto.OneTimeSignature
sig merklekeystore.Signature
fromThisNode bool
}

Expand Down
48 changes: 20 additions & 28 deletions compactcert/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/crypto/merklekeystore"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/protocol"
Expand All @@ -34,9 +34,9 @@ import (
type sigFromAddr struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

Signer basics.Address `codec:"signer"`
Round basics.Round `codec:"rnd"`
Sig crypto.OneTimeSignature `codec:"sig"`
Signer basics.Address `codec:"signer"`
Round basics.Round `codec:"rnd"`
Sig merklekeystore.Signature `codec:"sig"`
}

func (ccw *Worker) signer(latest basics.Round) {
Expand Down Expand Up @@ -93,12 +93,7 @@ func (ccw *Worker) signBlock(hdr bookkeeping.BlockHeader) {
return
}

// Compact cert gets signed by the next round after the block,
// because by the time agreement is reached on the block,
// ephemeral keys for that round could be deleted.
sigKeyRound := hdr.Round + 1

keys := ccw.accts.Keys(sigKeyRound)
keys := ccw.accts.Keys(hdr.Round)
if len(keys) == 0 {
// No keys, nothing to do.
return
Expand All @@ -113,33 +108,30 @@ func (ccw *Worker) signBlock(hdr bookkeeping.BlockHeader) {
return
}

if votersHdr.CompactCert[protocol.CompactCertBasic].CompactCertVoters.IsZero() {
if votersHdr.CompactCert[protocol.CompactCertBasic].CompactCertVoters.IsEmpty() {
// No voter commitment, perhaps because compact certs were
// just enabled.
return
}

votersProto := config.Consensus[votersHdr.CurrentProtocol]
sigs := make([]sigFromAddr, 0, len(keys))

var sigs []sigFromAddr
var sigkeys []crypto.OneTimeSignatureVerifier
for _, key := range keys {
if key.FirstValid <= sigKeyRound && sigKeyRound <= key.LastValid {
keyDilution := key.KeyDilution
if keyDilution == 0 {
keyDilution = votersProto.DefaultKeyDilution
}

ephID := basics.OneTimeIDForRound(sigKeyRound, keyDilution)
sig := key.Voting.Sign(ephID, hdr)
if key.FirstValid > hdr.Round || hdr.Round > key.LastValid {
continue
}

sigs = append(sigs, sigFromAddr{
Signer: key.Parent,
Round: hdr.Round,
Sig: sig,
})
sigkeys = append(sigkeys, key.Voting.OneTimeSignatureVerifier)
sig, err := key.StateProofSecrets.Sign(hdr, uint64(hdr.Round))
if err != nil {
ccw.log.Warnf("ccw.signBlock(%d): StateProof.Sign: %v", hdr.Round, err)
continue
}

sigs = append(sigs, sigFromAddr{
Signer: key.Parent,
Round: hdr.Round,
Sig: sig,
})
}

for _, sfa := range sigs {
Expand Down
66 changes: 43 additions & 23 deletions compactcert/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ func (s *testWorkerStubs) addBlock(ccNextRound basics.Round) {
hdr.Round = s.latest
hdr.CurrentProtocol = protocol.ConsensusFuture

var ccBasic bookkeeping.CompactCertState
var ccBasic = bookkeeping.CompactCertState{
CompactCertVoters: make([]byte, compactcert.HashSize),
CompactCertVotersTotal: basics.MicroAlgos{},
CompactCertNextRound: 0,
}
ccBasic.CompactCertVotersTotal.Raw = uint64(s.totalWeight)

if hdr.Round > 0 {
Expand Down Expand Up @@ -131,13 +135,13 @@ func (s *testWorkerStubs) CompactCertVoters(r basics.Round) (*ledgercore.VotersF
for i, k := range s.keysForVoters {
voters.AddrToPos[k.Parent] = uint64(i)
voters.Participants = append(voters.Participants, basics.Participant{
PK: k.Voting.OneTimeSignatureVerifier,
Weight: 1,
KeyDilution: config.Consensus[protocol.ConsensusFuture].DefaultKeyDilution,
PK: *k.StateProofSecrets.GetVerifier(),
Weight: 1,
FirstValid: uint64(k.FirstValid),
})
}

tree, err := merklearray.Build(voters.Participants)
tree, err := merklearray.Build(voters.Participants, crypto.HashFactory{HashType: compactcert.HashType})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -201,15 +205,17 @@ func newTestWorker(t testing.TB, s *testWorkerStubs) *Worker {
return newTestWorkerDB(t, s, dbs.Wdb)
}

func newPartKey(t testing.TB, parent basics.Address) account.Participation {
// You must call defer part.Close() after calling this function,
// since it creates a DB accessor but the caller must close it (required for PersistentKeystore)
func newPartKey(t testing.TB, parent basics.Address) account.PersistedParticipation {
fn := fmt.Sprintf("%s.%d", strings.ReplaceAll(t.Name(), "/", "."), crypto.RandUint64())
partDB, err := db.MakeAccessor(fn, false, true)
require.NoError(t, err)

part, err := account.FillDBWithParticipationKeys(partDB, parent, 0, 1024*1024, config.Consensus[protocol.ConsensusFuture].DefaultKeyDilution)
part, err := account.FillDBWithParticipationKeys(partDB, parent, 0, 1024, config.Consensus[protocol.ConsensusFuture].DefaultKeyDilution)
require.NoError(t, err)
part.Close()
return part.Participation

return part
}

func TestWorkerAllSigs(t *testing.T) {
Expand All @@ -219,7 +225,9 @@ func TestWorkerAllSigs(t *testing.T) {
for i := 0; i < 10; i++ {
var parent basics.Address
crypto.RandBytes(parent[:])
keys = append(keys, newPartKey(t, parent))
p := newPartKey(t, parent)
defer p.Close()
keys = append(keys, p.Participation)
}

s := newWorkerStubs(t, keys, len(keys))
Expand Down Expand Up @@ -257,10 +265,11 @@ func TestWorkerAllSigs(t *testing.T) {
require.False(t, overflowed)

ccparams := compactcert.Params{
Msg: signedHdr,
ProvenWeight: provenWeight,
SigRound: basics.Round(signedHdr.Round + 1),
SecKQ: proto.CompactCertSecKQ,
Msg: signedHdr,
ProvenWeight: provenWeight,
SigRound: basics.Round(signedHdr.Round),
SecKQ: proto.CompactCertSecKQ,
CompactCertRounds: proto.CompactCertRounds,
}

voters, err := s.CompactCertVoters(tx.Txn.CertRound - basics.Round(proto.CompactCertRounds) - basics.Round(proto.CompactCertVotersLookback))
Expand All @@ -281,7 +290,9 @@ func TestWorkerPartialSigs(t *testing.T) {
for i := 0; i < 7; i++ {
var parent basics.Address
crypto.RandBytes(parent[:])
keys = append(keys, newPartKey(t, parent))
p := newPartKey(t, parent)
defer p.Close()
keys = append(keys, p.Participation)
}

s := newWorkerStubs(t, keys, 10)
Expand Down Expand Up @@ -318,10 +329,11 @@ func TestWorkerPartialSigs(t *testing.T) {
require.False(t, overflowed)

ccparams := compactcert.Params{
Msg: signedHdr,
ProvenWeight: provenWeight,
SigRound: basics.Round(signedHdr.Round + 1),
SecKQ: proto.CompactCertSecKQ,
Msg: signedHdr,
ProvenWeight: provenWeight,
SigRound: basics.Round(signedHdr.Round),
SecKQ: proto.CompactCertSecKQ,
CompactCertRounds: proto.CompactCertRounds,
}

voters, err := s.CompactCertVoters(tx.Txn.CertRound - basics.Round(proto.CompactCertRounds) - basics.Round(proto.CompactCertVotersLookback))
Expand All @@ -339,7 +351,9 @@ func TestWorkerInsufficientSigs(t *testing.T) {
for i := 0; i < 2; i++ {
var parent basics.Address
crypto.RandBytes(parent[:])
keys = append(keys, newPartKey(t, parent))
p := newPartKey(t, parent)
defer p.Close()
keys = append(keys, p.Participation)
}

s := newWorkerStubs(t, keys, 10)
Expand Down Expand Up @@ -370,7 +384,9 @@ func TestLatestSigsFromThisNode(t *testing.T) {
for i := 0; i < 10; i++ {
var parent basics.Address
crypto.RandBytes(parent[:])
keys = append(keys, newPartKey(t, parent))
p := newPartKey(t, parent)
defer p.Close()
keys = append(keys, p.Participation)
}

s := newWorkerStubs(t, keys, 10)
Expand Down Expand Up @@ -423,7 +439,9 @@ func TestWorkerRestart(t *testing.T) {
for i := 0; i < 10; i++ {
var parent basics.Address
crypto.RandBytes(parent[:])
keys = append(keys, newPartKey(t, parent))
p := newPartKey(t, parent)
defer p.Close()
keys = append(keys, p.Participation)
}

s := newWorkerStubs(t, keys, 10)
Expand Down Expand Up @@ -464,7 +482,9 @@ func TestWorkerHandleSig(t *testing.T) {
for i := 0; i < 2; i++ {
var parent basics.Address
crypto.RandBytes(parent[:])
keys = append(keys, newPartKey(t, parent))
p := newPartKey(t, parent)
defer p.Close()
keys = append(keys, p.Participation)
}

s := newWorkerStubs(t, keys, 10)
Expand Down
6 changes: 6 additions & 0 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ type ConsensusParams struct {
// MaxProposedExpiredOnlineAccounts is the maximum number of online accounts, which need
// to be taken offline, that would be proposed to be taken offline.
MaxProposedExpiredOnlineAccounts int

// EnableStateProofKeyregCheck enables the check for stateProof key on key registration
EnableStateProofKeyregCheck bool
}

// PaysetCommitType enumerates possible ways for the block header to commit to
Expand Down Expand Up @@ -1056,6 +1059,9 @@ func initConsensusProtocols() {

vFuture.MaxProposedExpiredOnlineAccounts = 32

// stat proof key registration
vFuture.EnableStateProofKeyregCheck = true

Consensus[protocol.ConsensusFuture] = vFuture
}

Expand Down
Loading