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
- Variables
- func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error)
- type Key
- type KeyStore
- func (ks *KeyStore) Accounts() ([]string, error)
- func (ks *KeyStore) Delete(a account.Account, passphrase string) error
- func (ks *KeyStore) Find(addr account.Address) *account.Account
- func (ks *KeyStore) HasAddress(addr account.Address) bool
- func (ks *KeyStore) NewAccount(passphrase string, accountType uint32) (account.Account, error)
- func (ks *KeyStore) SignHashWithPassphrase(a account.Account, passphrase string, hash []byte) (signature []byte, err error)
- func (ks *KeyStore) SignTx(a account.Account, tx *pb.Transaction, pass string) (*pb.Transaction, error)
- func (ks *KeyStore) Update(a account.Account, passphrase, newPassphrase string) error
Constants ¶
const ( ScryptN = 2 ScryptP = 1 )
const ( StandardScryptN = 1 << 18 StandardScryptP = 1 LightScryptN = 1 << 12 LightScryptP = 6 )
Variables ¶
var ( ErrNoMatch = errors.New("no key for given address or file") ErrDecrypt = errors.New("could not decrypt key with given passphrase") )
var KeyStoreScheme = "keystore"
Functions ¶
Types ¶
type Key ¶
func DecryptKey ¶
DecryptKey returns the decrypted key via auth
func (*Key) MarshalJSON ¶
Marshal key to json bytes
func (*Key) UnmarshalJSON ¶
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) HasAddress ¶
HasAddress returns if current node has the specified addr
func (*KeyStore) NewAccount ¶
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.