Documentation
¶
Overview ¶
Package auth is a generated protocol buffer package. It is generated from these files: x/auth/codec.proto It has these top-level messages: UserData StdSignature
Package auth provides basic authentication middleware to verify the signatures on the transaction, and maintain nonces for replay protection.
Index ¶
- Constants
- Variables
- func BuildSignBytes(signBytes []byte, chainID string, seq int64) ([]byte, error)
- func BuildSignBytesTx(tx SignedTx, chainID string, seq int64) ([]byte, error)
- func ErrInvalidSequence(why string, args ...interface{}) error
- func ErrMissingPubKey() error
- func ErrPubKeyAddressMismatch() error
- func GetSigners(ctx weave.Context) []weave.Address
- func IsInvalidSequenceErr(err error) bool
- func VerifySignature(store weave.KVStore, sig *StdSignature, signBytes []byte, chainID string) (weave.Address, error)
- func VerifyTxSignatures(store weave.KVStore, tx SignedTx, chainID string) ([]weave.Address, error)
- type Decorator
- func (d Decorator) AllowMissingSigs() Decorator
- func (d Decorator) Check(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Checker) (weave.CheckResult, error)
- func (d Decorator) Deliver(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Deliverer) (weave.DeliverResult, error)
- type Key
- type SignedTx
- type StdSignature
- func (*StdSignature) Descriptor() ([]byte, []int)
- func (m *StdSignature) GetAddress() []byte
- func (m *StdSignature) GetPubKey() *crypto.PublicKey
- func (m *StdSignature) GetSequence() int64
- func (m *StdSignature) GetSignature() *crypto.Signature
- func (m *StdSignature) Marshal() (dAtA []byte, err error)
- func (m *StdSignature) MarshalTo(dAtA []byte) (int, error)
- func (*StdSignature) ProtoMessage()
- func (m *StdSignature) Reset()
- func (m *StdSignature) Size() (n int)
- func (m *StdSignature) String() string
- func (m *StdSignature) Unmarshal(dAtA []byte) error
- func (s *StdSignature) Validate() error
- type User
- type UserData
- func (*UserData) Descriptor() ([]byte, []int)
- func (m *UserData) GetPubKey() *crypto.PublicKey
- func (m *UserData) GetSequence() int64
- func (m *UserData) Marshal() (dAtA []byte, err error)
- func (m *UserData) MarshalTo(dAtA []byte) (int, error)
- func (*UserData) ProtoMessage()
- func (m *UserData) Reset()
- func (m *UserData) Size() (n int)
- func (m *UserData) String() string
- func (m *UserData) Unmarshal(dAtA []byte) error
- func (u UserData) Validate() error
Constants ¶
const (
CodeInvalidSequence uint32 = 20
)
ABCI Response Codes x/auth reserves 20 ~ 29.
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
var IsInvalidSignatureErr = errors.IsInvalidSignatureErr
Functions ¶
func BuildSignBytes ¶
BuildSignBytes combines all info on the actual tx before signing
func BuildSignBytesTx ¶
BuildSignBytesTx calculates the sign bytes given a tx
func ErrInvalidSequence ¶
func ErrMissingPubKey ¶
func ErrMissingPubKey() error
func ErrPubKeyAddressMismatch ¶
func ErrPubKeyAddressMismatch() error
func GetSigners ¶
GetSigners returns who signed the current Context. May be empty
func IsInvalidSequenceErr ¶
func VerifySignature ¶
func VerifySignature(store weave.KVStore, sig *StdSignature, signBytes []byte, chainID string) (weave.Address, error)
VerifySignature checks one signature against signbytes, check chain and updates state in the store
Types ¶
type Decorator ¶
type Decorator struct {
// contains filtered or unexported fields
}
Decorator verifies the signatures and adds them to the context
func NewDecorator ¶
func NewDecorator() Decorator
NewDecorator returns a default authentication decorator, which appends the chainID before checking the signature, and requires at least one signature to be present
func (Decorator) AllowMissingSigs ¶
AllowMissingSigs allows us to pass along items with no signatures
type Key ¶
type Key []byte
Key is the primary key we use to distinguish users This should be []byte, in order to index with our KVStore. Any structure to these bytes should be defined by the constructor.
Question: allow objects with a Marshal method???
type SignedTx ¶
type SignedTx interface {
// GetSignBytes returns the canonical byte representation of the Msg.
// Equivalent to weave.MustMarshal(tx.GetMsg()) if Msg has a deterministic
// serialization.
//
// Helpful to store original, unparsed bytes here, just in case.
GetSignBytes() ([]byte, error)
// Signatures returns the signature of signers who signed the Msg.
GetSignatures() []*StdSignature
}
SignedTx represents a transaction that contains signatures, which can be verified by the auth.Decorator
type StdSignature ¶
type StdSignature struct {
Sequence int64 `protobuf:"varint,1,opt,name=Sequence,proto3" json:"Sequence,omitempty"`
// PubKey required if Sequence == 0
PubKey *crypto.PublicKey `protobuf:"bytes,2,opt,name=PubKey" json:"PubKey,omitempty"`
// Address required if PubKey is not present
Address []byte `protobuf:"bytes,3,opt,name=Address,proto3" json:"Address,omitempty"`
Signature *crypto.Signature `protobuf:"bytes,4,opt,name=Signature" json:"Signature,omitempty"`
}
StdSignature represents the signature, the identity of the signer (either the PubKey or the Address), and a sequence number to prevent replay attacks.
A given signer must submit transactions with the sequence number increasing by 1 each time (starting at 0)
func (*StdSignature) Descriptor ¶
func (*StdSignature) Descriptor() ([]byte, []int)
func (*StdSignature) GetAddress ¶
func (m *StdSignature) GetAddress() []byte
func (*StdSignature) GetPubKey ¶
func (m *StdSignature) GetPubKey() *crypto.PublicKey
func (*StdSignature) GetSequence ¶
func (m *StdSignature) GetSequence() int64
func (*StdSignature) GetSignature ¶
func (m *StdSignature) GetSignature() *crypto.Signature
func (*StdSignature) Marshal ¶
func (m *StdSignature) Marshal() (dAtA []byte, err error)
func (*StdSignature) ProtoMessage ¶
func (*StdSignature) ProtoMessage()
func (*StdSignature) Reset ¶
func (m *StdSignature) Reset()
func (*StdSignature) Size ¶
func (m *StdSignature) Size() (n int)
func (*StdSignature) String ¶
func (m *StdSignature) String() string
func (*StdSignature) Unmarshal ¶
func (m *StdSignature) Unmarshal(dAtA []byte) error
func (*StdSignature) Validate ¶
func (s *StdSignature) Validate() error
Validate ensures the StdSignature meets basic standards
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is the actual object that we want to pass around in our code. It handles loading and saving the data to/from the persistent store. It also adds helpers to manipulate state.
It may allow full access to manipulate all variables on the data, or limit it. It maintains a reference to the store it was loaded from, to know how to save itself.
func GetOrCreateUser ¶
GetOrCreateUser loads this user if present, or initializes a new user with this key if not present.
func (*User) CheckAndIncrementSequence ¶
CheckAndIncrementSequence checks if the current Sequence matches the expected value. If so, it will increase the sequence by one and return nil If not, it will not change the sequence, but return an error
func (*User) Save ¶
func (u *User) Save()
Save writes the current user state to the backing store panics if invalid state
type UserData ¶
type UserData struct {
PubKey *crypto.PublicKey `protobuf:"bytes,1,opt,name=pub_key,json=pubKey" json:"pub_key,omitempty"`
Sequence int64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"`
}
UserData just stores the data and is used for serialization.
Note: This should not be created from outside the module, User is the entry point you want
func (*UserData) Descriptor ¶
func (*UserData) GetSequence ¶
func (*UserData) ProtoMessage ¶
func (*UserData) ProtoMessage()