gitbe

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2022 License: ISC Imports: 0 Imported by: 0

Documentation

Overview

Package gitbe contains the git backend types and filenames that are required by the legacypoliteia tool.

Index

Constants

View Source
const (
	// Proposal sub-directory paths. These paths are relative to the proposal
	// root directory.
	RecordPayloadPath = "payload/"
	DecredPluginPath  = "plugins/decred/"

	// Record metadata filename. The record metadata file is located in the
	// proposal root directory.
	RecordMetadataFilename = "recordmetadata.json"

	// Proposal file filenames. The proposal files are located in the payload
	// directory.
	IndexFilename            = "index.md"
	ProposalMetadataFilename = "proposalmetadata.json"

	// PublicKey is the git backend politeia public key. The public key changed
	// when politeia migrated to tstore.
	PublicKey = "a70134196c3cdf3f85f8af6abaa38c15feb7bccf5e6d3db6212358363465e502"
)
View Source
const (
	// Journal filenames
	CommentsJournalFilename = "comments.journal"
	BallotJournalFilename   = "ballot.journal"

	// Journal actions
	JournalActionAdd     = "add"     // Add entry
	JournalActionDel     = "del"     // Delete entry
	JournalActionAddLike = "addlike" // Add comment like
)
View Source
const (
	// Metadata stream filenames
	MDStreamProposalGeneral = "00.metadata.txt"
	MDStreamStatusChanges   = "02.metadata.txt"
	MDStreamAuthorizeVote   = "13.metadata.txt"
	MDStreamStartVote       = "14.metadata.txt"
	MDStreamStartVoteReply  = "15.metadata.txt"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizeVote

type AuthorizeVote struct {
	// Generated by decredplugin
	Version   uint   `json:"version"`   // Version of this structure
	Receipt   string `json:"receipt"`   // Server signature of client signature
	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp

	// Generated by client
	Action    string `json:"action"`    // Authorize or revoke
	Token     string `json:"token"`     // Proposal censorship token
	Signature string `json:"signature"` // Signature of token+version+action
	PublicKey string `json:"publickey"` // Pubkey used for signature
}

AuthorizeVote is an MDStream that is used to indicate that a proposal has been finalized and is ready to be voted on. The signature and public key are from the proposal author. The author can revoke a previously sent vote authorization by setting the Action field to revoke.

type CastVote

type CastVote struct {
	Token     string `json:"token"`
	Ticket    string `json:"ticket"`
	VoteBit   string `json:"votebit"`
	Signature string `json:"signature"`
}

CastVote is a signed vote.

Signature is the signature of the Token+Ticket+VoteBit.

type CastVoteJournal

type CastVoteJournal struct {
	CastVote CastVote `json:"castvote"`
	Receipt  string   `json:"receipt"` // Server receipt
}

CastVoteJournal represents a ballot journal entry.

type CensorComment

type CensorComment struct {
	Token     string `json:"token"`     // Censorship token
	CommentID string `json:"commentid"` // Comment ID
	Reason    string `json:"reason"`    // Reason comment was censored
	Signature string `json:"signature"` // Admin signature
	PublicKey string `json:"publickey"` // Admin public key

	// Generated by the server
	Receipt   string `json:"receipt"`   // Server receipt
	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp
}

CensorComment is a journal entry for a JournalActionDel action.

Signature is the admin signature of the Token+CommentID+Reason.

Receipt is the server signature of the admin signature.

type Comment

type Comment struct {
	Token     string `json:"token"`     // Censorship token
	ParentID  string `json:"parentid"`  // Parent comment ID
	Comment   string `json:"comment"`   // Comment text
	Signature string `json:"signature"` // Client signature
	PublicKey string `json:"publickey"` // Client public key
	CommentID string `json:"commentid"` // Comment ID
	Receipt   string `json:"receipt"`   // Server receipt
	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp

	// The following fields exist but will always be their zero value. This
	// is the result of the initial implementation including these fields in
	// error.
	TotalVotes  uint64 `json:"totalvotes"`  // Total number of up/down votes
	ResultVotes int64  `json:"resultvotes"` // Vote score
	Censored    bool   `json:"censored"`    // Has this comment been censored
}

Comment is the journal entry for a JournalActionAdd action.

Signature is the client signature of the Token+ParentID+Comment.

Receipt is the server signature of the client signature.

type JournalAction

type JournalAction struct {
	Version string `json:"version"`
	Action  string `json:"action"`
}

JournalAction prefixes and determines what the next structure is in the JSON journal.

Version is used to determine what version of the comment journal structure follows.

type LikeComment

type LikeComment struct {
	Token     string `json:"token"`     // Censorship token
	CommentID string `json:"commentid"` // Comment ID
	Action    string `json:"action"`    // Up or downvote (1, -1)
	Signature string `json:"signature"` // Client signature
	PublicKey string `json:"publickey"` // Client public key

	// Generated by the server
	Receipt   string `json:"receipt"`   // Server receipt
	Timestamp int64  `json:"timestamp"` // Received UNIX timestamp
}

LikeComment is the journal entry for a JournalActionAddLike action.

Signature is the client signature of the Token+CommentID+Action.

Receipt is the server signature of the client signature.

type MDStatusT

type MDStatusT int

MDStatusT represents a record metadata status.

const (
	MDStatusInvalid           MDStatusT = 0
	MDStatusUnvetted          MDStatusT = 1
	MDStatusVetted            MDStatusT = 2
	MDStatusCensored          MDStatusT = 3
	MDStatusIterationUnvetted MDStatusT = 4
	MDStatusArchived          MDStatusT = 5
)

type ProposalGeneralV2

type ProposalGeneralV2 struct {
	Version   uint64 `json:"version"`   // Struct version
	Timestamp int64  `json:"timestamp"` // Last update of proposal
	PublicKey string `json:"publickey"` // Key used for signature
	Signature string `json:"signature"` // Proposal signature
}

ProposalGeneralV2 represents general metadata for a proposal.

Signature is the signature of the proposal merkle root. The merkle root contains the ordered files and metadata digests. The file digests are first in the ordering.

Differences between v1 and v2: * Name has been removed and is now part of proposal metadata. * Signature has been updated to include propoposal metadata.

type ProposalMetadata

type ProposalMetadata struct {
	Name   string `json:"name"`             // Proposal name
	LinkTo string `json:"linkto,omitempty"` // Token of proposal to link to
	LinkBy int64  `json:"linkby,omitempty"` // UNIX timestamp of RFP deadline
}

ProposalMetadata contains metadata that is specified by the user on proposal submission. It is attached to a proposal submission as a politeiawww Metadata object and is saved to politeiad as a File, not as a MetadataStream. The filename is defined by FilenameProposalMetadata.

The reason it is saved to politeiad as a File is because politeiad only includes Files in the merkle root calculation. This is user defined metadata so it must be included in the proposal signature on submission. If it were saved to politeiad as a MetadataStream then it would not be included in the merkle root, thus causing an error where the client calculated merkle root if different than the politeiad calculated merkle root.

type RecordMetadata

type RecordMetadata struct {
	Version   uint64    `json:"version"`   // Version of the scruture
	Iteration uint64    `json:"iteration"` // Iteration count of record
	Status    MDStatusT `json:"status"`    // Current status of the record
	Merkle    string    `json:"merkle"`    // Merkle root of all files in record
	Timestamp int64     `json:"timestamp"` // Last updated
	Token     string    `json:"token"`     // Record authentication token
}

RecordMetadata is the metadata of a record.

type RecordStatusChangeV2

type RecordStatusChangeV2 struct {
	Version             uint          `json:"version"` // Version of this struct
	NewStatus           RecordStatusT `json:"newstatus"`
	StatusChangeMessage string        `json:"statuschangemessage,omitempty"`
	Signature           string        `json:"signature"`
	AdminPubKey         string        `json:"adminpubkey"`
	Timestamp           int64         `json:"timestamp"`
}

RecordStatusChangeV2 represents a politeiad record status change and is used to store additional status change metadata that would not otherwise be captured by the politeiad status change routes.

V2 adds the Signature field, which was erroneously left out of V1.

Signature of is the signature of Token + NewStatus + StatusChangeMessage.

type RecordStatusT

type RecordStatusT int
var (
	RecordStatusInvalid           RecordStatusT = 0
	RecordStatusNotFound          RecordStatusT = 1
	RecordStatusNotReviewed       RecordStatusT = 2
	RecordStatusCensored          RecordStatusT = 3
	RecordStatusPublic            RecordStatusT = 4
	RecordStatusUnreviewedChanges RecordStatusT = 5
	RecordStatusArchived          RecordStatusT = 6
)

type StartVoteReply

type StartVoteReply struct {
	Version          uint     `json:"version"`          // Version of this struct
	StartBlockHeight string   `json:"startblockheight"` // Block height
	StartBlockHash   string   `json:"startblockhash"`   // Block hash
	EndHeight        string   `json:"endheight"`        // Height of vote end
	EligibleTickets  []string `json:"eligibletickets"`  // Valid voting tickets
}

StartVoteReply is the reply to StartVote.

type StartVoteV1

type StartVoteV1 struct {
	Version   uint   `json:"version"`   // Version of this structure
	PublicKey string `json:"publickey"` // Key used for signature
	Vote      VoteV1 `json:"vote"`      // Vote + options
	Signature string `json:"signature"` // Signature of token
}

StartVoteV1 was formerly used to start a proposal vote, but is not longer accepted. A StartVoteV2 must be used to start a proposal vote.

type StartVoteV2

type StartVoteV2 struct {
	Version   uint   `json:"version"`   // Version of this structure
	PublicKey string `json:"publickey"` // Key used for signature
	Vote      VoteV2 `json:"vote"`      // Vote options and params
	Signature string `json:"signature"` // Signature of Vote hash
}

StartVoteV2 is used to start a proposal vote.

The message being signed is the SHA256 digest of the VoteV2 JSON byte slice.

Differences between StartVoteV1 and StartVoteV2:

  • Signature is the signature of a hash of the Vote struct. It was previously the signature of just the proposal token.
  • Vote is now a VoteV2. See the VoteV2 comment for more details.

type VoteOption

type VoteOption struct {
	Id          string `json:"id"`
	Description string `json:"description"`
	Bits        uint64 `json:"bits"`
}

VoteOption describes a single vote option.

type VoteT

type VoteT int

VoteT represents the different type of votes.

var (
	VoteTypeInvalid  VoteT = 0
	VoteTypeStandard VoteT = 1
	VoteTypeRunoff   VoteT = 2
)

type VoteV1

type VoteV1 struct {
	Token            string       `json:"token"`
	Mask             uint64       `json:"mask"`
	Duration         uint32       `json:"duration"`
	QuorumPercentage uint32       `json:"quorumpercentage"`
	PassPercentage   uint32       `json:"passpercentage"`
	Options          []VoteOption `json:"options"`
}

VoteV1 represents the vote options and parameters for a StartVoteV1.

type VoteV2

type VoteV2 struct {
	Token            string       `json:"token"`
	ProposalVersion  uint32       `json:"proposalversion"`
	Type             VoteT        `json:"type"`
	Mask             uint64       `json:"mask"`
	Duration         uint32       `json:"duration"`
	QuorumPercentage uint32       `json:"quorumpercentage"`
	PassPercentage   uint32       `json:"passpercentage"`
	Options          []VoteOption `json:"options"`
}

VoteV2 represents the vote options and vote parameters for a StartVoteV2.

Differences between VoteV1 and VoteV2:

  • Added the ProposalVersion field that specifies the version of the proposal that is being voted on. This was added so that the proposal version is explicitly included in the StartVote signature.
  • Added a Type field in order to specify the vote type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL