crypto

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACCOUNT_ZERO = "rrrrrrrrrrrrrrrrrrrrrhoLvTp"
	ACCOUNT_ONE  = "rrrrrrrrrrrrrrrrrrrrBZbvji"
	NaN          = "rrrrrrrrrrrrrrrrrrrn5RM1rHd"
	ROOT         = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
)

Variables

This section is empty.

Functions

func DoubleSha256

func DoubleSha256(b []byte) []byte

func NewEd25519Key

func NewEd25519Key(seed []byte) (*ed25519key, error)

func Sha256RipeMD160

func Sha256RipeMD160(b []byte) []byte

func Sha512Half

func Sha512Half(b []byte) []byte

Returns first 32 bytes of a SHA512 of the input bytes

func Sha512Quarter

func Sha512Quarter(b []byte) []byte

Returns first 16 bytes of a SHA512 of the input bytes

func Sign

func Sign(privateKey, hash, msg []byte) ([]byte, error)

func Verify

func Verify(publicKey, hash, msg, signature []byte) (bool, error)

Types

type EcdsaKey

type EcdsaKey struct {
	*btcec.PrivateKey
}

func GenEcdsaKey

func GenEcdsaKey() (*EcdsaKey, error)

GenEcdsaKey 生成 secp256k1 key

func LoadECDSKey

func LoadECDSKey(privateKeyBytes []byte) *EcdsaKey

func NewECDSAKey

func NewECDSAKey(seed []byte) (*EcdsaKey, error)

If seed is nil, generate a random one

func (*EcdsaKey) EncodeAddressString

func (k *EcdsaKey) EncodeAddressString(compressed bool) string

func (*EcdsaKey) Id

func (k *EcdsaKey) Id(sequence *uint32) []byte

func (*EcdsaKey) Private

func (k *EcdsaKey) Private(sequence *uint32) []byte

func (*EcdsaKey) Public

func (k *EcdsaKey) Public(sequence *uint32) []byte

type Hash

type Hash interface {
	Version() HashVersion
	Payload() []byte
	PayloadTrimmed() []byte
	Value() *big.Int
	String() string
	Clone() Hash
	MarshalText() ([]byte, error)
}

func AccountId

func AccountId(key Key, sequence *uint32) (Hash, error)

func AccountPrivateKey

func AccountPrivateKey(key Key, sequence *uint32) (Hash, error)

func AccountPublicKey

func AccountPublicKey(key Key, sequence *uint32) (Hash, error)

func GenerateFamilySeed

func GenerateFamilySeed(password string) (Hash, error)

func NewAccountId

func NewAccountId(b []byte) (Hash, error)

func NewAccountPrivateKey

func NewAccountPrivateKey(b []byte) (Hash, error)

func NewAccountPublicKey

func NewAccountPublicKey(b []byte) (Hash, error)

func NewFamilySeed

func NewFamilySeed(b []byte) (Hash, error)

func NewNodePrivateKey

func NewNodePrivateKey(b []byte) (Hash, error)

func NewNodePublicKey

func NewNodePublicKey(b []byte) (Hash, error)

func NewRippleHash

func NewRippleHash(s string) (Hash, error)

func NewRippleHashCheck

func NewRippleHashCheck(s string, version HashVersion) (Hash, error)

Checks hash matches expected version

func NodePrivateKey

func NodePrivateKey(key Key) (Hash, error)

func NodePublicKey

func NodePublicKey(key Key) (Hash, error)

type HashVersion

type HashVersion byte
const (
	ALPHABET = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"

	RIPPLE_ACCOUNT_ID      HashVersion = 0
	RIPPLE_NODE_PUBLIC     HashVersion = 28
	RIPPLE_NODE_PRIVATE    HashVersion = 32
	RIPPLE_FAMILY_SEED     HashVersion = 33
	RIPPLE_ACCOUNT_PRIVATE HashVersion = 34
	RIPPLE_ACCOUNT_PUBLIC  HashVersion = 35
)

type Key

type Key interface {
	Private(*uint32) []byte
	Id(*uint32) []byte
	Public(*uint32) []byte
}

Jump to

Keyboard shortcuts

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