burrow: github.com/hyperledger/burrow/crypto Index | Files

package crypto

import "github.com/hyperledger/burrow/crypto"

Index

Package Files

address.go crypto.go crypto.pb.go hash.go private_key.go public_key.go signature.go tendermint.go

Constants

const (
    MaxPublicKeyLength                = btcec.PubKeyBytesLenCompressed
    PublicKeyFixedWidthEncodingLength = MaxPublicKeyLength + 1
)
const AddressHexLength = 2 * AddressLength
const AddressLength = binary.Word160Length

Variables

var (
    ErrInvalidLengthCrypto        = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowCrypto          = fmt.Errorf("proto: integer overflow")
    ErrUnexpectedEndOfGroupCrypto = fmt.Errorf("proto: unexpected end of group")
)
var ZeroAddress = Address{}

func CompressedSignatureFromParams Uses

func CompressedSignatureFromParams(v uint64, r, s []byte) []byte

func EnsureEd25519PrivateKeyCorrect Uses

func EnsureEd25519PrivateKeyCorrect(candidatePrivateKey ed25519.PrivateKey) error

Ensures the last 32 bytes of the ed25519 private key is the public key derived from the first 32 private bytes

func Keccak256 Uses

func Keccak256(data []byte) []byte

func NodeIDFromAddress Uses

func NodeIDFromAddress(id Address) p2p.ID

func Nonce Uses

func Nonce(caller Address, nonce []byte) []byte

func PublicKeyLength Uses

func PublicKeyLength(curveType CurveType) int

Returns the length in bytes of the public key

func RIPEMD160 Uses

func RIPEMD160(data []byte) []byte

func SHA256 Uses

func SHA256(data []byte) []byte

func SequenceNonce Uses

func SequenceNonce(address Address, sequence uint64) []byte

Obtain a nearly unique nonce based on a montonic account sequence number

func UncompressedSignatureFromParams Uses

func UncompressedSignatureFromParams(r, s []byte) []byte

type Address Uses

type Address binary.Word160

func AddressFromBytes Uses

func AddressFromBytes(bs []byte) (address Address, err error)

Returns an address consisting of the first 20 bytes of bs, return an error if the bs does not have length exactly 20 but will still return either: the bytes in bs padded on the right or the first 20 bytes of bs truncated in any case.

func AddressFromHexString Uses

func AddressFromHexString(str string) (Address, error)

func AddressFromWord256 Uses

func AddressFromWord256(addr binary.Word256) Address

func MaybeAddressFromBytes Uses

func MaybeAddressFromBytes(bs []byte) (*Address, error)

Returns a pointer to an Address that is nil iff len(bs) == 0 otherwise does the same as AddressFromBytes

func MustAddressFromBytes Uses

func MustAddressFromBytes(addr []byte) Address

func MustAddressFromHexString Uses

func MustAddressFromHexString(str string) Address

func NewContractAddress Uses

func NewContractAddress(caller Address, nonce []byte) (newAddr Address)

func NewContractAddress2 Uses

func NewContractAddress2(caller Address, salt [binary.Word256Bytes]byte, initcode []byte) (newAddr Address)

func (Address) Bytes Uses

func (address Address) Bytes() []byte

Copy address and return a slice onto the copy

func (*Address) Marshal Uses

func (address *Address) Marshal() ([]byte, error)

Gogo proto support

func (Address) MarshalJSON Uses

func (address Address) MarshalJSON() ([]byte, error)

func (Address) MarshalText Uses

func (address Address) MarshalText() ([]byte, error)

func (*Address) MarshalTo Uses

func (address *Address) MarshalTo(data []byte) (int, error)

func (*Address) Size Uses

func (address *Address) Size() int

func (Address) String Uses

func (address Address) String() string

func (*Address) Unmarshal Uses

func (address *Address) Unmarshal(data []byte) error

func (*Address) UnmarshalJSON Uses

