Documentation ¶
Overview ¶
Package key provides keypairs.
Index ¶
- Constants
- Variables
- type BasePrivatekey
- func (k BasePrivatekey) Bytes() []byte
- func (k BasePrivatekey) Equal(b Key) bool
- func (BasePrivatekey) Hint() hint.Hint
- func (k BasePrivatekey) IsValid([]byte) error
- func (k BasePrivatekey) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (k BasePrivatekey) MarshalText() ([]byte, error)
- func (k BasePrivatekey) Publickey() Publickey
- func (k BasePrivatekey) Sign(b []byte) (Signature, error)
- func (k BasePrivatekey) String() string
- func (k *BasePrivatekey) UnmarshalBSONValue(t bsontype.Type, b []byte) error
- func (k *BasePrivatekey) UnmarshalText(b []byte) error
- func (k *BasePrivatekey) UnpackBSON(b []byte, _ *bsonenc.Encoder) error
- func (k *BasePrivatekey) UnpackJSON(b []byte, _ *jsonenc.Encoder) error
- type BasePublickey
- func (k BasePublickey) Bytes() []byte
- func (k BasePublickey) Equal(b Key) bool
- func (BasePublickey) Hint() hint.Hint
- func (k BasePublickey) IsValid([]byte) error
- func (k BasePublickey) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (k BasePublickey) MarshalText() ([]byte, error)
- func (k BasePublickey) String() string
- func (k *BasePublickey) UnmarshalBSONValue(t bsontype.Type, b []byte) error
- func (k *BasePublickey) UnmarshalText(b []byte) error
- func (k *BasePublickey) UnpackBSON(b []byte, _ *bsonenc.Encoder) error
- func (k *BasePublickey) UnpackJSON(b []byte, _ *jsonenc.Encoder) error
- func (k BasePublickey) Verify(input []byte, sig Signature) error
- type Key
- type KeyDecoder
- type Privatekey
- type PrivatekeyDecoder
- type Publickey
- type PublickeyDecoder
- type Signature
- func (sg Signature) Bytes() []byte
- func (sg Signature) Equal(ns Signature) bool
- func (sg Signature) IsValid([]byte) error
- func (sg Signature) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (sg Signature) MarshalJSON() ([]byte, error)
- func (sg Signature) String() string
- func (sg *Signature) UnmarshalBSONValue(_ bsontype.Type, b []byte) error
- func (sg *Signature) UnmarshalJSON(b []byte) error
Constants ¶
View Source
const KeyTypeSize = 3
View Source
const MinSeedSize = 36
Variables ¶
View Source
var ( InvalidKeyError = util.NewError("invalid key") SignatureVerificationFailedError = util.NewError("signature verification failed") )
View Source
var ( BasePrivatekeyType = hint.Type("mpr") BasePrivatekeyHint = hint.NewHint(BasePrivatekeyType, "v0.0.1") BasePublickeyType = hint.Type("mpu") BasePublickeyHint = hint.NewHint(BasePublickeyType, "v0.0.1") )
Functions ¶
This section is empty.
Types ¶
type BasePrivatekey ¶
type BasePrivatekey struct {
// contains filtered or unexported fields
}
BasePrivatekey is based on BTC Privatekey.
func LoadBasePrivatekey ¶
func LoadBasePrivatekey(s string) (BasePrivatekey, error)
func NewBasePrivatekey ¶
func NewBasePrivatekey() BasePrivatekey
func NewBasePrivatekeyFromSeed ¶
func NewBasePrivatekeyFromSeed(s string) (BasePrivatekey, error)
func ParseBasePrivatekey ¶
func ParseBasePrivatekey(s string) (BasePrivatekey, error)
func (BasePrivatekey) Bytes ¶
func (k BasePrivatekey) Bytes() []byte
func (BasePrivatekey) Equal ¶
func (k BasePrivatekey) Equal(b Key) bool
func (BasePrivatekey) Hint ¶
func (BasePrivatekey) Hint() hint.Hint
func (BasePrivatekey) IsValid ¶
func (k BasePrivatekey) IsValid([]byte) error
func (BasePrivatekey) MarshalBSONValue ¶
func (k BasePrivatekey) MarshalBSONValue() (bsontype.Type, []byte, error)
func (BasePrivatekey) MarshalText ¶
func (k BasePrivatekey) MarshalText() ([]byte, error)
func (BasePrivatekey) Publickey ¶
func (k BasePrivatekey) Publickey() Publickey
func (BasePrivatekey) String ¶
func (k BasePrivatekey) String() string
func (*BasePrivatekey) UnmarshalBSONValue ¶
func (k *BasePrivatekey) UnmarshalBSONValue(t bsontype.Type, b []byte) error
func (*BasePrivatekey) UnmarshalText ¶
func (k *BasePrivatekey) UnmarshalText(b []byte) error
func (*BasePrivatekey) UnpackBSON ¶
func (k *BasePrivatekey) UnpackBSON(b []byte, _ *bsonenc.Encoder) error
func (*BasePrivatekey) UnpackJSON ¶
func (k *BasePrivatekey) UnpackJSON(b []byte, _ *jsonenc.Encoder) error
type BasePublickey ¶
type BasePublickey struct {
// contains filtered or unexported fields
}
func LoadBasePublickey ¶
func LoadBasePublickey(s string) (BasePublickey, error)
func NewBasePublickey ¶
func NewBasePublickey(k *btcec.PublicKey) BasePublickey
func ParseBasePublickey ¶
func ParseBasePublickey(s string) (BasePublickey, error)
func (BasePublickey) Bytes ¶
func (k BasePublickey) Bytes() []byte
func (BasePublickey) Equal ¶
func (k BasePublickey) Equal(b Key) bool
func (BasePublickey) Hint ¶
func (BasePublickey) Hint() hint.Hint
func (BasePublickey) IsValid ¶
func (k BasePublickey) IsValid([]byte) error
func (BasePublickey) MarshalBSONValue ¶
func (k BasePublickey) MarshalBSONValue() (bsontype.Type, []byte, error)
func (BasePublickey) MarshalText ¶
func (k BasePublickey) MarshalText() ([]byte, error)
func (BasePublickey) String ¶
func (k BasePublickey) String() string
func (*BasePublickey) UnmarshalBSONValue ¶
func (k *BasePublickey) UnmarshalBSONValue(t bsontype.Type, b []byte) error
func (*BasePublickey) UnmarshalText ¶
func (k *BasePublickey) UnmarshalText(b []byte) error
func (*BasePublickey) UnpackBSON ¶
func (k *BasePublickey) UnpackBSON(b []byte, _ *bsonenc.Encoder) error
func (*BasePublickey) UnpackJSON ¶
func (k *BasePublickey) UnpackJSON(b []byte, _ *jsonenc.Encoder) error
type KeyDecoder ¶
type KeyDecoder struct {
// contains filtered or unexported fields
}
KeyDecoder is basic unmarshaler for Keys. It can unmarshal Privatekey and publickey.
func (KeyDecoder) Body ¶
func (kd KeyDecoder) Body() []byte
func (*KeyDecoder) Encode ¶
func (kd *KeyDecoder) Encode(enc encoder.Encoder) (Key, error)
Encode is used with encoder.Encoder.
var de struct { Key KeyDecoder }
err := json.Unmarshal(b, &de)
if err != nil { return err }
enc := jsonenc.NewEncoder() uk, err := de.Key.Encode(enc)
if err != nil { return err }
priv, ok := uk.(Privtekey) pub, ok := uk.(Publickey)
func (KeyDecoder) Type ¶
func (kd KeyDecoder) Type() hint.Type
func (*KeyDecoder) UnmarshalBSON ¶
func (kd *KeyDecoder) UnmarshalBSON(b []byte) error
func (*KeyDecoder) UnmarshalJSON ¶
func (kd *KeyDecoder) UnmarshalJSON(b []byte) error
type Privatekey ¶
func DecodePrivatekeyFromString ¶
func DecodePrivatekeyFromString(s string, enc encoder.Encoder) (Privatekey, error)
type PrivatekeyDecoder ¶
type PrivatekeyDecoder struct {
KeyDecoder
}
PrivatekeyDecoder is basic unmarshaler for Privatekey.
func (*PrivatekeyDecoder) Encode ¶
func (kd *PrivatekeyDecoder) Encode(enc encoder.Encoder) (Privatekey, error)
type PublickeyDecoder ¶
type PublickeyDecoder struct {
KeyDecoder
}
PublickeyDecoder is basic unmarshaler for Privatekey.
type Signature ¶
type Signature []byte
func NewSignatureFromString ¶
func (Signature) MarshalBSONValue ¶
func (Signature) MarshalJSON ¶
func (*Signature) UnmarshalBSONValue ¶
func (*Signature) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.