crypto

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSeedMethod default seed method
	DefaultSeedMethod = SeedMethodBip39
)

Variables

This section is empty.

Functions

func CreateSeed added in v1.0.1

func CreateSeed(length int) ([]byte, error)

CreateSeed Create a new seed (secrets).

func GetPrivateKey

func GetPrivateKey(secrets KeyPairSecrets) (*ecdsa.PrivateKey, error)

GetPrivateKey Get private key from key pair secrets

func GetPrivateKeyFromExponent

func GetPrivateKeyFromExponent(privateExponentHex string) (*ecdsa.PrivateKey, error)

GetPrivateKeyFromExponent Get private key (ECDSA) from private exponent as hex string

func GetPublicKeyBase58FromKeyPairSecrets

func GetPublicKeyBase58FromKeyPairSecrets(secrets KeyPairSecrets) (string, error)

GetPublicKeyBase58FromKeyPairSecrets Get public key base58 fron key pair secrets

func GetPublicKeyFromBase58

func GetPublicKeyFromBase58(publicBase58 string) (*ecdsa.PublicKey, error)

GetPublicKeyFromBase58 Get public key ECDSA from public key base58

func GetPublicKeysFromPrivateKey

func GetPublicKeysFromPrivateKey(privateKey *ecdsa.PrivateKey) ([]byte, string, error)

GetPublicKeysFromPrivateKey Get public keys (bytes and base58) from private key (ECDSA)

func MnemonicBip39ToSeed

func MnemonicBip39ToSeed(mnemonic string) ([]byte, error)

MnemonicBip39ToSeed takes mnemonic string and returns seed

func PathForDIDType

func PathForDIDType(name string, didType id.DidType) string

PathForDIDType Build a valid path string given didType and name string

func SeedBip39ToMnemonic

func SeedBip39ToMnemonic(seed []byte) (string, error)

SeedBip39ToMnemonic takes the seed bytes and returns mnemonic string

func ValidateBip39Seed

func ValidateBip39Seed(seed []byte) error

ValidateBip39Seed Valid BIP39 seed

Types

type KeyPair

type KeyPair struct {
	PrivateKey      *ecdsa.PrivateKey
	PublicKeyBytes  []byte
	PublicKeyBase58 string
}

KeyPair struct

func GetKeyPair

func GetKeyPair(secrets KeyPairSecrets) (*KeyPair, error)

GetKeyPair Get key pair from key pair secrets

type KeyPairSecrets

type KeyPairSecrets interface {
	Seed() []byte
	Path() string
	SeedMethod() SeedMethod
	Password() string
}

KeyPairSecrets Key pair secrets

func NewDefaultKeyPairSecrets

func NewDefaultKeyPairSecrets(seed []byte, path string) (KeyPairSecrets, error)

NewDefaultKeyPairSecrets builds a valid key pair secrets (default SeedMethodBip39 and default password "")

func NewDefaultKeyPairSecretsWithPassword

func NewDefaultKeyPairSecretsWithPassword(seed []byte, path string, password string) (KeyPairSecrets, error)

NewDefaultKeyPairSecretsWithPassword builds a valid key pair secrets (default SeedMethodBip39)

func NewKeyPairSecrets

func NewKeyPairSecrets(seed []byte, path string, seedMethod SeedMethod, password string) (KeyPairSecrets, error)

NewKeyPairSecrets builds a valid key pair secrets

type SeedMethod

type SeedMethod int

SeedMethod seed method type

const (
	// SeedMethodBip39 (0) uses pbkdf2 2048 iterations
	SeedMethodBip39 SeedMethod = iota
	// SeedMethodNone (1) is a naive method using hmac_sha256
	SeedMethodNone
)

Jump to

Keyboard shortcuts

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