Documentation ¶
Overview ¶
description: subchain-sdk-go
@author: xwc1125 @date: 2020/8/6 0006
description: keybox
@author: xwc1125 @date: 2020/8/6 0006
Index ¶
Constants ¶
View Source
const ( // StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptN = 1 << 18 // StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptP = 1 // LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB // memory and taking approximately 100ms CPU time on a modern processor. LightScryptN = 1 << 12 // LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB // memory and taking approximately 100ms CPU time on a modern processor. LightScryptP = 6 )
Variables ¶
View Source
var (
ErrDecrypt = errors.New("could not decrypt key with given password")
)
Functions ¶
func DecryptDataV3 ¶
func DecryptDataV3(cryptoJson CryptoJSON, auth string) ([]byte, error)
func EncryptKey ¶
EncryptKey encrypts a key using the specified scrypt parameters into a json blob that can be decrypted later on.
Types ¶
type CryptoJSON ¶
type CryptoJSON struct { Cipher string `json:"cipher"` CipherText string `json:"ciphertext"` CipherParams cipherparamsJSON `json:"cipherparams"` KDF string `json:"kdf"` KDFParams map[string]interface{} `json:"kdfparams"` MAC string `json:"mac"` }
func EncryptDataV3 ¶
func EncryptDataV3(data, auth []byte, scryptN, scryptP int) (CryptoJSON, error)
Encryptdata encrypts the data given as 'data' with the password 'auth'.
type Key ¶
type Key struct { Id uuid.UUID // Version 4 "random" for unique id not derived from key data Path string `json:"path"` Addr string // we only store privkey as pubkey/address can be derived from it // privkey in this struct is always in plaintext PrivateKey []byte }
func DecryptKey ¶
DecryptKey decrypts a key from a json blob, returning the private key itself.
func (*Key) MarshalJSON ¶
func (*Key) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.