Copyright | Alexander Krupenkin 2018 |
---|---|
License | BSD3 |
Maintainer | mail@akru.me |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Ethereum Secret Storage implementation. Spec https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition.
Synopsis
- data EncryptedKey = EncryptedKey {}
- data Cipher = Aes128Ctr {
- cipherIv :: !(IV AES128)
- cipherText :: !HexString
- data Kdf
- decrypt :: (ByteArrayAccess password, ByteArray privateKey) => EncryptedKey -> password -> Maybe privateKey
- encrypt :: (ByteArray privateKey, ByteArrayAccess password, MonadRandom m) => privateKey -> password -> m EncryptedKey
Encrypted Ethereum private key
data EncryptedKey Source #
Secret Storage representation on memory.
EncryptedKey | |
|
Instances
Eq EncryptedKey Source # | |
Defined in Crypto.Ethereum.Keyfile (==) :: EncryptedKey -> EncryptedKey -> Bool # (/=) :: EncryptedKey -> EncryptedKey -> Bool # | |
Show EncryptedKey Source # | |
Defined in Crypto.Ethereum.Keyfile showsPrec :: Int -> EncryptedKey -> ShowS # show :: EncryptedKey -> String # showList :: [EncryptedKey] -> ShowS # | |
ToJSON EncryptedKey Source # | |
Defined in Crypto.Ethereum.Keyfile toJSON :: EncryptedKey -> Value # toEncoding :: EncryptedKey -> Encoding # toJSONList :: [EncryptedKey] -> Value # toEncodingList :: [EncryptedKey] -> Encoding # | |
FromJSON EncryptedKey Source # | |
Defined in Crypto.Ethereum.Keyfile parseJSON :: Value -> Parser EncryptedKey # parseJSONList :: Value -> Parser [EncryptedKey] # |
Key derivation function parameters and salt.
Secret storage packers
decrypt :: (ByteArrayAccess password, ByteArray privateKey) => EncryptedKey -> password -> Maybe privateKey Source #
Decrypt Ethereum private key.
Typically Web3 Secret Storage is JSON-encoded. EncryptedKey
data type has FromJSON
instance
to helps decode it from JSON-encoded string or file.
let decryptJSON pass = flip decrypt pass <=< decode
encrypt :: (ByteArray privateKey, ByteArrayAccess password, MonadRandom m) => privateKey -> password -> m EncryptedKey Source #
Encrypt Ethereum private key.
let encryptJSON pass key = encode $ encrypt key pass