account

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const PartTableSchemaName = "parttable"

PartTableSchemaName is the name of the table in the Schema Versions table storing the table + version details

View Source
const PartTableSchemaVersion = 2

PartTableSchemaVersion is the latest version of the PartTable schema

Variables

View Source
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

func Migrate

func Migrate(partDB db.Accessor) error

Migrate is called when loading participation keys. Calls through to the migration helper and returns the result.

Types

type Participation

type Participation struct {
	Parent basics.Address

	VRF    *crypto.VRFSecrets
	Voting *crypto.OneTimeSignatureSecrets

	// 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.)

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.MicroAlgos, txnFirstValid, txnLastValid basics.Round, leaseBytes [32]byte) transactions.Transaction

GenerateRegistrationTransaction returns a transaction object for registering a Participation with its parent.

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) 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.

func (Participation) VotingSigner

func (part Participation) VotingSigner() crypto.OneTimeSigner

VotingSigner returns the voting secrets associated with this Participation account, together with the KeyDilution value.

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 (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.

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.

func GenerateRoot

func GenerateRoot(store db.Accessor) (Root, error)

GenerateRoot uses the system's source of randomness to generate an account.

func ImportRoot

func ImportRoot(store db.Accessor, seed [32]byte) (acc Root, err error)

ImportRoot uses a provided source of randomness to instantiate an account.

func RestoreRoot

func RestoreRoot(store db.Accessor) (acc Root, err error)

RestoreRoot restores a Root from a database handle.

func (Root) Address

func (root Root) Address() basics.Address

Address returns the address associated with the Root account.

func (Root) Secrets

func (root Root) Secrets() *crypto.SignatureSecrets

Secrets returns the signing secrets associated with the Root account.

Jump to

Keyboard shortcuts

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