Documentation ¶
Index ¶
- Variables
- func CborDecodeInto(r []byte, v interface{}) error
- func CheckMsgEnum(me MsgEnum) error
- func ContainMsgType(multiME MsgEnum, mt types.MsgType) bool
- func FindCode(enum MsgEnum) []int
- func GetSignBytesAndObj(toSign []byte, meta types.MsgMeta) (interface{}, []byte, error)
- func GetSignData(datas ...[]byte) []byte
- func MsgEnumCode(me MsgEnum) int
- func RegisterSupportedMsgTypes(msgType types.MsgType, p reflect.Type, fGetSignBytes FGetSignBytes, ...) (replaced bool)
- type AddressScope
- type DrawRandomParams
- type FGetSignBytes
- type FParseObj
- type Group
- type GroupAuth
- type KeyBind
- type KeyStrategy
- type MethodName
- type MethodTemplate
- type MsgEnum
- type MsgTypeTemplate
- type Types
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCodeOverflow = errors.New("code over flow")
View Source
var MaxMsgEnumCode = len(MsgEnumPool) - 1
View Source
var MsgEnumPool = []struct { Code int Name string }{ {Code: MsgEnumCode(MEUnknown), Name: "unknown"}, {Code: MsgEnumCode(MEChainMsg), Name: "chainMsg"}, {Code: MsgEnumCode(MEBlock), Name: "block"}, {Code: MsgEnumCode(MEDealProposal), Name: "dealProposal"}, {Code: MsgEnumCode(MEDrawRandomParam), Name: "drawRandomParam"}, {Code: MsgEnumCode(MESignedVoucher), Name: "signedVoucher"}, {Code: MsgEnumCode(MEStorageAsk), Name: "storageAsk"}, {Code: MsgEnumCode(MEAskResponse), Name: "askResponse"}, {Code: MsgEnumCode(MENetWorkResponse), Name: "netWorkResponse"}, {Code: MsgEnumCode(MEProviderDealState), Name: "providerDealState"}, {Code: MsgEnumCode(MEClientDeal), Name: "clientDeal"}, }
View Source
var SupportedMsgTypes = map[types.MsgType]*Types{ types.MTDealProposal: { Type: reflect.TypeOf(market.DealProposal{}), SignBytes: func(i interface{}) ([]byte, error) { return cborutil.Dump(i) }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(market.DealProposal{})), }, types.MTClientDeal: { Type: reflect.TypeOf(market.ClientDealProposal{}), SignBytes: func(in interface{}) ([]byte, error) { ni, err := cborutil.AsIpld(in) if err != nil { return nil, err } return ni.Cid().Bytes(), nil }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(market.ClientDealProposal{})), }, types.MTDrawRandomParam: { Type: reflect.TypeOf(DrawRandomParams{}), SignBytes: func(in interface{}) ([]byte, error) { param := in.(*DrawRandomParams) return param.SignBytes() }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(DrawRandomParams{})), }, types.MTSignedVoucher: { Type: reflect.TypeOf(paych.SignedVoucher{}), SignBytes: func(in interface{}) ([]byte, error) { return (in.(*paych.SignedVoucher)).SigningBytes() }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(paych.SignedVoucher{})), }, types.MTStorageAsk: { Type: reflect.TypeOf(storagemarket.StorageAsk{}), SignBytes: func(in interface{}) ([]byte, error) { return cborutil.Dump(in) }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(storagemarket.StorageAsk{})), }, types.MTAskResponse: { Type: reflect.TypeOf(network.AskResponse{}), SignBytes: func(in interface{}) ([]byte, error) { newAsk := in.(*network.AskResponse).Ask.Ask oldAsk := &migrations.StorageAsk0{ Price: newAsk.Price, VerifiedPrice: newAsk.VerifiedPrice, MinPieceSize: newAsk.MinPieceSize, MaxPieceSize: newAsk.MaxPieceSize, Miner: newAsk.Miner, Timestamp: newAsk.Timestamp, Expiry: newAsk.Expiry, SeqNo: newAsk.SeqNo, } return cborutil.Dump(oldAsk) }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(network.AskResponse{})), }, types.MTNetWorkResponse: { Type: reflect.TypeOf(network.Response{}), SignBytes: func(in interface{}) ([]byte, error) { return cborutil.Dump(in) }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(network.Response{})), }, types.MTBlock: { Type: reflect.TypeOf(types.BlockHeader{}), SignBytes: func(in interface{}) ([]byte, error) { return in.(*types.BlockHeader).SignatureData() }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(types.BlockHeader{})), }, types.MTChainMsg: { Type: reflect.TypeOf(types.Message{}), SignBytes: func(in interface{}) ([]byte, error) { msg := in.(*types.Message) return msg.Cid().Bytes(), nil }, ParseObj: func(in []byte, meta types.MsgMeta) (interface{}, error) { if len(meta.Extra) == 0 { return nil, errors.New("msg type must contain extra data") } msg, err := types.DecodeMessage(meta.Extra) if err != nil { return nil, err } return msg, nil }, }, types.MTProviderDealState: { Type: reflect.TypeOf(storagemarket.ProviderDealState{}), SignBytes: func(in interface{}) ([]byte, error) { return cborutil.Dump(in) }, ParseObj: defaultPaseObjFunc(reflect.TypeOf(storagemarket.ProviderDealState{})), }, types.MTUnknown: { Type: reflect.TypeOf([]byte{}), SignBytes: func(in interface{}) ([]byte, error) { msg, isOk := in.([]byte) if !isOk { return nil, fmt.Errorf("MTUnknown must be []byte") } return msg, nil }, ParseObj: func(in []byte, meta types.MsgMeta) (interface{}, error) { if meta.Type == types.MTUnknown { return in, nil } return nil, fmt.Errorf("un-expected MsgType:%s", meta.Type) }}, types.MTVerifyAddress: { Type: reflect.TypeOf([]byte{}), SignBytes: func(in interface{}) ([]byte, error) { return in.([]byte), nil }, ParseObj: func(in []byte, meta types.MsgMeta) (interface{}, error) { expected := GetSignData(meta.Extra, gateway.RandomBytes) if !bytes.Equal(in, expected) { return nil, fmt.Errorf("sign data not match, actual %v, expected %v", in, expected) } return in, nil }, }, }
SupportedMsgTypes signature type factory
Functions ¶
func CborDecodeInto ¶ added in v1.13.0
func CheckMsgEnum ¶
func GetSignBytesAndObj ¶ added in v1.13.0
GetSignBytesAndObj Matches the type and returns the data that needs to be signed
func GetSignData ¶ added in v1.13.0
func MsgEnumCode ¶
func RegisterSupportedMsgTypes ¶ added in v1.13.0
Types ¶
type AddressScope ¶
type AddressScope struct { Root bool // is root auth, true : can get all addresses in the wallet Addresses []address.Address // when root==false, should fill a scope of wallet addresses }
type DrawRandomParams ¶
type DrawRandomParams struct { Rbase []byte Pers crypto.DomainSeparationTag Round abi.ChainEpoch Entropy []byte }
func (*DrawRandomParams) MarshalCBOR ¶
func (dr *DrawRandomParams) MarshalCBOR(w io.Writer) error
func (*DrawRandomParams) SignBytes ¶
func (dr *DrawRandomParams) SignBytes() ([]byte, error)
return store.DrawRandomness(dr.Rbase, dr.Pers, dr.Round, dr.Entropy)
func (*DrawRandomParams) UnmarshalCBOR ¶
func (dr *DrawRandomParams) UnmarshalCBOR(r io.Reader) error
type FGetSignBytes ¶ added in v1.13.0
type Group ¶
type Group struct { GroupID uint Name string // NOTE: not fill data when query groups KeyBinds []*KeyBind }
Group multi KeyBind
type KeyBind ¶
type KeyBind struct { BindID uint Name string Address string // source from MsgTypeTemplate or temporary create MetaTypes MsgEnum // source from MethodTemplate Methods []MethodName }
KeyBind bind wallet usage strategy allow designated rule to pass
func (*KeyBind) ContainMethod ¶
type KeyStrategy ¶
type KeyStrategy struct { Address address.Address // wallet address MetaTypes MsgEnum // sum MsgEnum Methods []MethodName // msg method array }
KeyStrategy a uint of wallet strategy
type MethodName ¶
type MethodName = string
type MethodTemplate ¶
type MethodTemplate struct { MTId uint Name string // method name join with ',' Methods []MethodName }
MethodTemplate to quickly create a private key usage strategy msg actor and methodNum agg to method name NOTE: routeType 4
type MsgTypeTemplate ¶
MsgTypeTemplate to quickly create a private key usage strategy
Click to show internal directories.
Click to hide internal directories.