crypto

package
v0.7.5-beta.6 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

BTCCoinType is the CoinType for Bitcoin.

View Source
const COSMOSCoinType = types.CoinType_CoinType_COSMOS

COSMOSCoinType is the CoinType for Cosmos.

View Source
const (
	// ChallengeLength - Length of bytes to generate for a challenge
	ChallengeLength = 32
)

DOGECoinType is the CoinType for Dogecoin.

ETHCoinType is the CoinType for Ethereum.

Ed25519KeyType is the key type for ed25519.

FILCoinType is the CoinType for Filecoin.

HNSCoinType is the CoinType for Handshake.

LTCCoinType is the CoinType for Litecoin.

RSAKeyType is the key type for RSA.

SOLCoinType is the CoinType for Solana.

SONRCoinType is the CoinType for Sonr.

Secp256k1KeyType is the key type for secp256k1.

TestCoinType is the CoinType for Testnet.

WebAuthnKeyType is the key type for WebAuthn.

XRPCoinType is the CoinType for XRP.

Variables

View Source
var AllCoinTypes = types.AllCoinTypes

AllCoinTypes is a slice of all CoinTypes.

Functions

func Base58Decode added in v0.6.26

func Base58Decode(str string) ([]byte, error)

Base58Decode takes a base68 encoded string and returns a byte array.

func Base58Encode added in v0.6.26

func Base58Encode(bz []byte) string

Base58Encode takes a byte array and returns a base68 encoded string.

func Base64Decode added in v0.6.26

func Base64Decode(str string) ([]byte, error)

Base64Decode takes a base64 encoded string and returns a byte array.

func Base64Encode added in v0.6.26

func Base64Encode(bz []byte) string

Base64Encode takes a byte array and returns a base64 encoded string.

func GenerateChallenge added in v0.7.3

func GenerateChallenge() (challenge protocol.URLEncodedBase64, err error)

GenerateChallenge creates a new challenge that should be signed and returned by the authenticator. The spec recommends using at least 16 bytes with 100 bits of entropy. We use 32 bytes.

func HexDecode added in v0.7.3

func HexDecode(str string) ([]byte, error)

HexDecode takes a hex encoded string and returns a byte array.

func HexEncode added in v0.7.3

func HexEncode(bz []byte) string

HexEncode takes a byte array and returns a hex encoded string.

func NewSNRCoins added in v0.7.3

func NewSNRCoins(amt int) sdk.Coins

NewSNRCoins returns a new sdk.Coins object with the given amount of SNR.

func NewUSNRCoins added in v0.7.3

func NewUSNRCoins(amt int) sdk.Coins

NewUSNRCoins returns a new sdk.Coins object with the given amount of USNR.

Types

type AccountData added in v0.7.3

type AccountData = crypto.AccountData

AccountData is the data that is returned by the keygen process. It contains the address, the algorithm used to generate the key pair and the public key.

func NewDefaultAccountData added in v0.7.3

func NewDefaultAccountData(cointype CoinType, publicKey *PubKey) (*AccountData, error)

NewDefaultAccountData creates a new AccountData with the default values.

type Algo added in v0.7.3

type Algo string

Algo is the type of algorithm used for key generation.

const (
	// AlgoSecp256k1 is the secp256k1 algorithm.
	AlgoSecp256k1 Algo = "secp256k1"

	// AlgoEd25519 is the ed25519 algorithm.
	AlgoEd25519 Algo = "ed25519"

	// AlgoSr25519 is the sr25519 algorithm.
	AlgoSr25519 Algo = "sr25519"
)

func (Algo) KeyType added in v0.7.3

func (a Algo) KeyType() KeyType

KeyType returns the KeyType of the algorithm.

type CoinType added in v0.3.1

type CoinType = types.CoinType

CoinType is a type alias for types.CoinType in pkg/crypto/internal/types.

func CoinTypeFromAddrPrefix added in v0.4.3

func CoinTypeFromAddrPrefix(str string) CoinType

CoinTypeFromAddrPrefix returns the CoinType from the public key address prefix (btc, eth).

func CoinTypeFromBipPath added in v0.4.3

func CoinTypeFromBipPath(i uint32) CoinType

CoinTypeFromBipPath returns the CoinType from the BIP Path (0, 60).

func CoinTypeFromDidMethod added in v0.4.3

func CoinTypeFromDidMethod(str string) CoinType

CoinTypeFromDidMethod returns the CoinType from the DID Method (btc, eth).

func CoinTypeFromName added in v0.4.3

func CoinTypeFromName(str string) CoinType

CoinTypeFromName returns the CoinType from the Blockchain name (Bitcoin, Ethereum).

func CoinTypeFromTicker added in v0.4.3

func CoinTypeFromTicker(str string) CoinType

CoinTypeFromTicker returns the CoinType from the tokens Ticker (BTC, ETH).

type EncryptionKey added in v0.7.3

type EncryptionKey interface {
	// Bytes returns the bytes of the encryption key
	Bytes() []byte

	// Encrypt encrypts the message with the encryption key
	Encrypt(msg []byte) ([]byte, error)

	// Decrypt decrypts the message with the encryption key
	Decrypt(msg []byte) ([]byte, error)
}

EncryptionKey is an interface for encryption keys

type KeyType added in v0.3.1

type KeyType = types.KeyType

KeyType is a type alias for types.KeyType in pkg/crypto/internal/types.

type PubKey

type PubKey = types.PubKey

PubKey is a type alias for types.PubKey in pkg/crypto/internal/types.

func NewEd25519PubKey added in v0.3.1

func NewEd25519PubKey(bz []byte) *PubKey

NewEd25519PubKey takes a byte array of raw public key bytes and returns a PubKey.

func NewPubKey added in v0.7.3

func NewPubKey(bz []byte, kt KeyType) *PubKey

NewPubKey takes a byte array and returns a PubKey

func NewRSAPubKey added in v0.3.1

func NewRSAPubKey(bz []byte) *PubKey

NewRSAPubKey takes a byte array of raw public key bytes and returns a PubKey.

func NewSecp256k1PubKey added in v0.3.1

func NewSecp256k1PubKey(pk *secp256k1.PubKey) *PubKey

NewSecp256k1PubKey takes a hex string and returns a PubKey

func NewWebAuthnPubKey added in v0.3.1

func NewWebAuthnPubKey(bz []byte) *PubKey

NewWebAuthnPubKey takes a byte array of raw public key bytes and returns a PubKey.

func PubKeyFromBytes added in v0.3.1

func PubKeyFromBytes(bz []byte) (*PubKey, error)

PubKeyFromBytes takes a byte array and returns a PubKey

func PubKeyFromDID added in v0.3.1

func PubKeyFromDID(did string) (*PubKey, error)

PubKeyFromDID takes a string of a DID, decodes it from base58, unmarshals it into a PubKey, and returns the PubKey

type Secp256k1PubKey added in v0.7.3

type Secp256k1PubKey = secp256k1.PubKey

Secp256k1PubKey is a type alias for secp256k1.PubKey in pkg/crypto/keys/secp256k1.

Jump to

Keyboard shortcuts

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