web3-crypto-1.0.0.0: Cryptograhical primitives for Haskell Web3 library.
CopyrightAleksandr Krupenkin 2016-2021
LicenseApache-2.0
Maintainermail@akru.me
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Crypto.Ethereum.Keyfile

Description

Ethereum Secret Storage implementation. Spec https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition.

Synopsis

Encrypted Ethereum private key

data EncryptedKey Source #

Secret Storage representation on memory.

Constructors

EncryptedKey 

Fields

data Cipher Source #

Cipher parameters.

Constructors

Aes128Ctr 

data Kdf Source #

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