func (address *Address) UnmarshalJSON(data []byte) error

func (*Address) UnmarshalText Uses

func (address *Address) UnmarshalText(text []byte) error

func (Address) Word256 Uses

func (address Address) Word256() binary.Word256

type Addressable Uses

type Addressable interface {
    // Get the 20 byte EVM address of this account
    GetAddress() Address
    // Public key from which the Address is derived
    GetPublicKey() PublicKey
}

func NewAddressable Uses

func NewAddressable(publicKey PublicKey) Addressable

type Addresses Uses

type Addresses []Address

func (Addresses) Len Uses

func (as Addresses) Len() int

func (Addresses) Less Uses

func (as Addresses) Less(i, j int) bool

func (Addresses) Swap Uses

func (as Addresses) Swap(i, j int)

type CurveType Uses

type CurveType uint32
const (
    CurveTypeUnset CurveType = iota
    CurveTypeEd25519
    CurveTypeSecp256k1
)

func CurveTypeFromString Uses

func CurveTypeFromString(s string) (CurveType, error)

func (CurveType) ABCIType Uses

func (k CurveType) ABCIType() string

func (CurveType) Byte Uses

func (k CurveType) Byte() byte

Get this CurveType's 8 bit identifier as a byte

func (CurveType) String Uses

func (k CurveType) String() string

type ErrInvalidCurve Uses

type ErrInvalidCurve string

func (ErrInvalidCurve) Error Uses

func (err ErrInvalidCurve) Error() string

type PrivateKey Uses

type PrivateKey struct {
    CurveType CurveType `protobuf:"varint,1,opt,name=CurveType,proto3,casttype=CurveType" json:"CurveType,omitempty"`
    // Note may need initialisation
    PublicKey            []byte   `protobuf:"bytes,2,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
    PrivateKey           []byte   `protobuf:"bytes,3,opt,name=PrivateKey,proto3" json:"PrivateKey,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func GeneratePrivateKey Uses

func GeneratePrivateKey(random io.Reader, curveType CurveType) (PrivateKey, error)

func PrivateKeyFromRawBytes Uses

func PrivateKeyFromRawBytes(privKeyBytes []byte, curveType CurveType) (PrivateKey, error)

func PrivateKeyFromSecret Uses

func PrivateKeyFromSecret(secret string, curveType CurveType) PrivateKey

func (*PrivateKey) Descriptor Uses

func (*PrivateKey) Descriptor() ([]byte, []int)

func (PrivateKey) GetPublicKey Uses

func (p PrivateKey) GetPublicKey() PublicKey

func (*PrivateKey) Marshal Uses

func (m *PrivateKey) Marshal() (dAtA []byte, err error)

func (*PrivateKey) MarshalTo Uses

func (m *PrivateKey) MarshalTo(dAtA []byte) (int, error)

func (*PrivateKey) MarshalToSizedBuffer Uses

func (m *PrivateKey) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PrivateKey) ProtoMessage Uses

func (*PrivateKey) ProtoMessage()

func (PrivateKey) RawBytes Uses

func (p PrivateKey) RawBytes() []byte

func (*PrivateKey) Reinitialise Uses

func (p *PrivateKey) Reinitialise() error

Reinitialise after serialisation

func (*PrivateKey) Reset Uses

func (m *PrivateKey) Reset()

func (PrivateKey) Sign Uses

func (p PrivateKey) Sign(msg []byte) (*Signature, error)

func (*PrivateKey) Size Uses

func (m *PrivateKey) Size() (n int)

func (PrivateKey) String Uses

func (p PrivateKey) String() string

func (*PrivateKey) Unmarshal Uses

func (m *PrivateKey) Unmarshal(dAtA []byte) error

func (*PrivateKey) XXX_DiscardUnknown Uses

func (m *PrivateKey) XXX_DiscardUnknown()

func (*PrivateKey) XXX_Marshal Uses

