Documentation ¶
Index ¶
- Constants
- Variables
- func Migrate(partDB db.Accessor) error
- type Participation
- func (part Participation) Address() basics.Address
- func (part Participation) GenerateRegistrationTransaction(fee basics.MicroNovas, txnFirstValid, txnLastValid basics.Round, ...) transactions.Transaction
- func (part Participation) ID() ParticipationID
- func (part Participation) OverlapsInterval(first, last basics.Round) bool
- func (part Participation) StateProofSigner() *merklesignature.Secrets
- func (part Participation) StateProofVerifier() *merklesignature.Verifier
- func (part Participation) VRFSecrets() *crypto.VRFSecrets
- func (part Participation) ValidInterval() (first, last basics.Round)
- func (part Participation) VotingSecrets() *crypto.OneTimeSignatureSecrets
- type ParticipationAction
- type ParticipationID
- type ParticipationKeyIdentity
- func (_ *ParticipationKeyIdentity) CanMarshalMsg(z interface{}) bool
- func (_ *ParticipationKeyIdentity) CanUnmarshalMsg(z interface{}) bool
- func (id ParticipationKeyIdentity) ID() ParticipationID
- func (z *ParticipationKeyIdentity) MarshalMsg(b []byte) (o []byte)
- func (z *ParticipationKeyIdentity) MsgIsZero() bool
- func (z *ParticipationKeyIdentity) Msgsize() (s int)
- func (id *ParticipationKeyIdentity) ToBeHashed() (protocol.HashID, []byte)
- func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error)
- type ParticipationRecord
- type ParticipationRecordForRound
- type ParticipationRegistry
- type PersistedParticipation
- func FillDBWithParticipationKeys(store db.Accessor, address basics.Address, firstValid, lastValid basics.Round, ...) (part PersistedParticipation, err error)
- func RestoreParticipation(store db.Accessor) (acc PersistedParticipation, err error)
- func RestoreParticipationWithSecrets(store db.Accessor) (PersistedParticipation, error)
- func (part PersistedParticipation) Close()
- func (part PersistedParticipation) DeleteOldKeys(current basics.Round, proto config.ConsensusParams) <-chan error
- func (part PersistedParticipation) Persist() error
- func (part PersistedParticipation) PersistNewParent() error
- func (part PersistedParticipation) PersistWithSecrets() error
- type Root
- type SortUint64
- type StateProofKeys
- func (_ StateProofKeys) CanMarshalMsg(z interface{}) bool
- func (_ *StateProofKeys) CanUnmarshalMsg(z interface{}) bool
- func (z StateProofKeys) MarshalMsg(b []byte) (o []byte)
- func (z StateProofKeys) MsgIsZero() bool
- func (z StateProofKeys) Msgsize() (s int)
- func (z *StateProofKeys) UnmarshalMsg(bts []byte) (o []byte, err error)
- type StateProofRecordForRound
- type StateProofVerifier
- func (_ *StateProofVerifier) CanMarshalMsg(z interface{}) bool
- func (_ *StateProofVerifier) CanUnmarshalMsg(z interface{}) bool
- func (z *StateProofVerifier) MarshalMsg(b []byte) []byte
- func (z *StateProofVerifier) MsgIsZero() bool
- func (z *StateProofVerifier) Msgsize() int
- func (z *StateProofVerifier) UnmarshalMsg(bts []byte) ([]byte, error)
Constants ¶
const PartTableSchemaName = "parttable"
PartTableSchemaName is the name of the table in the Schema Versions table storing the table + version details
const PartTableSchemaVersion = 3
PartTableSchemaVersion is the latest version of the PartTable schema
Variables ¶
var ErrActiveKeyNotFound = errors.New("no active participation key found for account")
ErrActiveKeyNotFound is used when attempting to update an account with no active key
var ErrAlreadyInserted = errors.New("these participation keys are already inserted")
ErrAlreadyInserted is used when inserting a key which already exists in the registry.
var ErrInvalidRegisterRange = errors.New("key would not be active within range")
ErrInvalidRegisterRange is used when attempting to register a participation key on a round that is out of range.
var ErrMultipleKeysForID = errors.New("multiple valid keys found for the same participationID")
ErrMultipleKeysForID this should never happen. Multiple keys with the same participationID
var ErrMultipleValidKeys = errors.New("multiple valid keys found while recording key usage")
ErrMultipleValidKeys is used when recording a result but multiple valid keys were found. This should not be possible.
var ErrNoKeyForID = errors.New("no valid key found for the participationID")
ErrNoKeyForID there may be cases where a key is deleted and used at the same time, so this error should be handled.
var ErrParticipationIDNotFound = errors.New("the participation ID was not found")
ErrParticipationIDNotFound is used when attempting to update a set of keys which do not exist.
var ErrRequestedRoundOutOfRange = errors.New("request range is not within the validity range")
ErrRequestedRoundOutOfRange is used when the requested round for GetForRound is outside the valid range of this participation
var ErrSecretNotFound = errors.New("the participation ID did not have secrets for the requested round")
ErrSecretNotFound is used when attempting to lookup secrets for a particular round.
var ErrUnknownParticipationAction = errors.New("unknown participation action")
ErrUnknownParticipationAction is used when record is given something other than the known actions.
var ErrUnsupportedSchema = fmt.Errorf("unsupported participation file schema version (expected %d)", PartTableSchemaVersion)
ErrUnsupportedSchema is the error returned when the PartTable schema version is wrong.
Functions ¶
Types ¶
type Participation ¶
type Participation struct { Parent basics.Address VRF *crypto.VRFSecrets Voting *crypto.OneTimeSignatureSecrets // StateProofSecrets is used to sign compact certificates. /* StateProofSecrets는 컴팩트 인증서에 서명할 때 사용됨 */ StateProofSecrets *merklesignature.Secrets // The first and last rounds for which this account is valid, respectively. // // When lastValid has concluded, this set of secrets is destroyed. FirstValid basics.Round LastValid basics.Round KeyDilution uint64 }
A Participation encapsulates a set of secrets which allows a root to participate in consensus. All such accounts are associated with a parent root account via the Address (although this parent account may not be resident on this machine). Participations are allowed to vote on a user's behalf for some range of rounds. After this range, all remaining secrets are destroyed. For correctness, all Roots should have no more than one Participation globally active at any time. If this condition is violated, the Root may equivocate. (Algorand tolerates a limited fraction of misbehaving accounts.)
Participation은 root가 합의에 참여할 수 있게 하는 비밀 집합(여러종류의 비밀들)을 캡슐화한다. 모든 계정은 주소를 통해 root계정과 연결되어 있다.(부모 계정(root)은 머신상에 존재하지 않는다? 논리적으로만 존재한다는건가? avm에 올라가지 않는다는건가? 이 상태머신(흠.. 어떤 상태머신이지?)에는 존재하지 않는다. 참여계정만 존재하는건가?) Participation은 유저가 특정 라운드만큼 투표할 수 있는 권한이다. 모든 라운드가 끝나면 남아있는 비밀(sectret)은 모두 파괴된다. 정확성을 위해 모든 Root는 한번에 하나의 활성화된 참여만 가질 수 있다. 이것이 위배되면 root는 모호해진다(알고랜드는 약각의 오작동은 허용) <= equivocate뜻이 모호해진다여서 이렇게 썼는데 뭐가 모호해진다는건지 모르겠네.. (msgp가 Paticipation을 무시한다? 즉, 동작하지 않는다는건가? 흠.. 모호하다고 하긴했는데 동작을 안하는게 맞겠지?)
func (Participation) Address ¶
func (part Participation) Address() basics.Address
Address returns the root account under which this participation account is registered.
func (Participation) GenerateRegistrationTransaction ¶
func (part Participation) GenerateRegistrationTransaction(fee basics.MicroNovas, txnFirstValid, txnLastValid basics.Round, leaseBytes [32]byte, includeStateProofKeys bool) transactions.Transaction
GenerateRegistrationTransaction returns a transaction object for registering a Participation with its parent.
func (Participation) ID ¶
func (part Participation) ID() ParticipationID
ID computes a ParticipationID.
func (Participation) OverlapsInterval ¶
func (part Participation) OverlapsInterval(first, last basics.Round) bool
OverlapsInterval returns true if the partkey is valid at all within the range of rounds (inclusive)
func (Participation) StateProofSigner ¶
func (part Participation) StateProofSigner() *merklesignature.Secrets
StateProofSigner returns the key used to sign on Compact Certificates. might return nil!
func (Participation) StateProofVerifier ¶
func (part Participation) StateProofVerifier() *merklesignature.Verifier
StateProofVerifier returns the verifier for the StateProof keys.
func (Participation) VRFSecrets ¶
func (part Participation) VRFSecrets() *crypto.VRFSecrets
VRFSecrets returns the VRF secrets associated with this Participation account.
func (Participation) ValidInterval ¶
func (part Participation) ValidInterval() (first, last basics.Round)
ValidInterval returns the first and last rounds for which this participation account is valid.
func (Participation) VotingSecrets ¶
func (part Participation) VotingSecrets() *crypto.OneTimeSignatureSecrets
VotingSecrets returns the voting secrets associated with this Participation account.
type ParticipationAction ¶
type ParticipationAction int
ParticipationAction is used when recording participation actions.
ParticipationAction은 합의 참여자가 할 수 있는 행동을 저장하는 변수이다. 1. 투표 참여 2. 블록 제안 3. 상태증명
const ( Vote ParticipationAction = iota BlockProposal StateProof )
ParticipationAction types
type ParticipationID ¶
ParticipationID identifies a particular set of participation keys.
ParticipationID는 특정 참여키들의 집합을 식별하는 id이다
func ParseParticipationID ¶
func ParseParticipationID(str string) (d ParticipationID, err error)
ParseParticipationID takes a string and returns a ParticipationID object
func (ParticipationID) IsZero ¶
func (pid ParticipationID) IsZero() bool
IsZero returns true if the ParticipationID is all zero bytes.
func (ParticipationID) String ¶
func (pid ParticipationID) String() string
String prints a b32 version of this ID.
type ParticipationKeyIdentity ¶
type ParticipationKeyIdentity struct { Parent basics.Address `codec:"addr"` VRFSK crypto.VrfPrivkey `codec:"vrfsk"` VoteID crypto.OneTimeSignatureVerifier `codec:"vote-id"` FirstValid basics.Round `codec:"fv"` LastValid basics.Round `codec:"lv"` KeyDilution uint64 `codec:"kd"` // contains filtered or unexported fields }
ParticipationKeyIdentity is for msgpack encoding the participation data. ParticipationKeyIdentity는 participation을 msgpack인코딩한 데이터이다. .
func (*ParticipationKeyIdentity) CanMarshalMsg ¶
func (_ *ParticipationKeyIdentity) CanMarshalMsg(z interface{}) bool
func (*ParticipationKeyIdentity) CanUnmarshalMsg ¶
func (_ *ParticipationKeyIdentity) CanUnmarshalMsg(z interface{}) bool
func (ParticipationKeyIdentity) ID ¶
func (id ParticipationKeyIdentity) ID() ParticipationID
ID creates a ParticipationID hash from the identity file. => ID는 identity file로부터 ParticipationID hash를 생성한다.
func (*ParticipationKeyIdentity) MarshalMsg ¶
func (z *ParticipationKeyIdentity) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (*ParticipationKeyIdentity) MsgIsZero ¶
func (z *ParticipationKeyIdentity) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (*ParticipationKeyIdentity) Msgsize ¶
func (z *ParticipationKeyIdentity) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ParticipationKeyIdentity) ToBeHashed ¶
func (id *ParticipationKeyIdentity) ToBeHashed() (protocol.HashID, []byte)
ToBeHashed implements the Hashable interface. => Hashable인터페이스를 구현했다.
func (*ParticipationKeyIdentity) UnmarshalMsg ¶
func (z *ParticipationKeyIdentity) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type ParticipationRecord ¶
type ParticipationRecord struct { ParticipationID ParticipationID Account basics.Address FirstValid basics.Round LastValid basics.Round KeyDilution uint64 LastVote basics.Round LastBlockProposal basics.Round LastStateProof basics.Round EffectiveFirst basics.Round EffectiveLast basics.Round StateProof *StateProofVerifier VRF *crypto.VRFSecrets // 메시지에 대해 위조할 수 없는 서명 Voting *crypto.OneTimeSignatureSecrets }
ParticipationRecord contains all metadata relating to a set of participation keys.
participation keys들의 집합과 관련된 모든 메타데이터를 포함한다.
func (ParticipationRecord) Duplicate ¶
func (r ParticipationRecord) Duplicate() ParticipationRecord
Duplicate creates a copy of the current object. This is required once secrets are stored.
func (ParticipationRecord) IsZero ¶
func (r ParticipationRecord) IsZero() bool
IsZero returns true if the object contains zero values.
func (ParticipationRecord) OverlapsInterval ¶
func (r ParticipationRecord) OverlapsInterval(first, last basics.Round) bool
OverlapsInterval returns true if the partkey is valid at all within the range of rounds (inclusive)
type ParticipationRecordForRound ¶
type ParticipationRecordForRound struct {
ParticipationRecord
}
ParticipationRecordForRound contains participant's secrets that corresponds to one specific round. In Addition, it also returns the participation metadata
func (ParticipationRecordForRound) IsZero ¶
func (r ParticipationRecordForRound) IsZero() bool
IsZero returns true if the object contains zero values.
func (*ParticipationRecordForRound) VotingSigner ¶
func (r *ParticipationRecordForRound) VotingSigner() crypto.OneTimeSigner
VotingSigner returns the voting secrets associated with this Participation account, together with the KeyDilution value.
OneTimeSigner는 메시지에 위조할 수 없는 일회용 서명을 할 수 있는 비밀정보이다!
type ParticipationRegistry ¶
type ParticipationRegistry interface { // Insert adds a record to storage and computes the ParticipationID Insert(record Participation) (ParticipationID, error) // AppendKeys appends state proof keys to an existing Participation record. Keys can only be appended // once, an error will occur when the data is flushed when inserting a duplicate key. AppendKeys(id ParticipationID, keys StateProofKeys) error // Delete removes a record from storage. Delete(id ParticipationID) error // DeleteExpired removes all records from storage which are expired on the given round. DeleteExpired(round basics.Round) error // Get a participation record. Get(id ParticipationID) ParticipationRecord // GetAll of the participation records. GetAll() []ParticipationRecord // GetForRound fetches a record with voting secrets for a particular round. GetForRound(id ParticipationID, round basics.Round) (ParticipationRecordForRound, error) // GetStateProofForRound fetches a record with stateproof secrets for a particular round. GetStateProofForRound(id ParticipationID, round basics.Round) (StateProofRecordForRound, error) // Register updates the EffectiveFirst and EffectiveLast fields. If there are multiple records for the account // then it is possible for multiple records to be updated. Register(id ParticipationID, on basics.Round) error // Record sets the Last* field for the active ParticipationID for the given account. Record(account basics.Address, round basics.Round, participationType ParticipationAction) error // Flush ensures that all changes have been written to the underlying data store. Flush(timeout time.Duration) error // Close any resources used to implement the interface. Close() }
ParticipationRegistry contain all functions for interacting with the Participation Registry.
Participation Registry 구현체에는 합의 참여자들(Participation)에 대한 정보를 저장할 수 있는 자료구조가 있다. 따라서 이 인터페이스는 그곳에 참가자 정보를 CRUD할 수 있는 인터페이스를 제공한다.
func MakeParticipationRegistry ¶
MakeParticipationRegistry creates a db.Accessor backed ParticipationRegistry.
type PersistedParticipation ¶
type PersistedParticipation struct { Participation Store db.Accessor }
PersistedParticipation encapsulates the static state of the participation for a single address at any given moment, while providing the ability to handle persistence and deletion of secrets.
func FillDBWithParticipationKeys ¶
func FillDBWithParticipationKeys(store db.Accessor, address basics.Address, firstValid, lastValid basics.Round, keyDilution uint64) (part PersistedParticipation, err error)
FillDBWithParticipationKeys initializes the passed database with participation keys
func RestoreParticipation ¶
func RestoreParticipation(store db.Accessor) (acc PersistedParticipation, err error)
RestoreParticipation restores a Participation from a database handle.
func RestoreParticipationWithSecrets ¶
func RestoreParticipationWithSecrets(store db.Accessor) (PersistedParticipation, error)
RestoreParticipationWithSecrets restores a Participation from a database handle. In addition, this function also restores all stateproof secrets
func (PersistedParticipation) Close ¶
func (part PersistedParticipation) Close()
Close closes the underlying database handle.
func (PersistedParticipation) DeleteOldKeys ¶
func (part PersistedParticipation) DeleteOldKeys(current basics.Round, proto config.ConsensusParams) <-chan error
DeleteOldKeys securely deletes ephemeral keys for rounds strictly older than the given round.
func (PersistedParticipation) Persist ¶
func (part PersistedParticipation) Persist() error
Persist writes a Participation out to a database on the disk
func (PersistedParticipation) PersistNewParent ¶
func (part PersistedParticipation) PersistNewParent() error
PersistNewParent writes a new parent address to the partkey database.
func (PersistedParticipation) PersistWithSecrets ¶
func (part PersistedParticipation) PersistWithSecrets() error
PersistWithSecrets writes Participation struct to the database along with all the secrets it contains
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
A Root encapsulates a set of secrets which controls some store of money.
A Root is authorized to spend money and create Participations for which this account is the parent.
It handles persistence and secure deletion of secrets.
Root는 어떤 돈의 저장소(?)를 통제하는 비밀세트(rootkey)를 압축하기위해 사용한다. Root는 돈을 사용하고 이 계정을 부모로 두는 Participations를 생성하기 위한 권한을 받는다(참여노드를 만드는건가?) Root는 비밀의 영구저장 및 안전한 삭제를 담당한다.
func GenerateRoot ¶
GenerateRoot uses the system's source of randomness to generate an account.
func ImportRoot ¶
ImportRoot uses a provided source of randomness to instantiate an account.
func RestoreRoot ¶
RestoreRoot restores a Root from a database handle.
func (Root) Secrets ¶
func (root Root) Secrets() *crypto.SignatureSecrets
Secrets returns the signing secrets associated with the Root account.
type SortUint64 ¶
type SortUint64 = basics.SortUint64
SortUint64 implements sorting by uint64 keys for canonical encoding of maps in msgpack format.
type StateProofKeys ¶
type StateProofKeys []merklesignature.KeyRoundPair
StateProofKeys represents a set of ephemeral stateproof keys with their corresponding round
특정 라운드에서 stateproof keys 정보를 나타냄 KeyRoundPair{ Round uint64 `codec:"rnd"` Key *crypto.FalconSigner `codec:"key"` }
func (StateProofKeys) CanMarshalMsg ¶
func (_ StateProofKeys) CanMarshalMsg(z interface{}) bool
func (*StateProofKeys) CanUnmarshalMsg ¶
func (_ *StateProofKeys) CanUnmarshalMsg(z interface{}) bool
func (StateProofKeys) MarshalMsg ¶
func (z StateProofKeys) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (StateProofKeys) MsgIsZero ¶
func (z StateProofKeys) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (StateProofKeys) Msgsize ¶
func (z StateProofKeys) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*StateProofKeys) UnmarshalMsg ¶
func (z *StateProofKeys) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type StateProofRecordForRound ¶
type StateProofRecordForRound struct { ParticipationRecord //Signer는 지정된 라운드에 대한 StateProof 서명자를 나타냅니다. StateProofSecrets *merklesignature.Signer }
StateProofRecordForRound contains participant's state proof secrets that corresponds to one specific round. In Addition, it also returns the participation metadata. If there are no secrets for the round a nil is returned in Stateproof field.
StateProofRecordForRound는 하나의 특정 라운드 참가자의 state proof secrets을 포함합니다. 또한 참여 메타데이터도 반환합니다. 라운드에 대한 secrets이 없으면 Stateproof 필드에 nil이 반환됩니다.
type StateProofVerifier ¶
type StateProofVerifier merklesignature.Verifier
StateProofVerifier defined the type used for the stateproofs public key
StateProof를 검증하는 검증자
func (*StateProofVerifier) CanMarshalMsg ¶
func (_ *StateProofVerifier) CanMarshalMsg(z interface{}) bool
func (*StateProofVerifier) CanUnmarshalMsg ¶
func (_ *StateProofVerifier) CanUnmarshalMsg(z interface{}) bool
func (*StateProofVerifier) MarshalMsg ¶
func (z *StateProofVerifier) MarshalMsg(b []byte) []byte
MarshalMsg implements msgp.Marshaler
func (*StateProofVerifier) MsgIsZero ¶
func (z *StateProofVerifier) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (*StateProofVerifier) Msgsize ¶
func (z *StateProofVerifier) Msgsize() int
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*StateProofVerifier) UnmarshalMsg ¶
func (z *StateProofVerifier) UnmarshalMsg(bts []byte) ([]byte, error)
UnmarshalMsg implements msgp.Unmarshaler