Documentation ¶
Index ¶
- Constants
- Variables
- func RandomCSPRNG(n int) []byte
- type Cipher
- func (c *Cipher) Decrypt(data []byte, passphrase []byte) ([]byte, error)
- func (c *Cipher) DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error)
- func (c *Cipher) Encrypt(data []byte, passphrase []byte) ([]byte, error)
- func (c *Cipher) EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error)
- type Encrypt
- type Scrypt
- func (s *Scrypt) Decrypt(data []byte, passphrase []byte) ([]byte, error)
- func (s *Scrypt) DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error)
- func (s *Scrypt) Encrypt(data []byte, passphrase []byte) ([]byte, error)
- func (s *Scrypt) EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error)
- func (s *Scrypt) ScryptEncrypt(data []byte, passphrase []byte, N, r, p int) ([]byte, error)
Constants ¶
View Source
const ( // ScryptKDF name ScryptKDF = "scrypt" // StandardScryptN N parameter of Scrypt encryption algorithm StandardScryptN = 1 << 12 // StandardScryptR r parameter of Scrypt encryption algorithm StandardScryptR = 8 // StandardScryptP p parameter of Scrypt encryption algorithm StandardScryptP = 1 // ScryptDKLen get derived key length ScryptDKLen = 32 )
Variables ¶
View Source
var ( // ErrVersionInvalid version not supported ErrVersionInvalid = errors.New("version not supported") // ErrKDFInvalid cipher not supported ErrKDFInvalid = errors.New("kdf not supported") // ErrCipherInvalid cipher not supported ErrCipherInvalid = errors.New("cipher not supported") // ErrDecrypt decrypt failed ErrDecrypt = errors.New("could not decrypt key with given passphrase") )
Functions ¶
func RandomCSPRNG ¶
RandomCSPRNG a cryptographically secure pseudo-random number generator
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
Cipher encrypt cipher
func (*Cipher) DecryptKey ¶
DecryptKey decrypts a key, returning the private key itself.
type Encrypt ¶
type Encrypt interface { // Encrypt encrypts data with passphrase, Encrypt(data []byte, passphrase []byte) ([]byte, error) // EncryptKey encrypt key with address EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error) // Decrypt decrypts data with passphrase, returning origin data. Decrypt(data []byte, passphrase []byte) ([]byte, error) // DecryptKey decrypts a key from a json blob, returning the private key itself. DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error) }
Encrypt interface for encrypt
type Scrypt ¶
type Scrypt struct { }
Scrypt scrypt encrypt
func (*Scrypt) DecryptKey ¶
DecryptKey decrypts a key from a json blob, returning the private key itself.
func (*Scrypt) EncryptKey ¶
EncryptKey encrypt key with address
func (*Scrypt) ScryptEncrypt ¶
ScryptEncrypt encrypts a key using the specified scrypt parameters into a json blob that can be decrypted later on. N is a CPU/memory cost parameter, which must be a power of two greater than 1. r and p must satisfy r * p < 2³⁰. If the parameters do not satisfy the limits, the function returns a nil byte slice and an error.
Click to show internal directories.
Click to hide internal directories.