func (m *PrivateKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PrivateKey) XXX_Merge Uses

func (m *PrivateKey) XXX_Merge(src proto.Message)

func (*PrivateKey) XXX_MessageName Uses

func (*PrivateKey) XXX_MessageName() string

func (*PrivateKey) XXX_Size Uses

func (m *PrivateKey) XXX_Size() int

func (*PrivateKey) XXX_Unmarshal Uses

func (m *PrivateKey) XXX_Unmarshal(b []byte) error

type PublicKey Uses

type PublicKey struct {
    CurveType            CurveType                                     `protobuf:"varint,1,opt,name=CurveType,proto3,casttype=CurveType" json:"CurveType,omitempty"`
    PublicKey            github_com_hyperledger_burrow_binary.HexBytes `protobuf:"bytes,2,opt,name=PublicKey,proto3,customtype=github.com/hyperledger/burrow/binary.HexBytes" json:"PublicKey"`
    XXX_NoUnkeyedLiteral struct{}                                      `json:"-"`
    XXX_unrecognized     []byte                                        `json:"-"`
    XXX_sizecache        int32                                         `json:"-"`
}

func DecodePublicKeyFixedWidth Uses

func DecodePublicKeyFixedWidth(bs []byte) (PublicKey, error)

func PublicKeyFromABCIPubKey Uses

func PublicKeyFromABCIPubKey(pubKey abci.PubKey) (PublicKey, error)

func PublicKeyFromBytes Uses

func PublicKeyFromBytes(bs []byte, curveType CurveType) (PublicKey, error)

Currently this is a stub that reads the raw bytes returned by key_client and returns an ed25519 public key.

func PublicKeyFromSignature Uses

func PublicKeyFromSignature(sig, hash []byte) (*PublicKey, error)

PublicKeyFromSignature verifies an ethereum compact signature and returns the public key if valid

func PublicKeyFromTendermintPubKey Uses

func PublicKeyFromTendermintPubKey(pubKey tmCrypto.PubKey) (PublicKey, error)

func (PublicKey) ABCIPubKey Uses

func (p PublicKey) ABCIPubKey() abci.PubKey

Return the ABCI PubKey. See Tendermint protobuf.go for the go-crypto conversion this is based on

func (PublicKey) AddressHashType Uses

func (p PublicKey) AddressHashType() string

func (*PublicKey) Descriptor Uses

func (*PublicKey) Descriptor() ([]byte, []int)

func (PublicKey) EncodeFixedWidth Uses

func (p PublicKey) EncodeFixedWidth() []byte

Produces a binary encoding of the CurveType byte plus the public key for padded to a fixed width on the right

func (PublicKey) GetAddress Uses

func (p PublicKey) GetAddress() Address

func (*PublicKey) GetCurveType Uses

func (m *PublicKey) GetCurveType() CurveType

func (PublicKey) IsSet Uses

func (p PublicKey) IsSet() bool

func (PublicKey) IsValid Uses

func (p PublicKey) IsValid() bool

func (*PublicKey) Marshal Uses

func (m *PublicKey) Marshal() (dAtA []byte, err error)

func (PublicKey) MarshalJSON Uses

func (p PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) MarshalText Uses

func (p PublicKey) MarshalText() ([]byte, error)

func (*PublicKey) MarshalTo Uses

func (m *PublicKey) MarshalTo(dAtA []byte) (int, error)

func (*PublicKey) MarshalToSizedBuffer Uses

func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PublicKey) ProtoMessage Uses

func (*PublicKey) ProtoMessage()

func (*PublicKey) Reset Uses

func (m *PublicKey) Reset()

func (*PublicKey) Size Uses

func (m *PublicKey) Size() (n int)

func (PublicKey) String Uses

func (p PublicKey) String() string

func (PublicKey) TendermintAddress Uses

func (p PublicKey) TendermintAddress() tmCrypto.Address

