crypto

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2014 License: LGPL-2.1-or-later Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MnemonicWords []string = []string{}/* 1626 elements not displayed */

Functions

func CreateAddress

func CreateAddress(b []byte, nonce uint64) []byte

Creates an ethereum address given the bytes and the nonce

func Decrypt added in v0.7.10

func Decrypt(prv *ecdsa.PrivateKey, ct []byte) ([]byte, error)

func Ecrecover

func Ecrecover(data []byte) []byte

func Encrypt added in v0.7.10

func Encrypt(pub *ecdsa.PublicKey, message []byte) ([]byte, error)

func FromECDSA

func FromECDSA(prv *ecdsa.PrivateKey) []byte

func FromECDSAPub

func FromECDSAPub(pub *ecdsa.PublicKey) []byte

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

func IndexOf added in v0.7.10

func IndexOf(slice []string, value string) int64

TODO: See if we can refactor this into a shared util lib if we need it multiple times

func MnemonicDecode added in v0.7.10

func MnemonicDecode(wordsar []string) string

func MnemonicEncode added in v0.7.10

func MnemonicEncode(message string) []string

func Ripemd160 added in v0.7.10

func Ripemd160(data []byte) []byte

func Sha256 added in v0.7.10

func Sha256(data []byte) []byte

func Sha3 added in v0.7.10

func Sha3(data []byte) []byte

func SigToPub

func SigToPub(hash, sig []byte) *ecdsa.PublicKey

func Sign

func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)

func ToECDSA

func ToECDSA(prv []byte) *ecdsa.PrivateKey

New methods using proper ecdsa keys from the stdlib

func ToECDSAPub added in v0.7.10

func ToECDSAPub(pub []byte) *ecdsa.PublicKey

Types

type BitCurve added in v0.7.10

type BitCurve struct {
	P       *big.Int // the order of the underlying field
	N       *big.Int // the order of the base point
	B       *big.Int // the constant of the BitCurve equation
	Gx, Gy  *big.Int // (x,y) of the base point
	BitSize int      // the size of the underlying field
}

A BitCurve represents a Koblitz Curve with a=0. See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

func S160 added in v0.7.10

func S160() *BitCurve

S160 returns a BitCurve which implements secp160k1 (see SEC 2 section 2.4.1)

func S192 added in v0.7.10

func S192() *BitCurve

S192 returns a BitCurve which implements secp192k1 (see SEC 2 section 2.5.1)

func S224 added in v0.7.10

func S224() *BitCurve

S224 returns a BitCurve which implements secp224k1 (see SEC 2 section 2.6.1)

func S256

func S256() *BitCurve

S256 returns a BitCurve which implements secp256k1 (see SEC 2 section 2.7.1)

func (*BitCurve) Add added in v0.7.10

