Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureEd25519PrivateKeyCorrect(candidatePrivateKey ed25519.PrivateKey) error
- func GetEthSignatureRecoveryID(chainID *big.Int, parity *big.Int) *big.Int
- func Keccak256(data []byte) []byte
- func Nonce(caller Address, nonce []byte) []byte
- func PublicKeyLength(curveType CurveType) int
- func RIPEMD160(data []byte) []byte
- func SHA256(data []byte) []byte
- func SequenceNonce(address Address, sequence uint64) []byte
- type Address
- func AddressFromBytes(bs []byte) (address Address, err error)
- func AddressFromHexString(str string) (Address, error)
- func AddressFromWord256(addr binary.Word256) Address
- func MaybeAddressFromBytes(bs []byte) (*Address, error)
- func MustAddressFromBytes(addr []byte) Address
- func MustAddressFromHexString(str string) Address
- func NewContractAddress(caller Address, nonce []byte) (newAddr Address)
- func NewContractAddress2(caller Address, salt [binary.Word256Bytes]byte, initcode []byte) (newAddr Address)
- func (address Address) Bytes() []byte
- func (address *Address) Marshal() ([]byte, error)
- func (address Address) MarshalJSON() ([]byte, error)
- func (address Address) MarshalText() ([]byte, error)
- func (address *Address) MarshalTo(data []byte) (int, error)
- func (address *Address) Size() int
- func (address Address) String() string
- func (address *Address) Unmarshal(data []byte) error
- func (address *Address) UnmarshalJSON(data []byte) error
- func (address *Address) UnmarshalText(text []byte) error
- func (address Address) Word256() binary.Word256
- type Addressable
- type Addresses
- type CompactSecp256k1Signature
- type CurveType
- type EIP155Signature
- type ErrInvalidCurve
- type PrivateKey
- func (*PrivateKey) Descriptor() ([]byte, []int)
- func (pk *PrivateKey) GetAddress() Address
- func (p PrivateKey) GetPublicKey() *PublicKey
- func (m *PrivateKey) Marshal() (dAtA []byte, err error)
- func (m *PrivateKey) MarshalTo(dAtA []byte) (int, error)
- func (m *PrivateKey) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PrivateKey) ProtoMessage()
- func (p PrivateKey) RawBytes() []byte
- func (m *PrivateKey) Reset()
- func (p PrivateKey) Sign(msg []byte) (*Signature, error)
- func (m *PrivateKey) Size() (n int)
- func (p PrivateKey) String() string
- func (m *PrivateKey) Unmarshal(dAtA []byte) error
- func (m *PrivateKey) XXX_DiscardUnknown()
- func (m *PrivateKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PrivateKey) XXX_Merge(src proto.Message)
- func (*PrivateKey) XXX_MessageName() string
- func (m *PrivateKey) XXX_Size() int
- func (m *PrivateKey) XXX_Unmarshal(b []byte) error
- type PublicKey
- func (p *PublicKey) AddressHashType() string
- func (*PublicKey) Descriptor() ([]byte, []int)
- func (p *PublicKey) GetAddress() Address
- func (m *PublicKey) GetCurveType() CurveType
- func (p *PublicKey) IsSet() bool
- func (p *PublicKey) IsValid() bool
- func (m *PublicKey) Marshal() (dAtA []byte, err error)
- func (p *PublicKey) MarshalJSON() ([]byte, error)
- func (p *PublicKey) MarshalText() ([]byte, error)
- func (m *PublicKey) MarshalTo(dAtA []byte) (int, error)
- func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PublicKey) ProtoMessage()
- func (m *PublicKey) Reset()
- func (m *PublicKey) Size() (n int)
- func (p *PublicKey) String() string
- func (p PublicKey) TendermintAddress() tmCrypto.Address
- func (p PublicKey) TendermintPubKey() tmCrypto.PubKey
- func (m *PublicKey) Unmarshal(dAtA []byte) error
- func (p *PublicKey) UnmarshalJSON(text []byte) error
- func (p *PublicKey) UnmarshalText(text []byte) error
- func (p *PublicKey) Verify(msg []byte, signature *Signature) error
- func (m *PublicKey) XXX_DiscardUnknown()
- func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PublicKey) XXX_Merge(src proto.Message)
- func (*PublicKey) XXX_MessageName() string
- func (m *PublicKey) XXX_Size() int
- func (m *PublicKey) XXX_Unmarshal(b []byte) error
- type PublicKeyJSON
- type Secp256k1Signature
- type Signable
- type Signature
- func (*Signature) Descriptor() ([]byte, []int)
- func (m *Signature) GetCurveType() CurveType
- func (sig *Signature) GetEthSignature(chainID *big.Int) (*EIP155Signature, error)
- func (m *Signature) GetSignature() []byte
- func (m *Signature) Marshal() (dAtA []byte, err error)
- func (m *Signature) MarshalTo(dAtA []byte) (int, error)
- func (m *Signature) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Signature) ProtoMessage()
- func (sig *Signature) RawBytes() []byte
- func (m *Signature) Reset()
- func (m *Signature) Size() (n int)
- func (sig *Signature) String() string
- func (sig Signature) TendermintSignature() []byte
- func (m *Signature) Unmarshal(dAtA []byte) error
- func (m *Signature) XXX_DiscardUnknown()
- func (m *Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Signature) XXX_Merge(src proto.Message)
- func (*Signature) XXX_MessageName() string
- func (m *Signature) XXX_Size() int
- func (m *Signature) XXX_Unmarshal(b []byte) error
- type Signer
Constants ¶
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{}
Functions ¶
func EnsureEd25519PrivateKeyCorrect ¶
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 GetEthSignatureRecoveryID ¶ added in v0.34.4
func PublicKeyLength ¶
Returns the length in bytes of the public key
func SequenceNonce ¶ added in v0.24.4
Obtain a nearly unique nonce based on a monotonic account sequence number
Types ¶
type Address ¶
func AddressFromBytes ¶
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 ¶
func AddressFromWord256 ¶
func MaybeAddressFromBytes ¶
Returns a pointer to an Address that is nil iff len(bs) == 0 otherwise does the same as AddressFromBytes
func MustAddressFromBytes ¶
func MustAddressFromHexString ¶ added in v0.34.4
func NewContractAddress ¶
func NewContractAddress2 ¶ added in v0.24.0
func (Address) MarshalJSON ¶
func (Address) MarshalText ¶
func (*Address) UnmarshalJSON ¶
func (*Address) UnmarshalText ¶
type Addressable ¶ added in v0.20.0
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 ¶ added in v0.20.0
func NewAddressable(publicKey *PublicKey) Addressable
type CompactSecp256k1Signature ¶ added in v0.34.4
type CompactSecp256k1Signature struct {
Secp256k1Signature
}
*
btcec layout is: input: [ v | r | s ] bytes: [ 1 | 32 | 32 ] Where: v = 27 + recovery id (which of 4 possible x coords do we take as public key) (single byte but padded) r = encrypted random point s = signature proof Signature layout required by btcec: sig: [ r | s | v ] bytes: [ 32 | 32 | 1 ]
func (*CompactSecp256k1Signature) Marshal ¶ added in v0.34.4
func (s *CompactSecp256k1Signature) Marshal() ([]byte, error)
func (*CompactSecp256k1Signature) Unmarshal ¶ added in v0.34.4
func (s *CompactSecp256k1Signature) Unmarshal(bs []byte) error
type CurveType ¶
type CurveType uint32
func CurveTypeFromString ¶
type EIP155Signature ¶ added in v0.34.4
type EIP155Signature struct {
Secp256k1Signature
}
func (*EIP155Signature) ToCompactSignature ¶ added in v0.34.4
func (s *EIP155Signature) ToCompactSignature() ([]byte, error)
Get btcec compact signature (our standard)
type ErrInvalidCurve ¶
type ErrInvalidCurve uint32
func (ErrInvalidCurve) Error ¶
func (curveType ErrInvalidCurve) Error() string
type PrivateKey ¶
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 ¶
func GeneratePrivateKey(random io.Reader, curveType CurveType) (PrivateKey, error)
func PrivateKeyFromRawBytes ¶
func PrivateKeyFromRawBytes(privateKeyBytes []byte, curveType CurveType) (PrivateKey, error)
func PrivateKeyFromSecret ¶
func PrivateKeyFromSecret(secret string, curveType CurveType) PrivateKey
func (*PrivateKey) Descriptor ¶ added in v0.20.0
func (*PrivateKey) Descriptor() ([]byte, []int)
func (*PrivateKey) GetAddress ¶ added in v0.34.4
func (pk *PrivateKey) GetAddress() Address
func (PrivateKey) GetPublicKey ¶
func (p PrivateKey) GetPublicKey() *PublicKey
func (*PrivateKey) Marshal ¶ added in v0.20.0
func (m *PrivateKey) Marshal() (dAtA []byte, err error)
func (*PrivateKey) MarshalTo ¶ added in v0.20.0
func (m *PrivateKey) MarshalTo(dAtA []byte) (int, error)
func (*PrivateKey) MarshalToSizedBuffer ¶ added in v0.34.4
func (m *PrivateKey) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*PrivateKey) ProtoMessage ¶ added in v0.20.0
func (*PrivateKey) ProtoMessage()
func (PrivateKey) RawBytes ¶
func (p PrivateKey) RawBytes() []byte
func (*PrivateKey) Reset ¶ added in v0.20.0
func (m *PrivateKey) Reset()
func (*PrivateKey) Size ¶ added in v0.20.0
func (m *PrivateKey) Size() (n int)
func (PrivateKey) String ¶ added in v0.20.0
func (p PrivateKey) String() string
func (*PrivateKey) Unmarshal ¶ added in v0.20.0
func (m *PrivateKey) Unmarshal(dAtA []byte) error
func (*PrivateKey) XXX_DiscardUnknown ¶ added in v0.23.0
func (m *PrivateKey) XXX_DiscardUnknown()
func (*PrivateKey) XXX_Marshal ¶ added in v0.23.0
func (m *PrivateKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PrivateKey) XXX_Merge ¶ added in v0.23.0
func (m *PrivateKey) XXX_Merge(src proto.Message)
func (*PrivateKey) XXX_MessageName ¶ added in v0.20.0
func (*PrivateKey) XXX_MessageName() string
func (*PrivateKey) XXX_Size ¶ added in v0.23.0
func (m *PrivateKey) XXX_Size() int
func (*PrivateKey) XXX_Unmarshal ¶ added in v0.23.0
func (m *PrivateKey) XXX_Unmarshal(b []byte) error
type PublicKey ¶
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 PublicKeyFromBytes ¶
Currently this is a stub that reads the raw bytes returned by key_client and returns an ed25519 public key.
func PublicKeyFromTendermintPubKey ¶ added in v0.20.0
func (*PublicKey) AddressHashType ¶
func (*PublicKey) Descriptor ¶ added in v0.20.0
func (*PublicKey) GetAddress ¶ added in v0.23.0
func (*PublicKey) GetCurveType ¶ added in v0.20.0
func (*PublicKey) MarshalJSON ¶
func (*PublicKey) MarshalText ¶
func (*PublicKey) MarshalToSizedBuffer ¶ added in v0.34.4
func (*PublicKey) ProtoMessage ¶ added in v0.20.0
func (*PublicKey) ProtoMessage()
func (PublicKey) TendermintAddress ¶ added in v0.34.4
func (PublicKey) TendermintPubKey ¶ added in v0.20.1
func (*PublicKey) UnmarshalJSON ¶
func (*PublicKey) UnmarshalText ¶
func (*PublicKey) XXX_DiscardUnknown ¶ added in v0.23.0
func (m *PublicKey) XXX_DiscardUnknown()
func (*PublicKey) XXX_Marshal ¶ added in v0.23.0
func (*PublicKey) XXX_MessageName ¶ added in v0.20.0
func (*PublicKey) XXX_Unmarshal ¶ added in v0.23.0
type PublicKeyJSON ¶
type Secp256k1Signature ¶ added in v0.34.4
type Secp256k1Signature struct { // Magic parity byte (value varies by implementation to carry additional information) V big.Int `json:"v"` R big.Int `json:"r"` S big.Int `json:"s"` }
func (*Secp256k1Signature) BigRecoveryIndex ¶ added in v0.34.4
func (s *Secp256k1Signature) BigRecoveryIndex() *big.Int
func (*Secp256k1Signature) RecoveryIndex ¶ added in v0.34.4
func (s *Secp256k1Signature) RecoveryIndex() uint
Returns either 0 or 1 for the underlying parity of the public key solution
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing.
type Signature ¶
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 ¶
func (*Signature) Descriptor ¶ added in v0.20.1
func (*Signature) GetCurveType ¶ added in v0.20.1
func (*Signature) GetEthSignature ¶ added in v0.34.4
func (sig *Signature) GetEthSignature(chainID *big.Int) (*EIP155Signature, error)
func (*Signature) GetSignature ¶ added in v0.20.1
func (*Signature) MarshalToSizedBuffer ¶ added in v0.34.4
func (*Signature) ProtoMessage ¶ added in v0.20.1
func (*Signature) ProtoMessage()
func (Signature) TendermintSignature ¶ added in v0.20.1
func (*Signature) XXX_DiscardUnknown ¶ added in v0.23.0
func (m *Signature) XXX_DiscardUnknown()