func (PublicKey) TendermintPubKey Uses

func (p PublicKey) TendermintPubKey() tmCrypto.PubKey

func (*PublicKey) Unmarshal Uses

func (m *PublicKey) Unmarshal(dAtA []byte) error

func (*PublicKey) UnmarshalJSON Uses

func (p *PublicKey) UnmarshalJSON(text []byte) error

func (*PublicKey) UnmarshalText Uses

func (p *PublicKey) UnmarshalText(text []byte) error

func (PublicKey) Verify Uses

func (p PublicKey) Verify(msg []byte, signature *Signature) error

func (*PublicKey) XXX_DiscardUnknown Uses

func (m *PublicKey) XXX_DiscardUnknown()

func (*PublicKey) XXX_Marshal Uses

func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PublicKey) XXX_Merge Uses

func (m *PublicKey) XXX_Merge(src proto.Message)

func (*PublicKey) XXX_MessageName Uses

func (*PublicKey) XXX_MessageName() string

func (*PublicKey) XXX_Size Uses

func (m *PublicKey) XXX_Size() int

func (*PublicKey) XXX_Unmarshal Uses

func (m *PublicKey) XXX_Unmarshal(b []byte) error

type PublicKeyJSON Uses

type PublicKeyJSON struct {
    CurveType string
    PublicKey string
}

type Signable Uses

type Signable interface {
    SignBytes(chainID string) ([]byte, error)
}

Signable is an interface for all signable things. It typically removes signatures before serializing.

type Signature Uses

type Signature struct {
    CurveType            CurveType `protobuf:"varint,1,opt,name=CurveType,proto3,casttype=CurveType" json:"CurveType,omitempty"`
    Signature            []byte    `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"`
    XXX_NoUnkeyedLiteral struct{}  `json:"-"`
    XXX_unrecognized     []byte    `json:"-"`
    XXX_sizecache        int32     `json:"-"`
}

func SignatureFromBytes Uses

func SignatureFromBytes(bs []byte, curveType CurveType) (*Signature, error)

func (*Signature) Descriptor Uses

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) GetCurveType Uses

func (m *Signature) GetCurveType() CurveType

func (*Signature) GetSignature Uses

func (m *Signature) GetSignature() []byte

func (*Signature) Marshal Uses

func (m *Signature) Marshal() (dAtA []byte, err error)

func (*Signature) MarshalTo Uses

func (m *Signature) MarshalTo(dAtA []byte) (int, error)

func (*Signature) MarshalToSizedBuffer Uses

func (m *Signature) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Signature) ProtoMessage Uses

func (*Signature) ProtoMessage()

func (*Signature) RawBytes Uses

func (sig *Signature) RawBytes() []byte

func (*Signature) Reset Uses

func (m *Signature) Reset()

func (*Signature) Size Uses

func (m *Signature) Size() (n int)

func (*Signature) String Uses

func (sig *Signature) String() string

func (Signature) TendermintSignature Uses

func (sig Signature) TendermintSignature() []byte

func (*Signature) Unmarshal Uses

func (m *Signature) Unmarshal(dAtA []byte) error

func (*Signature) XXX_DiscardUnknown Uses

func (m *Signature) XXX_DiscardUnknown()

func (*Signature) XXX_Marshal Uses

func (m *Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Signature) XXX_Merge Uses

func (m *Signature) XXX_Merge(src proto.Message)

func (*Signature) XXX_MessageName Uses

func (*Signature) XXX_MessageName() string

func (*Signature) XXX_Size Uses

func (m *Signature) XXX_Size() int

func (*Signature) XXX_Unmarshal Uses

func (m *Signature) XXX_Unmarshal(b []byte) error

type Signer Uses

type Signer interface {
    Sign(msg []byte) (*Signature, error)
}

Package crypto imports 25 packages (graph) and is imported by 156 packages. Updated 2020-03-06. Refresh now. Tools for package owners.