crypto

package
v0.0.0-...-a88d24b Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2014 License: ISC Imports: 9 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 Base58Decode

func Base58Decode(b, alphabet string) ([]byte, error)

Base58Decode decodes a modified base58 string to a byte slice and checks checksum.

func Base58Encode

func Base58Encode(b []byte, alphabet string) string

Base58Encode encodes a byte slice to a modified base58 string.

func DoubleSha256

func DoubleSha256(b []byte) ([]byte, error)

func ParsePublicKey

func ParsePublicKey(b []byte) (*btcec.PublicKey, error)

func ParsePublicKeyFromHash

func ParsePublicKeyFromHash(hash []byte) (*btcec.PublicKey, error)

func Sha256RipeMD160

func Sha256RipeMD160(b []byte) ([]byte, error)

func Sha512Half

func Sha512Half(b []byte) ([]byte, error)

Returns first 32 bytes of a SHA512 of the input bytes

func Sha512Quarter

func Sha512Quarter(b []byte) ([]byte, error)

Returns first 16 bytes of a SHA512 of the input bytes

func Verify

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

Verifies a hash using DER encoded signature

Types

type AccountKey

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

func (*AccountKey) PrivateAccountKey

func (a *AccountKey) PrivateAccountKey() (Hash, error)

func (*AccountKey) PrivateBytes

func (k *AccountKey) PrivateBytes() []byte

func (*AccountKey) PublicAccountKey

func (a *AccountKey) PublicAccountKey() (Hash, error)

func (*AccountKey) PublicCompressed

func (k *AccountKey) PublicCompressed() []byte

func (*AccountKey) Sign

func (k *AccountKey) Sign(hash []byte) ([]byte, error)

Returns DER encoded signature from input hash

type Hash

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

func GenerateFamilySeed

func GenerateFamilySeed(password string) (Hash, error)

func NewBitcoinAddress

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

func NewLitecoinAddress

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

func NewRippleAccount

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

func NewRippleFamilyGenerator

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

func NewRippleFamilySeed

func NewRippleFamilySeed(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 NewRipplePrivateAccount

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

func NewRipplePrivateNode

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

func NewRipplePublicAccount

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

func NewRipplePublicNode

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

type HashNetwork

type HashNetwork byte
const (
	RIPPLE   HashNetwork = 0
	BITCOIN  HashNetwork = 1
	LITECOIN HashNetwork = 2
)

type HashVersion

type HashVersion byte
const (
	RIPPLE_NODE_PUBLIC      HashVersion = 28
	RIPPLE_NODE_PRIVATE     HashVersion = 32
	RIPPLE_ACCOUNT_ID       HashVersion = 0
	RIPPLE_ACCOUNT_PUBLIC   HashVersion = 35
	RIPPLE_ACCOUNT_PRIVATE  HashVersion = 34
	RIPPLE_FAMILY_GENERATOR HashVersion = 41
	RIPPLE_FAMILY_SEED      HashVersion = 33
	BITCOIN_ADDRESS         HashVersion = 0
	LITECOIN_ADDRESS        HashVersion = 48
)

type Key

type Key interface {
	Sign(b []byte) ([]byte, error)
	PublicCompressed() []byte
	PrivateBytes() []byte
}

type ProofOfWork

type ProofOfWork struct {
	Challenge  *big.Int
	Target     *big.Int
	Iterations int
	// contains filtered or unexported fields
}

func NewProofOfWork

func NewProofOfWork(challenge, target []byte, iterations uint32) *ProofOfWork

func (*ProofOfWork) Check

func (pow *ProofOfWork) Check(nonce []byte) (bool, error)

func (*ProofOfWork) Next

func (pow *ProofOfWork) Next(nonce []byte) (*big.Int, error)

func (*ProofOfWork) Solve

func (pow *ProofOfWork) Solve() ([]byte, error)

type RootDeterministicKey

type RootDeterministicKey struct {
	Seed Hash
	// contains filtered or unexported fields
}

func GenerateRootDeterministicKey

func GenerateRootDeterministicKey(seed []byte) (*RootDeterministicKey, error)

If seed is nil, generate a random one

func (*RootDeterministicKey) GenerateAccountId

func (r *RootDeterministicKey) GenerateAccountId(sequence int32) (Hash, error)

func (*RootDeterministicKey) GenerateAccountKey

func (r *RootDeterministicKey) GenerateAccountKey(sequence int32) (*AccountKey, error)

func (*RootDeterministicKey) PrivateBytes

func (k *RootDeterministicKey) PrivateBytes() []byte

func (*RootDeterministicKey) PrivateNodeKey

func (r *RootDeterministicKey) PrivateNodeKey() (Hash, error)

func (*RootDeterministicKey) PublicCompressed

func (k *RootDeterministicKey) PublicCompressed() []byte

func (*RootDeterministicKey) PublicGenerator

func (r *RootDeterministicKey) PublicGenerator() (Hash, error)

func (*RootDeterministicKey) PublicNodeKey

func (r *RootDeterministicKey) PublicNodeKey() (Hash, error)

func (*RootDeterministicKey) Sign

func (k *RootDeterministicKey) Sign(hash []byte) ([]byte, error)

Returns DER encoded signature from input hash

Jump to

Keyboard shortcuts

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