keystore

package
v0.0.0-...-c9d2d86 Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: ISC Imports: 26 Imported by: 0

Documentation

Overview

Copyright (C) 2017, Zipper Team. All rights reserved.

This file is part of zipper

The zipper is free software: you can use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ISC License for more details.

You should have received a copy of the ISC License along with this program. If not, see <https://opensource.org/licenses/isc>.

Index

Constants

View Source
const (
	ScryptN = 2
	ScryptP = 1
)
View Source
const (
	StandardScryptN = 1 << 18

	StandardScryptP = 1

	LightScryptN = 1 << 12

	LightScryptP = 6
)

Variables

View Source
var (
	ErrNoMatch = errors.New("no key for given address or file")
	ErrDecrypt = errors.New("could not decrypt key with given passphrase")
)
View Source
var KeyStoreScheme = "keystore"

Functions

func EncryptKey

func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error)

EncryptKey encrypt the key via auth

Types

type Key

type Key struct {
	Id         uuid.UUID
	Address    account.Address
	PrivateKey *crypto.PrivateKey
}

func DecryptKey

func DecryptKey(keyjson []byte, auth string) (*Key, error)

DecryptKey returns the decrypted key via auth

func (*Key) MarshalJSON

func (k *Key) MarshalJSON() (j []byte, err error)

Marshal key to json bytes

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(j []byte) (err error)

UnmarshalJSON restore key from json

type KeyStore

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

KeyStore definition

func NewKeyStore

func NewKeyStore(db *db.BlockchainDB, keydir string, scryptN, scryptP int) *KeyStore

NewKeyStore new a KeyStore instance

func NewPlaintextKeyStore

func NewPlaintextKeyStore(db *db.BlockchainDB, keydir string) *KeyStore

NewPlaintextKeyStore new a PlaintextKeyStore instance

func (*KeyStore) Accounts

func (ks *KeyStore) Accounts() ([]string, error)

func (*KeyStore) Delete

func (ks *KeyStore) Delete(a account.Account, passphrase string) error

Delete removes the speciified account

func (*KeyStore) Find

func (ks *KeyStore) Find(addr account.Address) *account.Account

func (*KeyStore) HasAddress

func (ks *KeyStore) HasAddress(addr account.Address) bool

HasAddress returns if current node has the specified addr

func (*KeyStore) NewAccount

func (ks *KeyStore) NewAccount(passphrase string, accountType uint32) (account.Account, error)

NewAccount creates a new account

func (*KeyStore) SignHashWithPassphrase

func (ks *KeyStore) SignHashWithPassphrase(a account.Account, passphrase string, hash []byte) (signature []byte, err error)

SignHashWithPassphrase signs hash if the private key matching the given address can be decrypted with the given passphrase. The produced signature is in the [R || S || V] format where V is 0 or 1.

func (*KeyStore) SignTx

func (ks *KeyStore) SignTx(a account.Account, tx *pb.Transaction, pass string) (*pb.Transaction, error)

SignTx sign the specified transaction

func (*KeyStore) Update

func (ks *KeyStore) Update(a account.Account, passphrase, newPassphrase string) error

Update update the specified account

Jump to

Keyboard shortcuts

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