Documentation ¶
Index ¶
- Constants
- func CreateSeed(length int) ([]byte, error)
- func GetPrivateKey(secrets KeyPairSecrets) (*ecdsa.PrivateKey, error)
- func GetPrivateKeyFromExponent(privateExponentHex string) (*ecdsa.PrivateKey, error)
- func GetPublicKeyBase58FromKeyPairSecrets(secrets KeyPairSecrets) (string, error)
- func GetPublicKeyFromBase58(publicBase58 string) (*ecdsa.PublicKey, error)
- func GetPublicKeysFromPrivateKey(privateKey *ecdsa.PrivateKey) ([]byte, string, error)
- func MnemonicBip39ToSeed(mnemonic string) ([]byte, error)
- func PathForDIDType(name string, didType id.DidType) string
- func SeedBip39ToMnemonic(seed []byte) (string, error)
- func ValidateBip39Seed(seed []byte) error
- type KeyPair
- type KeyPairSecrets
- func NewDefaultKeyPairSecrets(seed []byte, path string) (KeyPairSecrets, error)
- func NewDefaultKeyPairSecretsWithPassword(seed []byte, path string, password string) (KeyPairSecrets, error)
- func NewKeyPairSecrets(seed []byte, path string, seedMethod SeedMethod, password string) (KeyPairSecrets, error)
- type SeedMethod
Constants ¶
const ( // DefaultSeedMethod default seed method DefaultSeedMethod = SeedMethodBip39 )
Variables ¶
This section is empty.
Functions ¶
func CreateSeed ¶
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 ¶
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 ¶
MnemonicBip39ToSeed takes mnemonic string and returns seed
func PathForDIDType ¶
PathForDIDType Build a valid path string given didType and name string
func SeedBip39ToMnemonic ¶
SeedBip39ToMnemonic takes the seed bytes and returns mnemonic string
func ValidateBip39Seed ¶
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 )