mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-11-04 08:37:49 +00:00
database field conversion instance (#1940)
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
1 parent
f7ca2f956c
commit
3b760e8e7b
1 file changed
+5
@@ -34,6 +34,7 @@ import qualified Data.Map.Strict as M
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Encoding (encodeUtf8)
|
||||
import Simplex.Messaging.Agent.Store.DB (Binary (..), FromField (..), ToField (..), blobFieldDecoder)
|
||||
import qualified Simplex.Messaging.Crypto as C
|
||||
import Simplex.Messaging.Crypto.BIP39.English (englishWordList)
|
||||
|
||||
@@ -85,6 +86,10 @@ mkEntropy ent
|
||||
where
|
||||
entLen = BA.length ent
|
||||
|
||||
instance ToField WalletEntropy where toField (WalletEntropy ent) = toField $ Binary (BA.convert ent :: ByteString)
|
||||
|
||||
instance FromField WalletEntropy where fromField = blobFieldDecoder $ mkEntropy . BA.convert
|
||||
|
||||
randomEntropy :: EntropyStrength -> TVar ChaChaDRG -> STM WalletEntropy
|
||||
randomEntropy s = fmap WalletEntropy . C.randomBytes' (strengthBytes s)
|
||||
|
||||
|
||||
Reference in new issue
Block a user