-
Notifications
You must be signed in to change notification settings - Fork 105
StateProof: State proof support #374
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
42dfdf3
Regenerate client.
winder aa44342
Update txn and block objects, cucumber tests passing.
winder fdfac3d
Enable cucumber tests.
winder 501ad10
Update types/stateproof.go
winder 3abe4c0
Add transactions-root-256
winder 5bec007
Merge branch 'will/state-proof-support' of github.com:algorand/go-alg…
winder ec65a04
Remove unused code.
winder f65d794
Remove unused file
Eric-Warehime ef86aea
Add txn commitments blockheader fields
Eric-Warehime 1de5fda
Rename signature, add allocbound definitions
Eric-Warehime 10fa445
Add txn commitment to header
Eric-Warehime 0842b7f
Merge remote-tracking branch 'upstream/develop' into stpf-support
Eric-Warehime 390a9ea
PR comments
Eric-Warehime 521bec8
Remove unused file
Eric-Warehime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package algod | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/algorand/go-algorand-sdk/client/v2/common" | ||
| "github.com/algorand/go-algorand-sdk/client/v2/common/models" | ||
| ) | ||
|
|
||
| // GetLightBlockHeaderProof gets a proof for a given light block header inside a | ||
| // state proof commitment | ||
| type GetLightBlockHeaderProof struct { | ||
| c *Client | ||
|
|
||
| round uint64 | ||
| } | ||
|
|
||
| // Do performs the HTTP request | ||
| func (s *GetLightBlockHeaderProof) Do(ctx context.Context, headers ...*common.Header) (response models.LightBlockHeaderProof, err error) { | ||
| err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/lightheader/proof", common.EscapeParams(s.round)...), nil, headers) | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package algod | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/algorand/go-algorand-sdk/client/v2/common" | ||
| "github.com/algorand/go-algorand-sdk/client/v2/common/models" | ||
| ) | ||
|
|
||
| // GetStateProof get a state proof that covers a given round | ||
| type GetStateProof struct { | ||
| c *Client | ||
|
|
||
| round uint64 | ||
| } | ||
|
|
||
| // Do performs the HTTP request | ||
| func (s *GetStateProof) Do(ctx context.Context, headers ...*common.Header) (response models.StateProof, err error) { | ||
| err = s.c.get(ctx, &response, fmt.Sprintf("/v2/stateproofs/%s", common.EscapeParams(s.round)...), nil, headers) | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package models | ||
|
|
||
| // HashFactory defines a model for HashFactory. | ||
| type HashFactory struct { | ||
| // HashType (t) | ||
| HashType uint64 `json:"hash-type,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package models | ||
|
|
||
| // IndexerStateProofMessage defines a model for IndexerStateProofMessage. | ||
| type IndexerStateProofMessage struct { | ||
| // BlockHeadersCommitment (b) | ||
| BlockHeadersCommitment []byte `json:"block-headers-commitment,omitempty"` | ||
|
|
||
| // FirstAttestedRound (f) | ||
| FirstAttestedRound uint64 `json:"first-attested-round,omitempty"` | ||
|
|
||
| // LatestAttestedRound (l) | ||
| LatestAttestedRound uint64 `json:"latest-attested-round,omitempty"` | ||
|
|
||
| // LnProvenWeight (P) | ||
| LnProvenWeight uint64 `json:"ln-proven-weight,omitempty"` | ||
|
|
||
| // VotersCommitment (v) | ||
| VotersCommitment []byte `json:"voters-commitment,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package models | ||
|
|
||
| // LightBlockHeaderProof proof of membership and position of a light block header. | ||
| type LightBlockHeaderProof struct { | ||
| // Index the index of the light block header in the vector commitment tree | ||
| Index uint64 `json:"index"` | ||
|
|
||
| // Proof the encoded proof. | ||
| Proof []byte `json:"proof"` | ||
|
|
||
| // Treedepth represents the depth of the tree that is being proven, i.e. the number | ||
| // of edges from a leaf to the root. | ||
| Treedepth uint64 `json:"treedepth"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package models | ||
|
|
||
| // MerkleArrayProof defines a model for MerkleArrayProof. | ||
| type MerkleArrayProof struct { | ||
| // HashFactory | ||
| HashFactory HashFactory `json:"hash-factory,omitempty"` | ||
|
|
||
| // Path (pth) | ||
| Path [][]byte `json:"path,omitempty"` | ||
|
|
||
| // TreeDepth (td) | ||
| TreeDepth uint64 `json:"tree-depth,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package models | ||
|
|
||
| // StateProof represents a state proof and its corresponding message | ||
| type StateProof struct { | ||
| // Message represents the message that the state proofs are attesting to. | ||
| Message StateProofMessage `json:"Message"` | ||
|
|
||
| // Stateproof the encoded StateProof for the message. | ||
| Stateproof []byte `json:"StateProof"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package models | ||
|
|
||
| // StateProofFields (sp) represents a state proof. | ||
| // Definition: | ||
| // crypto/stateproof/structs.go : StateProof | ||
| type StateProofFields struct { | ||
| // PartProofs (P) | ||
| PartProofs MerkleArrayProof `json:"part-proofs,omitempty"` | ||
|
|
||
| // PositionsToReveal (pr) Sequence of reveal positions. | ||
| PositionsToReveal []uint64 `json:"positions-to-reveal,omitempty"` | ||
|
|
||
| // Reveals (r) Note that this is actually stored as a map[uint64] - Reveal in the | ||
| // actual msgp | ||
| Reveals []StateProofReveal `json:"reveals,omitempty"` | ||
|
|
||
| // SaltVersion (v) Salt version of the merkle signature. | ||
| SaltVersion uint64 `json:"salt-version,omitempty"` | ||
|
|
||
| // SigCommit (c) | ||
| SigCommit []byte `json:"sig-commit,omitempty"` | ||
|
|
||
| // SigProofs (S) | ||
| SigProofs MerkleArrayProof `json:"sig-proofs,omitempty"` | ||
|
|
||
| // SignedWeight (w) | ||
| SignedWeight uint64 `json:"signed-weight,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package models | ||
|
|
||
| // StateProofMessage represents the message that the state proofs are attesting to. | ||
| type StateProofMessage struct { | ||
| // Blockheaderscommitment the vector commitment root on all light block headers | ||
| // within a state proof interval. | ||
| Blockheaderscommitment []byte `json:"BlockHeadersCommitment"` | ||
|
|
||
| // Firstattestedround the first round the message attests to. | ||
| Firstattestedround uint64 `json:"FirstAttestedRound"` | ||
|
|
||
| // Lastattestedround the last round the message attests to. | ||
| Lastattestedround uint64 `json:"LastAttestedRound"` | ||
|
|
||
| // Lnprovenweight an integer value representing the natural log of the proven | ||
| // weight with 16 bits of precision. This value would be used to verify the next | ||
| // state proof. | ||
| Lnprovenweight uint64 `json:"LnProvenWeight"` | ||
|
|
||
| // Voterscommitment the vector commitment root of the top N accounts to sign the | ||
| // next StateProof. | ||
| Voterscommitment []byte `json:"VotersCommitment"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package models | ||
|
|
||
| // StateProofParticipant defines a model for StateProofParticipant. | ||
| type StateProofParticipant struct { | ||
| // Verifier (p) | ||
| Verifier StateProofVerifier `json:"verifier,omitempty"` | ||
|
|
||
| // Weight (w) | ||
| Weight uint64 `json:"weight,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package models | ||
|
|
||
| // StateProofReveal defines a model for StateProofReveal. | ||
| type StateProofReveal struct { | ||
| // Participant (p) | ||
| Participant StateProofParticipant `json:"participant,omitempty"` | ||
|
|
||
| // Position the position in the signature and participants arrays corresponding to | ||
| // this entry. | ||
| Position uint64 `json:"position,omitempty"` | ||
|
|
||
| // SigSlot (s) | ||
| SigSlot StateProofSigSlot `json:"sig-slot,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package models | ||
|
|
||
| // StateProofSigSlot defines a model for StateProofSigSlot. | ||
| type StateProofSigSlot struct { | ||
| // LowerSigWeight (l) The total weight of signatures in the lower-numbered slots. | ||
| LowerSigWeight uint64 `json:"lower-sig-weight,omitempty"` | ||
|
|
||
| // Signature | ||
| Signature StateProofSignature `json:"signature,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package models | ||
|
|
||
| // StateProofSignature defines a model for StateProofSignature. | ||
| type StateProofSignature struct { | ||
| // FalconSignature | ||
| FalconSignature []byte `json:"falcon-signature,omitempty"` | ||
|
|
||
| // MerkleArrayIndex | ||
| MerkleArrayIndex uint64 `json:"merkle-array-index,omitempty"` | ||
|
|
||
| // Proof | ||
| Proof MerkleArrayProof `json:"proof,omitempty"` | ||
|
|
||
| // VerifyingKey (vkey) | ||
| VerifyingKey []byte `json:"verifying-key,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package models | ||
|
|
||
| // StateProofTracking defines a model for StateProofTracking. | ||
| type StateProofTracking struct { | ||
| // NextRound (n) Next round for which we will accept a state proof transaction. | ||
| NextRound uint64 `json:"next-round,omitempty"` | ||
|
|
||
| // OnlineTotalWeight (t) The total number of microalgos held by the online accounts | ||
| // during the StateProof round. | ||
| OnlineTotalWeight uint64 `json:"online-total-weight,omitempty"` | ||
|
|
||
| // Type state Proof Type. Note the raw object uses map with this as key. | ||
| Type uint64 `json:"type,omitempty"` | ||
|
|
||
| // VotersCommitment (v) Root of a vector commitment containing online accounts that | ||
| // will help sign the proof. | ||
| VotersCommitment []byte `json:"voters-commitment,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package models | ||
|
|
||
| // StateProofVerifier defines a model for StateProofVerifier. | ||
| type StateProofVerifier struct { | ||
| // Commitment (cmt) Represents the root of the vector commitment tree. | ||
| Commitment []byte `json:"commitment,omitempty"` | ||
|
|
||
| // KeyLifetime (lf) Key lifetime. | ||
| KeyLifetime uint64 `json:"key-lifetime,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.