crypto

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StellarAccountPrefix is a prefix for Stellar key pairs derivation.
	StellarAccountPrefix = "m/44'/148'"
	// StellarPrimaryAccountPath is a derivation path of the primary account.
	StellarPrimaryAccountPath = "m/44'/148'/0'"
	// StellarAccountPathFormat is a path format used for Stellar key pair
	// derivation as described in SEP-00XX. Use with `fmt.Sprintf` and `DeriveForPath`.
	StellarAccountPathFormat = "m/44'/148'/%d'"
	// FirstHardenedIndex is the index of the first hardened key.
	FirstHardenedIndex = uint32(0x80000000)
)

Variables

View Source
var (
	ErrInvalidPath        = errors.New("Invalid derivation path")
	ErrNoPublicDerivation = errors.New("No public derivation for ed25519")
)

Functions

This section is empty.

Types

type Ed25519KeyPair

type Ed25519KeyPair struct {
	// contains filtered or unexported fields
}

func NewEd25519KeyPair

func NewEd25519KeyPair(privateKey ed25519.PrivateKey) *Ed25519KeyPair

func (*Ed25519KeyPair) PrivateKey

func (e *Ed25519KeyPair) PrivateKey() []byte

func (*Ed25519KeyPair) PublicKey

func (e *Ed25519KeyPair) PublicKey() []byte

func (*Ed25519KeyPair) Sign

func (e *Ed25519KeyPair) Sign(msg []byte) []byte

type Key

type Key struct {
	Key       []byte
	ChainCode []byte
}

func DeriveForPath

func DeriveForPath(path string, seed []byte) (*Key, error)

DeriveForPath derives key for a path in BIP-44 format and a seed. Ed25119 derivation operated on hardened keys only.

func NewMasterKey

func NewMasterKey(seed []byte) (*Key, error)

NewMasterKey generates a new master key from seed.

func (*Key) Derive

func (k *Key) Derive(i uint32) (*Key, error)

func (*Key) PublicKey

func (k *Key) PublicKey() ([]byte, error)

PublicKey returns public key for a derived private key.

func (*Key) RawSeed

func (k *Key) RawSeed() [32]byte

RawSeed returns raw seed bytes

type KeyPair

type KeyPair interface {
	Sign(msg []byte) []byte
	PublicKey() []byte
	PrivateKey() []byte
}

type Signer

type Signer[T any] interface {
	Sign(msg []byte) T
}

Jump to

Keyboard shortcuts

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