func (BitCurve *BitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

Add returns the sum of (x1,y1) and (x2,y2)

func (*BitCurve) Double added in v0.7.10

func (BitCurve *BitCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

Double returns 2*(x,y)

func (*BitCurve) GenerateKey added in v0.7.10

func (BitCurve *BitCurve) GenerateKey(rand io.Reader) (priv []byte, x, y *big.Int, err error)

TODO: double check if it is okay GenerateKey returns a public/private key pair. The private key is generated using the given reader, which must return random data.

func (*BitCurve) IsOnCurve added in v0.7.10

func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool

IsOnBitCurve returns true if the given (x,y) lies on the BitCurve.

func (*BitCurve) Marshal added in v0.7.10

func (BitCurve *BitCurve) Marshal(x, y *big.Int) []byte

Marshal converts a point into the form specified in section 4.3.6 of ANSI X9.62.

func (*BitCurve) Params added in v0.7.10

func (BitCurve *BitCurve) Params() *elliptic.CurveParams

func (*BitCurve) ScalarBaseMult added in v0.7.10

func (BitCurve *BitCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

ScalarBaseMult returns k*G, where G is the base point of the group and k is an integer in big-endian form.

func (*BitCurve) ScalarMult added in v0.7.10

func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)

TODO: double check if it is okay ScalarMult returns k*(Bx,By) where k is a number in big-endian form.

func (*BitCurve) Unmarshal added in v0.7.10

func (BitCurve *BitCurve) Unmarshal(data []byte) (x, y *big.Int)

Unmarshal converts a point, serialised by Marshal, into an x, y pair. On error, x = nil.

type DBKeyStore added in v0.7.10

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

func (*DBKeyStore) Load added in v0.7.10

func (k *DBKeyStore) Load(session string) (*KeyRing, error)

func (*DBKeyStore) Save added in v0.7.10

func (k *DBKeyStore) Save(session string, keyRing *KeyRing) error

type FileKeyStore added in v0.7.10

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

func (*FileKeyStore) Load added in v0.7.10

func (k *FileKeyStore) Load(session string) (*KeyRing, error)

func (*FileKeyStore) Save added in v0.7.10

func (k *FileKeyStore) Save(session string, keyRing *KeyRing) error

type KeyManager added in v0.7.10

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

func NewDBKeyManager added in v0.7.10

func NewDBKeyManager(db ethutil.Database) *KeyManager

func NewFileKeyManager added in v0.7.10

func NewFileKeyManager(basedir string) *KeyManager

func (*KeyManager) Address added in v0.7.10

func (k *KeyManager) Address() []byte

func (*KeyManager) Export added in v0.7.10

func (k *KeyManager) Export(dir string) error

func (*KeyManager) Init added in v0.7.10

func (k *KeyManager) Init(session string, cursor int, force bool) error

func (*KeyManager) InitFromSecretsFile added in v0.7.10

func (k *KeyManager) InitFromSecretsFile(session string, cursor int, secretsfile string) error

func (*KeyManager) InitFromString added in v0.7.10

func (k *KeyManager) InitFromString(session string, cursor int, secrets string) error

func (*KeyManager) KeyPair added in v0.7.10

func (k *KeyManager) KeyPair() *KeyPair

func (*KeyManager) KeyRing added in v0.7.10

func (k *KeyManager) KeyRing() *KeyPair

func (*KeyManager) PrivateKey added in v0.7.10

func (k *KeyManager) PrivateKey() []byte

func (*KeyManager) PublicKey added in v0.7.10

func (k *KeyManager) PublicKey() []byte

func (*KeyManager) SetCursor added in v0.7.10

func (k *KeyManager) SetCursor(cursor int) error

type KeyPair added in v0.7.10

type KeyPair struct {
	PrivateKey []byte
	PublicKey  []byte
	// contains filtered or unexported fields
}

func GenerateNewKeyPair added in v0.7.10

func GenerateNewKeyPair() *KeyPair

func NewKeyPairFromSec added in v0.7.10

func NewKeyPairFromSec(seckey []byte) (*KeyPair, error)

func (*KeyPair) Address added in v0.7.10

func (k *KeyPair) Address() []byte

func (*KeyPair) AsStrings added in v0.7.10

func (k *KeyPair) AsStrings() (string, string, string, string)

func (*KeyPair) Mnemonic added in v0.7.10

func (k *KeyPair) Mnemonic() string

func (*KeyPair) RlpEncode added in v0.7.10

func (k *KeyPair) RlpEncode() []byte

func (*KeyPair) RlpValue added in v0.7.10

func (k *KeyPair) RlpValue() *ethutil.Value

type KeyRing added in v0.7.10

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

func NewGeneratedKeyRing added in v0.7.10

func NewGeneratedKeyRing(len int) *KeyRing

func NewKeyRing added in v0.7.10

func NewKeyRing() *KeyRing

func NewKeyRingFromBytes added in v0.7.10

func NewKeyRingFromBytes(data []byte) (*KeyRing, error)

func NewKeyRingFromFile added in v0.7.10

func NewKeyRingFromFile(secfile string) (*KeyRing, error)

func NewKeyRingFromSecrets added in v0.7.10

func NewKeyRingFromSecrets(secs [][]byte) (*KeyRing, error)

func NewKeyRingFromString added in v0.7.10

func NewKeyRingFromString(content string) (*KeyRing, error)

func (*KeyRing) AddKeyPair added in v0.7.10

func (k *KeyRing) AddKeyPair(keyPair *KeyPair)

func (*KeyRing) Each added in v0.7.10

func (k *KeyRing) Each(f func(*KeyPair))

func (*KeyRing) Empty added in v0.7.10

func (k *KeyRing) Empty() bool

func (*KeyRing) GetKeyPair added in v0.7.10

func (k *KeyRing) GetKeyPair(i int) *KeyPair

func (*KeyRing) Len added in v0.7.10

func (k *KeyRing) Len() int

func (*KeyRing) RlpEncode added in v0.7.10

func (k *KeyRing) RlpEncode() []byte

func (*KeyRing) RlpValue added in v0.7.10

func (k *KeyRing) RlpValue() *ethutil.Value

type KeyStore added in v0.7.10

type KeyStore interface {
	Load(string) (*KeyRing, error)
	Save(string, *KeyRing) error
}

Jump to

Keyboard shortcuts

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