auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressToKey

func AddressToKey(addr sdk.Address) []byte

func GetTxDecoder

func GetTxDecoder(cdc *wire.Codec) func([]byte) (sdk.Tx, sdk.Error)

JSON decode MsgSend.

func NewAnteHandler

func NewAnteHandler(am AccountMapper) sdk.AnteHandler

func NewHandler

func NewHandler(am AccountMapper) sdk.Handler

func RegisterCodec

func RegisterCodec(cdc *wire.Codec) *wire.Codec

func WithSigners

func WithSigners(ctx sdk.Context, account BaseAccount) sdk.Context

WithSigners add the signer to the context

Types

type AccountMapper

type AccountMapper struct {
	// contains filtered or unexported fields
}

AccountMapper handles logic of account encode/decode

func NewAccountMapper

func NewAccountMapper(cdc *wire.Codec, key sdk.StoreKey, proto BaseAccount) AccountMapper

NewAccountMapper returns a new sdk.AccountMapper

func (AccountMapper) GetAccount

func (am AccountMapper) GetAccount(ctx sdk.Context, addr sdk.Address) BaseAccount

Implements BaseAccount

func (AccountMapper) GetNonce

func (am AccountMapper) GetNonce(ctx sdk.Context, addr sdk.Address) (int64, sdk.Error)

func (AccountMapper) GetPubKey

func (am AccountMapper) GetPubKey(ctx sdk.Context, addr sdk.Address) (types.PubKey, sdk.Error)

func (AccountMapper) NewAccountWithAddress

func (am AccountMapper) NewAccountWithAddress(ctx sdk.Context, addr sdk.Address) BaseAccount

NewAccountWithAddress

func (AccountMapper) SetAccount

func (am AccountMapper) SetAccount(ctx sdk.Context, acc BaseAccount)

func (AccountMapper) SetNonce

func (am AccountMapper) SetNonce(ctx sdk.Context, addr sdk.Address, newNonce int64) sdk.Error

type AuthSig

type AuthSig struct {
	types.PubKey    `json:"pub_key"`
	types.Signature `json:"signature"`
	Nonce           int64 `json:"nonce"`
}

func NewAuthSig

func NewAuthSig(key types.PubKey, sig types.Signature, nonce int64) AuthSig

func (AuthSig) GetNonce

func (sig AuthSig) GetNonce() int64

GetNonce returns Nonce from Signature

func (AuthSig) GetPubKey

func (sig AuthSig) GetPubKey() types.PubKey

func (AuthSig) String

func (sig AuthSig) String() string

func (AuthSig) Verify

func (sig AuthSig) Verify(msg []byte) bool

Verify signature according to message Prefix message with a nonce

type AuthTx

type AuthTx struct {
	sdk.Msg   `json:"message"`
	Signature AuthSig `json:"signature"`
}

func GetAuthTx

func GetAuthTx(pubKey types.PubKey, privKey types.PrivKey, msg sdk.Msg, nonce int64) AuthTx

GetAuthTx - create an AuthTx message

func NewAuthTx

func NewAuthTx(msg sdk.Msg, sig AuthSig) AuthTx

func (AuthTx) GetMsg

func (tx AuthTx) GetMsg() sdk.Msg

GetMsg returns the message of this transaction

func (AuthTx) GetMsgs

func (tx AuthTx) GetMsgs() []sdk.Msg

GetMsgs returns multiple messages

func (AuthTx) GetNonce

func (tx AuthTx) GetNonce() int64

GetNonce returns Nonce sent with the signature

func (AuthTx) GetSignBytes

func (tx AuthTx) GetSignBytes() []byte

GetSignBytes returns Bytes to be signed

func (AuthTx) GetSignature

func (tx AuthTx) GetSignature() types.SHRSignature

GetSignature returns the signature with this transaction

func (AuthTx) VerifySignature

func (tx AuthTx) VerifySignature() bool

VerifySignature to verify signature

type BaseAccount

type BaseAccount interface {
	types.Account

	GetAddress() sdk.Address
	SetAddress(sdk.Address) error // errors if already set

	GetPubKey() types.PubKey // can return nil
	SetPubKey(types.PubKey) error

	GetNonce() int64
	SetNonce(int64) error
	IncreaseNonce()

	String() string
}

BaseAccount is an interface providing sequence number to avoid replay attack and public key for authentication

func GetSigner

func GetSigner(ctx sdk.Context) BaseAccount

Get the signers from the context

type MsgNonce

type MsgNonce struct {
	Address sdk.Address `json:"address"`
}

func NewMsgNonce

func NewMsgNonce(account sdk.Address) MsgNonce

func (MsgNonce) GetSignBytes

func (msg MsgNonce) GetSignBytes() []byte

func (MsgNonce) GetSigners

func (msg MsgNonce) GetSigners() []sdk.Address

func (MsgNonce) String

func (msg MsgNonce) String() string

func (MsgNonce) Tags

func (msg MsgNonce) Tags() sdk.Tags

func (MsgNonce) Type

func (msg MsgNonce) Type() string

func (MsgNonce) ValidateBasic

func (msg MsgNonce) ValidateBasic() sdk.Error

type SHRAccount

type SHRAccount struct {
	Address sdk.Address  `json:"address"`
	Coins   types.Coins  `json:"coins"`
	PubKey  types.PubKey `json:"pub_key"`
	Nonce   int64        `json:"nonce"`
}

SHRAccount - a ShareLedger account

func NewSHRAccountWithAddress

func NewSHRAccountWithAddress(addr sdk.Address) *SHRAccount

NewSHRAccountWithAddress create a SHRAccount with address

func (SHRAccount) GetAddress

func (acc SHRAccount) GetAddress() sdk.Address

func (SHRAccount) GetCoins

func (acc SHRAccount) GetCoins() types.Coins

func (SHRAccount) GetNonce

func (acc SHRAccount) GetNonce() int64

func (SHRAccount) GetPubKey

func (acc SHRAccount) GetPubKey() types.PubKey

func (*SHRAccount) IncreaseNonce

func (acc *SHRAccount) IncreaseNonce()

func (*SHRAccount) SetAddress

func (acc *SHRAccount) SetAddress(addr sdk.Address) error

func (*SHRAccount) SetCoins

func (acc *SHRAccount) SetCoins(c types.Coins)

func (*SHRAccount) SetNonce

func (acc *SHRAccount) SetNonce(no int64) error

func (*SHRAccount) SetPubKey

func (acc *SHRAccount) SetPubKey(pk types.PubKey) error

func (SHRAccount) String

func (acc SHRAccount) String() string

type SHRAccountJSON

type SHRAccountJSON struct {
	Address sdk.Address `json:"address"`
	Coins   types.Coins `json:"coins"`
	PubKey  []byte      `json:"pub_key"`
	Nonce   int64       `json:"nonce"`
}

Jump to

Keyboard shortcuts

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