Documentation
¶
Index ¶
- Constants
- Variables
- func EncryptAESGCM(key []byte, src []byte) ([]byte, error)
- func EncryptArmorPrivKey(privKey ed25519.PrivKey, passphrase string, hint string) (string, error)
- func GenMorseAccount(index uint64) *migrationtypes.MorseAccount
- func GenMorseApplication(idx uint64) *migrationtypes.MorseApplication
- func GenMorseApplicationStakeAmount(index uint64) int64
- func GenMorseClaimableAccount(index uint64, distributionFn func(uint64) MorseAccountActorType) (*migrationtypes.MorseClaimableAccount, error)
- func GenMorsePrivateKey(seed uint64) cometcrypto.PrivKey
- func GenMorseSupplierStakeAmount(index uint64) int64
- func GenMorseUnstakedBalanceAmount(index uint64) int64
- func GenMorseValidator(idx uint64) *migrationtypes.MorseValidator
- func GenerateInvalidAddressMorseStateExportAndAccountState(t *testing.T) (*migrationtypes.MorseStateExport, *migrationtypes.MorseAccountState)
- func GenerateModuleAddressMorseStateExportAndAccountState(t *testing.T, moduleAccountNames []string) (*migrationtypes.MorseStateExport, *migrationtypes.MorseAccountState)
- func NewArmoredJson(kdf, salt, hint, ciphertext string) cmd.ArmoredJson
- func NewMorseStateExportAndAccountState(numAccounts int, distributionFn MorseAccountActorTypeDistributionFn) (export *migrationtypes.MorseStateExport, ...)
- func NewMorseStateExportAndAccountStateBytes(numAccounts int, distributionFn MorseAccountActorTypeDistributionFn) (morseStateExportBz []byte, morseAccountStateBz []byte, err error)
- func NewRoundRobinClusteredAllMorseAccountActorTypes(clusterSize uint64) func(index uint64) MorseAccountActorType
- type MorseAccountActorType
- func AllApplicationMorseAccountActorType(index uint64) MorseAccountActorType
- func AllSupplierMorseAccountActorType(index uint64) MorseAccountActorType
- func AllUnstakedMorseAccountActorType(index uint64) MorseAccountActorType
- func GetRoundRobinMorseAccountActorType(idx uint64) MorseAccountActorType
- func RoundRobinAllMorseAccountActorTypes(index uint64) MorseAccountActorType
- type MorseAccountActorTypeDistributionFn
Constants ¶
const ( MorseUnstakedActor = MorseAccountActorType(iota) MorseApplicationActor MorseSupplierActor // NumMorseAccountActorTypes is the number of MorseAccountActorTypes. // It takes advantage of the fact that the enum is zero-indexed. NumMorseAccountActorTypes )
Variables ¶
var BcryptSecurityParameter = 12
BcryptSecurityParameter is a var so that it can be changed within the lcd test Making the bcrypt security parameter a var shouldn't be a security issue: One can't verify an invalid key by maliciously changing the bcrypt parameter during a runtime vulnerability. The main security threat this then exposes would be something that changes this during runtime before the user creates their key. This vulnerability must succeed to update this to that same value before every subsequent call to the keys command in future startups / or the attacker must get access to the filesystem. However, with a similar threat model (changing variables in runtime), one can cause the user to sign a different tx than what they see, which is a significantly cheaper attack then breaking a bcrypt hash. (Recall that the nonce still exists to break rainbow tables) For further notes on security parameter choice, see README.md
Functions ¶
func EncryptArmorPrivKey ¶ added in v0.1.2
EncryptArmorPrivKey encrypts the given private key using a random salt and the given passphrase with the AES-256-GCM algorithm. It then encapsulates the ciphertext, salt, and hint in an ArmoredJson struct and returns it as a JSON-encoded string.
func GenMorseAccount ¶ added in v0.0.14
func GenMorseAccount(index uint64) *migrationtypes.MorseAccount
GenMorseAccount returns a new MorseAccount fixture. The given index is used to deterministically generate the account's address and unstaked balance.
func GenMorseApplication ¶ added in v0.0.14
func GenMorseApplication(idx uint64) *migrationtypes.MorseApplication
GenMorseApplication returns a new MorseApplication fixture. The given index is used to deterministically generate the application's address and staked tokens.
func GenMorseApplicationStakeAmount ¶ added in v0.0.14
GenMorseApplicationStakeAmount returns an amount by applying the given index to a pattern such that the generated amount is unique to the application stake (as opposed to the unstaked balance or supplier stake) and the given index. E.g.: - GenMorseApplicationStakeAmount(0) = 100010 - GenMorseApplicationStakeAmount(1) = 200020 - GenMorseApplicationStakeAmount(10) = 1000100
func GenMorseClaimableAccount ¶ added in v0.0.14
func GenMorseClaimableAccount( index uint64, distributionFn func(uint64) MorseAccountActorType, ) (*migrationtypes.MorseClaimableAccount, error)
GenMorseClaimableAccount returns a new MorseClaimableAccount fixture. The given index is used to deterministically generate the account's address and staked tokens. The given distribution function is used to determine the account's actor type (and stake if applicable).
func GenMorsePrivateKey ¶ added in v0.0.14
func GenMorsePrivateKey(seed uint64) cometcrypto.PrivKey
GenMorsePrivateKey creates a new ed25519 private key from the given seed.
func GenMorseSupplierStakeAmount ¶ added in v0.0.14
GenMorseSupplierStakeAmount returns an amount by applying the given index to a pattern such that the generated amount is unique to the supplier stake (as opposed to the unstaked balance or application stake) and the given index. E.g.: - GenMorseApplicationStakeAmount(0) = 10100 - GenMorseApplicationStakeAmount(1) = 20200 - GenMorseApplicationStakeAmount(10) = 101000
func GenMorseUnstakedBalanceAmount ¶ added in v0.0.14
GenMorseUnstakedBalanceAmount returns an amount by applying the given index to a pattern such that the generated amount is unique to the unstaked balance (as opposed to actor stake(s)) and the given index. E.g.: - GenMorseApplicationStakeAmount(0) = 1000001 - GenMorseApplicationStakeAmount(1) = 2000002 - GenMorseApplicationStakeAmount(10) = 10000010
func GenMorseValidator ¶ added in v0.0.14
func GenMorseValidator(idx uint64) *migrationtypes.MorseValidator
GenMorseValidator returns a new MorseValidator fixture. The given index is used to deterministically generate the validator's address and staked tokens.
func GenerateInvalidAddressMorseStateExportAndAccountState ¶ added in v0.1.11
func GenerateInvalidAddressMorseStateExportAndAccountState(t *testing.T) (*migrationtypes.MorseStateExport, *migrationtypes.MorseAccountState)
GenerateInvalidAddressMorseStateExportAndAccountState generates a MorseStateExport and MorseAccountState with invalid addresses for the following cases, and for each actor type (i.e. unstaked, app, suppler): - invalid hex - too short - too long
func GenerateModuleAddressMorseStateExportAndAccountState ¶ added in v0.1.11
func GenerateModuleAddressMorseStateExportAndAccountState(t *testing.T, moduleAccountNames []string) (*migrationtypes.MorseStateExport, *migrationtypes.MorseAccountState)
GenerateModuleAddressMorseStateExportAndAccountState generates a MorseStateExport and MorseAccountState with the following module addresses, and ONLY as a liquid account: - dao - fee_collector - application_stake_tokens_pool - staked_tokens_pool
func NewArmoredJson ¶ added in v0.1.2
func NewArmoredJson(kdf, salt, hint, ciphertext string) cmd.ArmoredJson
NewArmoredJson returns a new ArmoredJson struct with the given fields.
func NewMorseStateExportAndAccountState ¶
func NewMorseStateExportAndAccountState( numAccounts int, distributionFn MorseAccountActorTypeDistributionFn, ) (export *migrationtypes.MorseStateExport, state *migrationtypes.MorseAccountState, err error)
NewMorseStateExportAndAccountState returns MorseStateExport and MorseAccountState structs populated with: - Random account addresses - Monotonically increasing balances/stakes - Unstaked, application, supplier accounts are distributed according to the given distribution function.
func NewMorseStateExportAndAccountStateBytes ¶
func NewMorseStateExportAndAccountStateBytes( numAccounts int, distributionFn MorseAccountActorTypeDistributionFn, ) (morseStateExportBz []byte, morseAccountStateBz []byte, err error)
NewMorseStateExportAndAccountStateBytes returns:
- A serialized MorseStateExport. This is the JSON output of `pocket util export-genesis-for-reset`. It is used to generate the MorseAccountState.
- Its corresponding MorseAccountState. This is the JSON output of `pocketd tx migration collect-morse-accounts`. It is used to persist the canonical Morse migration state (snapshot) from on Shannon.
The states are populated with: - Random account addresses - Monotonically increasing balances/stakes - Unstaked, application, supplier accounts are distributed according to the given distribution function.
func NewRoundRobinClusteredAllMorseAccountActorTypes ¶ added in v0.1.11
func NewRoundRobinClusteredAllMorseAccountActorTypes(clusterSize uint64) func(index uint64) MorseAccountActorType
NewRoundRobinClusteredAllMorseAccountActorTypes returns a function which returns a MorseAccountActorType for every index, cyclically returning "clusters" of each MorseAccountActorType; i.e. continuous account types of clusterSize. E.g. if clusterSize is 2, then the resulting actor type sequence would be: - 0: MorseUnstakedActor - 1: MorseUnstakedActor - 2: MorseApplicationActor - 3: MorseApplicationActor - 4: MorseSupplierActor - 5: MorseSupplierActor
Types ¶
type MorseAccountActorType ¶ added in v0.0.14
type MorseAccountActorType int
MorseAccountActorType is an enum which represents all possible staked and unstaked actor types which are considered in the migration module.
func AllApplicationMorseAccountActorType ¶ added in v0.0.14
func AllApplicationMorseAccountActorType(index uint64) MorseAccountActorType
AllApplicationMorseAccountActorType returns MorseApplicationActor for every index.
func AllSupplierMorseAccountActorType ¶ added in v0.0.14
func AllSupplierMorseAccountActorType(index uint64) MorseAccountActorType
AllSupplierMorseAccountActorType returns MorseSupplierActor for every index.
func AllUnstakedMorseAccountActorType ¶ added in v0.0.14
func AllUnstakedMorseAccountActorType(index uint64) MorseAccountActorType
AllUnstakedMorseAccountActorType returns MorseUnstakedActor for every index.
func GetRoundRobinMorseAccountActorType ¶ added in v0.1.2
func GetRoundRobinMorseAccountActorType(idx uint64) MorseAccountActorType
GetRoundRobinMorseAccountActorType returns the actor type for the given index, given a round-robin distribution.
func RoundRobinAllMorseAccountActorTypes ¶ added in v0.0.14
func RoundRobinAllMorseAccountActorTypes(index uint64) MorseAccountActorType
RoundRobinAllMorseAccountActorTypes cyclically returns each MorseAccountActorType, one after the other, as the index increases. It is used to map a test account index to the test actor that's generated.
type MorseAccountActorTypeDistributionFn ¶ added in v0.0.14
type MorseAccountActorTypeDistributionFn func(index uint64) MorseAccountActorType
MorseAccountActorTypeDistributionFn is a function which returns a MorseAccountActorType derived from the given index. It is intended to be used in conjunction with MorseStateExport and MorseAccountState fixture generation logic.
func NewSingleMorseAccountActorTypeFn ¶ added in v0.0.14
func NewSingleMorseAccountActorTypeFn(actorType MorseAccountActorType) MorseAccountActorTypeDistributionFn
NewSingleMorseAccountActorTypeFn returns a MorseAccountActorTypeDistributionFn which returns the given actor type for every index.