ed25519

package
v0.60.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PrivKeyName = "tendermint/PrivKeyEd25519"
	PubKeyName  = "tendermint/PubKeyEd25519"
	// PubKeySize is is the size, in bytes, of public keys as used in this package.
	PubKeySize = 32
	// PrivKeySize is the size, in bytes, of private keys as used in this package.
	PrivKeySize = 64
	// Size of an Edwards25519 signature. Namely the size of a compressed
	// Edwards25519 point, and a field element. Both of which are 32 bytes.
	SignatureSize = 64
	// SeedSize is the size, in bytes, of private key seeds. These are the
	// private key representations used by RFC 8032.
	SeedSize = 32
)

Variables

View Source
var (
	ErrInvalidLengthKeys        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowKeys          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group")
)

Functions

This section is empty.

Types

type PrivKey deprecated

type PrivKey struct {
	Key crypto_ed25519.PrivateKey `protobuf:"bytes,1,opt,name=key,proto3,casttype=crypto/ed25519.PrivateKey" json:"key,omitempty"`
}

Deprecated: PrivKey defines a ed25519 private key. NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.

func GenPrivKey

func GenPrivKey() *PrivKey

GenPrivKey generates a new ed25519 private key. These ed25519 keys must not be used in SDK apps except in a tendermint validator context. It uses OS randomness in conjunction with the current global random seed in tendermint/libs/common to generate the private key.

func GenPrivKeyFromSecret

func GenPrivKeyFromSecret(secret []byte) *PrivKey

GenPrivKeyFromSecret hashes the secret with SHA2, and uses that 32 byte output to create the private key. NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.

func (*PrivKey) Bytes

func (privKey *PrivKey) Bytes() []byte

Bytes returns the privkey byte format.

func (*PrivKey) Descriptor

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

func (*PrivKey) Equals

func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool

Equals - you probably don't need to use this. Runs in constant time based on length of the keys.

func (*PrivKey) GetKey

func (m *PrivKey) GetKey() crypto_ed25519.PrivateKey

func (*PrivKey) Marshal

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

func (PrivKey) MarshalAmino

func (privKey PrivKey) MarshalAmino() ([]byte, error)

MarshalAmino overrides Amino binary marshalling.

func (PrivKey) MarshalAminoJSON

func (privKey PrivKey) MarshalAminoJSON() ([]byte, error)

MarshalAminoJSON overrides Amino JSON marshalling.

func (*PrivKey) MarshalTo

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

func (*PrivKey) MarshalToSizedBuffer

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

func (*PrivKey) ProtoMessage

func (*PrivKey) ProtoMessage()

func (*PrivKey) PubKey

func (privKey *PrivKey) PubKey() cryptotypes.PubKey

PubKey gets the corresponding public key from the private key.

Panics if the private key is not initialized.

func (*PrivKey) Reset

func (m *PrivKey) Reset()

func (*PrivKey) Sign

func (privKey *PrivKey) Sign(msg []byte) ([]byte, error)

Sign produces a signature on the provided message. This assumes the privkey is wellformed in the golang format. The first 32 bytes should be random, corresponding to the normal ed25519 private key. The latter 32 bytes should be the compressed public key. If these conditions aren't met, Sign will panic or produce an incorrect signature.

func (*PrivKey) Size

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

func (*PrivKey) String

func (m *PrivKey) String() string

func (*PrivKey) Type

func (privKey *PrivKey) Type() string

func (*PrivKey) Unmarshal

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

func (*PrivKey) UnmarshalAmino

func (privKey *PrivKey) UnmarshalAmino(bz []byte) error

UnmarshalAmino overrides Amino binary marshalling.

func (*PrivKey) UnmarshalAminoJSON

func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error

UnmarshalAminoJSON overrides Amino JSON marshalling.

func (*PrivKey) XXX_DiscardUnknown

func (m *PrivKey) XXX_DiscardUnknown()

func (*PrivKey) XXX_Marshal

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

func (*PrivKey) XXX_Merge

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

func (*PrivKey) XXX_Size

func (m *PrivKey) XXX_Size() int

func (*PrivKey) XXX_Unmarshal

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

type PubKey

type PubKey struct {
	Key crypto_ed25519.PublicKey `protobuf:"bytes,1,opt,name=key,proto3,casttype=crypto/ed25519.PublicKey" json:"key,omitempty"`
}

PubKey is an ed25519 public key for handling Tendermint keys in SDK. It's needed for Any serialization and SDK compatibility. It must not be used in a non Tendermint key context because it doesn't implement ADR-28. Nevertheless, you will like to use ed25519 in app user level then you must create a new proto message and follow ADR-28 for Address construction.

func (*PubKey) Address

func (pubKey *PubKey) Address() crypto.Address

Address is the SHA256-20 of the raw pubkey bytes. It doesn't implement ADR-28 addresses and it must not be used in SDK except in a tendermint validator context.

func (*PubKey) Bytes

func (pubKey *PubKey) Bytes() []byte

Bytes returns the PubKey byte format.

func (*PubKey) Descriptor

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

func (*PubKey) Equals

func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool

func (*PubKey) GetKey

func (m *PubKey) GetKey() crypto_ed25519.PublicKey

func (*PubKey) Marshal

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

func (PubKey) MarshalAmino

func (pubKey PubKey) MarshalAmino() ([]byte, error)

MarshalAmino overrides Amino binary marshalling.

func (PubKey) MarshalAminoJSON

func (pubKey PubKey) MarshalAminoJSON() ([]byte, error)

MarshalAminoJSON overrides Amino JSON marshalling.

func (*PubKey) MarshalTo

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

func (*PubKey) MarshalToSizedBuffer

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

func (*PubKey) ProtoMessage

func (*PubKey) ProtoMessage()

func (*PubKey) Reset

func (m *PubKey) Reset()

func (*PubKey) Size

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

func (*PubKey) String

func (pubKey *PubKey) String() string

String returns Hex representation of a pubkey with it's type

func (*PubKey) Type

func (pubKey *PubKey) Type() string

func (*PubKey) Unmarshal

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

func (*PubKey) UnmarshalAmino

func (pubKey *PubKey) UnmarshalAmino(bz []byte) error

UnmarshalAmino overrides Amino binary marshalling.

func (*PubKey) UnmarshalAminoJSON

func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error

UnmarshalAminoJSON overrides Amino JSON marshalling.

func (*PubKey) VerifySignature

func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool

func (*PubKey) XXX_DiscardUnknown

func (m *PubKey) XXX_DiscardUnknown()

func (*PubKey) XXX_Marshal

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

func (*PubKey) XXX_Merge

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

func (*PubKey) XXX_Size

func (m *PubKey) XXX_Size() int

func (*PubKey) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL