-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add double marry malfeasance proof (#6219)
## Motivation Closes #6218
- Loading branch information
Showing
19 changed files
with
857 additions
and
175 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,27 +1,60 @@ | ||
package wire | ||
|
||
import ( | ||
"github.com/spacemeshos/go-scale" | ||
|
||
"github.com/spacemeshos/go-spacemesh/common/types" | ||
"github.com/spacemeshos/go-spacemesh/signing" | ||
) | ||
|
||
//go:generate scalegen | ||
|
||
// MerkleTreeIndex is the index of the leaf containing the given field in the merkle tree. | ||
type MerkleTreeIndex uint16 | ||
|
||
const ( | ||
PublishEpochIndex MerkleTreeIndex = iota | ||
PositioningATXIndex | ||
CoinbaseIndex | ||
InitialPostIndex | ||
PreviousATXsRootIndex | ||
NIPostsRootIndex | ||
VRFNonceIndex | ||
MarriagesRootIndex | ||
MarriageATXIndex | ||
) | ||
|
||
// ProofType is an identifier for the type of proof that is encoded in the ATXProof. | ||
type ProofType byte | ||
|
||
const ( | ||
DoublePublish ProofType = iota + 1 | ||
DoubleMarry | ||
DoubleMerge | ||
InvalidPost | ||
// TODO(mafa): legacy types for future migration to new malfeasance proofs. | ||
LegacyDoublePublish ProofType = 0x00 | ||
LegacyInvalidPost ProofType = 0x01 | ||
LegacyInvalidPrevATX ProofType = 0x02 | ||
|
||
DoublePublish ProofType = 0x10 | ||
DoubleMarry ProofType = 0x11 | ||
DoubleMerge ProofType = 0x12 | ||
InvalidPost ProofType = 0x13 | ||
) | ||
|
||
// ProofVersion is an identifier for the version of the proof that is encoded in the ATXProof. | ||
type ProofVersion byte | ||
|
||
type ATXProof struct { | ||
// LayerID is the layer in which the proof was created. This can be used to implement different versions of the ATX | ||
// proof in the future. | ||
Layer types.LayerID | ||
// Version is the version identifier of the proof. This can be used to extend the ATX proof in the future. | ||
Version ProofVersion | ||
// ProofType is the type of proof that is being provided. | ||
ProofType ProofType | ||
// Proof is the actual proof. Its type depends on the ProofType. | ||
Proof []byte `scale:"max=1048576"` // max size of proof is 1MiB | ||
} | ||
|
||
// Proof is an interface for all types of proofs that can be provided in an ATXProof. | ||
// Generally the proof should be able to validate itself and be scale encoded. | ||
type Proof interface { | ||
scale.Encodable | ||
|
||
Valid(edVerifier *signing.EdVerifier) (types.NodeID, error) | ||
} |
Oops, something went wrong.