diff --git a/cabal.project b/cabal.project index 96c8cfdcd71..f4e3680cee9 100644 --- a/cabal.project +++ b/cabal.project @@ -62,7 +62,7 @@ packages: lib/balance-tx/ lib/benchmarks/ lib/cardano-api-extra/ - lib/crypto-hash-extra/ + lib/crypto-primitives/ lib/coin-selection/ lib/customer-deposit-wallet/ lib/delta-store/ diff --git a/hie.yaml b/hie.yaml index 032b09d852f..53d323bd313 100644 --- a/hie.yaml +++ b/hie.yaml @@ -48,8 +48,8 @@ cradle: - path: "lib/coin-selection/bench" component: "cardano-coin-selection:bench:utxo-index" - - path: "lib/crypto-hash-extra/src" - component: "lib:crypto-hash-extra" + - path: "lib/crypto-primitives/src" + component: "lib:crypto-primitives" - path: "lib/customer-deposit-wallet/src" component: "lib:customer-deposit-wallet" diff --git a/lib/address-derivation-discovery/address-derivation-discovery.cabal b/lib/address-derivation-discovery/address-derivation-discovery.cabal index 8c91f94ca48..a42d0165dff 100644 --- a/lib/address-derivation-discovery/address-derivation-discovery.cabal +++ b/lib/address-derivation-discovery/address-derivation-discovery.cabal @@ -58,8 +58,7 @@ library , cardano-wallet-secrets , cborg , containers - , crypto-hash-extra - , cryptonite + , crypto-primitives , data-interval , deepseq , digest diff --git a/lib/address-derivation-discovery/lib/Cardano/Byron/Codec/Cbor.hs b/lib/address-derivation-discovery/lib/Cardano/Byron/Codec/Cbor.hs index 0377f14fd29..0cd65c4a79c 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Byron/Codec/Cbor.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Byron/Codec/Cbor.hs @@ -77,16 +77,16 @@ import Control.Monad ( replicateM , when ) -import Crypto.Error +import Cryptography.Core ( CryptoError (..) , CryptoFailable (..) ) -import Crypto.Hash - ( hash - ) -import Crypto.Hash.Algorithms +import Cryptography.Hash.Blake ( Blake2b_224 - , SHA3_256 + ) +import Cryptography.Hash.Core + ( SHA3_256 + , hash ) import Data.ByteString ( ByteString @@ -107,7 +107,7 @@ import qualified Codec.CBOR.Decoding as CBOR import qualified Codec.CBOR.Encoding as CBOR import qualified Codec.CBOR.Read as CBOR import qualified Codec.CBOR.Write as CBOR -import qualified Crypto.Cipher.ChaChaPoly1305 as Poly +import qualified Cryptography.Cipher.ChaChaPoly1305 as Poly import qualified Data.ByteArray as BA import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL diff --git a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Byron.hs b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Byron.hs index 7cfc13ccce4..799bf3f4773 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Byron.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Byron.hs @@ -88,12 +88,12 @@ import Control.Lens ( Lens , lens ) -import Crypto.Hash.Algorithms - ( SHA512 (..) - ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) +import Cryptography.Hash.Core + ( SHA512 (..) + ) import Data.ByteArray ( ScrubbedBytes ) @@ -114,7 +114,7 @@ import qualified Cardano.Byron.Codec.Cbor as CBOR import qualified Cardano.Wallet.Address.Derivation as W import qualified Codec.CBOR.Encoding as CBOR import qualified Codec.CBOR.Write as CBOR -import qualified Crypto.KDF.PBKDF2 as PBKDF2 +import qualified Cryptography.KDF.PBKDF2 as PBKDF2 import qualified Data.ByteArray as BA {------------------------------------------------------------------------------- diff --git a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Icarus.hs b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Icarus.hs index f2b0e68deef..db1c4f13877 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Icarus.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Icarus.hs @@ -103,15 +103,13 @@ import Control.Lens import Control.Monad ( (<=<) ) -import Crypto.Error +import Cryptography.Core ( eitherCryptoError ) -import Crypto.Hash.Algorithms - ( SHA256 (..) - , SHA512 (..) - ) -import Crypto.MAC.HMAC +import Cryptography.Hash.Core ( HMAC + , SHA256 (..) + , SHA512 (..) , hmac ) import Data.Bifunctor @@ -144,8 +142,8 @@ import GHC.Generics import qualified Cardano.Byron.Codec.Cbor as CBOR import qualified Cardano.Crypto.Wallet as CC import qualified Codec.CBOR.Write as CBOR -import qualified Crypto.ECC.Edwards25519 as Ed25519 -import qualified Crypto.KDF.PBKDF2 as PBKDF2 +import qualified Cryptography.ECC.Edwards25519 as Ed25519 +import qualified Cryptography.KDF.PBKDF2 as PBKDF2 import qualified Data.ByteArray as BA import qualified Data.ByteString as BS import qualified Data.Text as T diff --git a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shared.hs b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shared.hs index eb399a50017..69b3c773135 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shared.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shared.hs @@ -84,14 +84,9 @@ import Cardano.Wallet.Primitive.Types.Address import Control.Monad ( (<=<) ) -import Crypto.Hash.Algorithms - ( Blake2b_224 (..) - ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 - ) -import Crypto.Hash.IO - ( HashAlgorithm (hashDigestSize) + , hashSizeBlake2b224 ) import Data.ByteString ( ByteString @@ -168,7 +163,7 @@ instance MkKeyFingerprint SharedKey Address where enterpriseAddr = 0b01110000 -- scripthash rewardAcct = 0b11110000 -- scripthash in if addrType `elem` [baseAddr, enterpriseAddr, rewardAcct] then - Right $ KeyFingerprint $ BS.take hashSize rest + Right $ KeyFingerprint $ BS.take hashSizeBlake2b224 rest else Left $ ErrInvalidAddress addr (Proxy @SharedKey) @@ -181,10 +176,3 @@ instance where paymentKeyFingerprint (_, paymentK) = Right $ KeyFingerprint $ blake2b224 $ xpubPublicKey $ getKey paymentK - -{------------------------------------------------------------------------------- - Internals --------------------------------------------------------------------------------} - -hashSize :: Int -hashSize = hashDigestSize Blake2b_224 diff --git a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shelley.hs b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shelley.hs index 6df1270fa78..ca5998fce88 100644 --- a/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shelley.hs +++ b/lib/address-derivation-discovery/lib/Cardano/Wallet/Address/Derivation/Shelley.hs @@ -117,14 +117,9 @@ import Control.Monad ( guard , (<=<) ) -import Crypto.Hash.Algorithms - ( Blake2b_224 (..) - ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 - ) -import Crypto.Hash.IO - ( HashAlgorithm (hashDigestSize) + , hashSizeBlake2b224 ) import Data.Binary.Put ( putByteString @@ -359,7 +354,7 @@ instance MkKeyFingerprint ShelleyKey Address where enterpriseAddr = 0b01100000 -- keyhash rewardAcct = 0b11100000 -- keyhash in if addrType `elem` [baseAddr, enterpriseAddr, rewardAcct] then - Right $ KeyFingerprint $ BS.take hashSize rest + Right $ KeyFingerprint $ BS.take hashSizeBlake2b224 rest else Left $ ErrInvalidAddress addr (Proxy @ShelleyKey) @@ -436,11 +431,3 @@ instance PersistPublicKey (ShelleyKey depth) where either err ShelleyKey . (xpub <=< fromHex @ByteString) where err _ = error "unsafeDeserializeXPub: unable to deserialize ShelleyKey" - -{------------------------------------------------------------------------------- - Internals --------------------------------------------------------------------------------} - -hashSize :: Int -hashSize = - hashDigestSize Blake2b_224 diff --git a/lib/benchmarks/cardano-wallet-benchmarks.cabal b/lib/benchmarks/cardano-wallet-benchmarks.cabal index 2f07a73b091..815ea33436c 100644 --- a/lib/benchmarks/cardano-wallet-benchmarks.cabal +++ b/lib/benchmarks/cardano-wallet-benchmarks.cabal @@ -99,7 +99,7 @@ benchmark restore , cardano-wallet:{cardano-wallet, cardano-wallet-api-http} , containers , contra-tracer - , crypto-hash-extra + , crypto-primitives , filepath , fmt , iohk-monitoring @@ -173,7 +173,7 @@ benchmark db , containers , contra-tracer , criterion - , cryptonite + , crypto-primitives , deepseq , directory , filepath diff --git a/lib/benchmarks/exe/db-bench.hs b/lib/benchmarks/exe/db-bench.hs index 4edc2141ade..e192aa92e62 100644 --- a/lib/benchmarks/exe/db-bench.hs +++ b/lib/benchmarks/exe/db-bench.hs @@ -240,7 +240,7 @@ import Criterion.Main , defaultMain , perRunEnvWithCleanup ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.ByteString diff --git a/lib/benchmarks/exe/restore-bench.hs b/lib/benchmarks/exe/restore-bench.hs index 12513e8613e..e41ea95020f 100644 --- a/lib/benchmarks/exe/restore-bench.hs +++ b/lib/benchmarks/exe/restore-bench.hs @@ -254,7 +254,7 @@ import Control.Tracer ( Tracer (..) , traceWith ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.Aeson diff --git a/lib/crypto-hash-extra/crypto-hash-extra.cabal b/lib/crypto-primitives/crypto-primitives.cabal similarity index 69% rename from lib/crypto-hash-extra/crypto-hash-extra.cabal rename to lib/crypto-primitives/crypto-primitives.cabal index ae7eb23db74..ab7b12a2510 100644 --- a/lib/crypto-hash-extra/crypto-hash-extra.cabal +++ b/lib/crypto-primitives/crypto-primitives.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 -name: crypto-hash-extra +name: crypto-primitives version: 0.1.0.0 -synopsis: Extra functionality for cryptographic hashing +synopsis: Cryptographic primitives license: Apache-2.0 author: Cardano Foundation (High Assurance Lab) maintainer: hal@cardanofoundation.org @@ -24,7 +24,13 @@ library -freverse-errors hs-source-dirs: src - exposed-modules: Crypto.Hash.Extra + exposed-modules: Cryptography.Cipher.ChaChaPoly1305 + Cryptography.Core + Cryptography.ECC.Edwards25519 + Cryptography.Hash.Blake + Cryptography.Hash.Core + Cryptography.KDF.PBKDF2 + Cryptography.KDF.Scrypt build-depends: , base >= 4.14.3 && < 4.19 , bytestring >= 0.10.12 && < 0.13 diff --git a/lib/crypto-primitives/src/Cryptography/Cipher/ChaChaPoly1305.hs b/lib/crypto-primitives/src/Cryptography/Cipher/ChaChaPoly1305.hs new file mode 100644 index 00000000000..e4aacf06052 --- /dev/null +++ b/lib/crypto-primitives/src/Cryptography/Cipher/ChaChaPoly1305.hs @@ -0,0 +1,17 @@ +module Cryptography.Cipher.ChaChaPoly1305 + ( decrypt + , encrypt + , initialize + , finalize + , finalizeAAD + , nonce12 + ) where + +import Crypto.Cipher.ChaChaPoly1305 + ( decrypt + , encrypt + , finalize + , finalizeAAD + , initialize + , nonce12 + ) diff --git a/lib/crypto-primitives/src/Cryptography/Core.hs b/lib/crypto-primitives/src/Cryptography/Core.hs new file mode 100644 index 00000000000..02f546daef3 --- /dev/null +++ b/lib/crypto-primitives/src/Cryptography/Core.hs @@ -0,0 +1,16 @@ +module Cryptography.Core + ( CryptoError (..) + , CryptoFailable (..) + , eitherCryptoError + + , MonadRandom (..) + ) where + +import Crypto.Error + ( CryptoError (..) + , CryptoFailable (..) + , eitherCryptoError + ) +import Crypto.Random.Types + ( MonadRandom (..) + ) diff --git a/lib/crypto-primitives/src/Cryptography/ECC/Edwards25519.hs b/lib/crypto-primitives/src/Cryptography/ECC/Edwards25519.hs new file mode 100644 index 00000000000..4deb764ef70 --- /dev/null +++ b/lib/crypto-primitives/src/Cryptography/ECC/Edwards25519.hs @@ -0,0 +1,11 @@ +module Cryptography.ECC.Edwards25519 + ( pointEncode + , scalarDecodeLong + , toPoint + ) where + +import Crypto.ECC.Edwards25519 + ( pointEncode + , scalarDecodeLong + , toPoint + ) diff --git a/lib/crypto-hash-extra/src/Crypto/Hash/Extra.hs b/lib/crypto-primitives/src/Cryptography/Hash/Blake.hs similarity index 64% rename from lib/crypto-hash-extra/src/Crypto/Hash/Extra.hs rename to lib/crypto-primitives/src/Cryptography/Hash/Blake.hs index 64c745c421e..a428a0176d6 100644 --- a/lib/crypto-hash-extra/src/Crypto/Hash/Extra.hs +++ b/lib/crypto-primitives/src/Cryptography/Hash/Blake.hs @@ -1,8 +1,14 @@ +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeApplications #-} -module Crypto.Hash.Extra - ( blake2b256 +module Cryptography.Hash.Blake + ( Blake2b_160 + , Blake2b_224 + , Blake2b_256 + + , blake2b256 , blake2b224 + , hashSizeBlake2b224 ) where import Prelude @@ -11,8 +17,12 @@ import Crypto.Hash ( hash ) import Crypto.Hash.Algorithms - ( Blake2b_224 - , Blake2b_256 + ( Blake2b_160 (..) + , Blake2b_224 (..) + , Blake2b_256 (..) + ) +import Crypto.Hash.IO + ( HashAlgorithm (hashDigestSize) ) import Data.ByteArray ( ByteArrayAccess @@ -30,3 +40,6 @@ blake2b256 = BA.convert . hash @_ @Blake2b_256 -- | Hash a byte string using Blake2b with a 224-bit (28-byte) digest. blake2b224 :: ByteArrayAccess a => a -> ByteString blake2b224 = BA.convert . hash @_ @Blake2b_224 + +hashSizeBlake2b224 :: Int +hashSizeBlake2b224 = hashDigestSize Blake2b_224 diff --git a/lib/crypto-primitives/src/Cryptography/Hash/Core.hs b/lib/crypto-primitives/src/Cryptography/Hash/Core.hs new file mode 100644 index 00000000000..fad1c97d362 --- /dev/null +++ b/lib/crypto-primitives/src/Cryptography/Hash/Core.hs @@ -0,0 +1,38 @@ +module Cryptography.Hash.Core + ( HashAlgorithm + , MD4 (..) + , MD5 (..) + , SHA1 (..) + , SHA224 (..) + , SHA256 (..) + , SHA512 (..) + , SHA3_256 (..) + , hash + + , HMAC + , hmac + + , Digest + , digestFromByteString + + ) where + +import Crypto.Hash + ( Digest + , digestFromByteString + , hash + ) +import Crypto.Hash.Algorithms + ( HashAlgorithm + , MD4 (..) + , MD5 (..) + , SHA1 (..) + , SHA224 (..) + , SHA256 (..) + , SHA3_256 (..) + , SHA512 (..) + ) +import Crypto.MAC.HMAC + ( HMAC + , hmac + ) diff --git a/lib/crypto-primitives/src/Cryptography/KDF/PBKDF2.hs b/lib/crypto-primitives/src/Cryptography/KDF/PBKDF2.hs new file mode 100644 index 00000000000..49b39ff10ea --- /dev/null +++ b/lib/crypto-primitives/src/Cryptography/KDF/PBKDF2.hs @@ -0,0 +1,13 @@ +module Cryptography.KDF.PBKDF2 + ( Parameters (..) + , fastPBKDF2_SHA512 + , generate + , prfHMAC + ) where + +import Crypto.KDF.PBKDF2 + ( Parameters (..) + , fastPBKDF2_SHA512 + , generate + , prfHMAC + ) diff --git a/lib/crypto-primitives/src/Cryptography/KDF/Scrypt.hs b/lib/crypto-primitives/src/Cryptography/KDF/Scrypt.hs new file mode 100644 index 00000000000..a4fee9ecbc6 --- /dev/null +++ b/lib/crypto-primitives/src/Cryptography/KDF/Scrypt.hs @@ -0,0 +1,9 @@ +module Cryptography.KDF.Scrypt + ( Parameters (..) + , generate + ) where + +import Crypto.KDF.Scrypt + ( Parameters (..) + , generate + ) diff --git a/lib/integration/cardano-wallet-integration.cabal b/lib/integration/cardano-wallet-integration.cabal index d43bb588e7e..977120b1e47 100644 --- a/lib/integration/cardano-wallet-integration.cabal +++ b/lib/integration/cardano-wallet-integration.cabal @@ -62,8 +62,7 @@ library framework , command , containers , contra-tracer - , crypto-hash-extra - , cryptonite + , crypto-primitives , directory , either , extra diff --git a/lib/integration/framework/Test/Integration/Framework/DSL.hs b/lib/integration/framework/Test/Integration/Framework/DSL.hs index 79361bdb831..dec4d3ef7f3 100644 --- a/lib/integration/framework/Test/Integration/Framework/DSL.hs +++ b/lib/integration/framework/Test/Integration/Framework/DSL.hs @@ -462,13 +462,13 @@ import Control.Retry , constantDelay , retrying ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_160 - , Digest - , digestFromByteString + , blake2b224 ) -import Crypto.Hash.Extra - ( blake2b224 +import Cryptography.Hash.Core + ( Digest + , digestFromByteString ) import Data.Aeson ( FromJSON diff --git a/lib/integration/framework/Test/Integration/Plutus.hs b/lib/integration/framework/Test/Integration/Plutus.hs index 35aa3a36585..9369c797780 100644 --- a/lib/integration/framework/Test/Integration/Plutus.hs +++ b/lib/integration/framework/Test/Integration/Plutus.hs @@ -60,7 +60,7 @@ import Codec.Serialise import Control.Arrow ( left ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 ) import Data.Aeson diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs index 88412bcf067..6d07fdc439d 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/ConfiguredPool.hs @@ -116,7 +116,7 @@ import Control.Monad.Reader import Control.Tracer ( traceWith ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.Foldable diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs index 9bd16f99951..5c066ad11ab 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Faucet.hs @@ -77,7 +77,7 @@ import Control.Monad.Reader , MonadReader (..) , asks ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.Aeson diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/PoolMetadataServer.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/PoolMetadataServer.hs index 5d6465f5f04..b6cdc0343fe 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/PoolMetadataServer.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/PoolMetadataServer.hs @@ -28,7 +28,7 @@ import Cardano.Wallet.Launch.Cluster.Logging import Control.Monad.Reader ( MonadIO (..) ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.ByteArray.Encoding diff --git a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/SMASH.hs b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/SMASH.hs index d1cd5da6d6e..690a02661da 100644 --- a/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/SMASH.hs +++ b/lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/SMASH.hs @@ -23,7 +23,7 @@ import Control.Tracer ( Tracer (..) , traceWith ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.Aeson diff --git a/lib/local-cluster/local-cluster.cabal b/lib/local-cluster/local-cluster.cabal index 616a5d2d2ba..2dedf1a8529 100644 --- a/lib/local-cluster/local-cluster.cabal +++ b/lib/local-cluster/local-cluster.cabal @@ -91,7 +91,7 @@ library , cborg , containers , contra-tracer - , crypto-hash-extra + , crypto-primitives , directory , extra , faucet diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index c2ec5bc7910..c445e2620c4 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -73,8 +73,7 @@ library , commutative-semigroups , containers , contra-tracer - , crypto-hash-extra - , cryptonite + , crypto-primitives , deepseq , delta-types , errors diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Byron.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Byron.hs index ae1d0970065..2bd76c763ac 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Byron.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Byron.hs @@ -71,7 +71,7 @@ import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs import Cardano.Wallet.Unsafe ( unsafeFromHex ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.Coerce diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Hash.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Hash.hs index e7f1d6b906f..4e1f2c1046f 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Hash.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Hash.hs @@ -30,10 +30,12 @@ import Cardano.Wallet.Util import Control.DeepSeq ( NFData (..) ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_224 , Blake2b_256 - , hash + ) +import Cryptography.Hash.Core + ( hash ) import Data.ByteArray ( ByteArrayAccess diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenFingerprint.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenFingerprint.hs index 18ba01da3ec..ce74bc7d17c 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenFingerprint.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenFingerprint.hs @@ -29,12 +29,12 @@ import Codec.Binary.Bech32.TH import Control.DeepSeq ( NFData ) -import Crypto.Hash - ( hash - ) -import Crypto.Hash.Algorithms +import Cryptography.Hash.Blake ( Blake2b_160 ) +import Cryptography.Hash.Core + ( hash + ) import Data.ByteArray ( convert ) diff --git a/lib/secrets/cardano-wallet-secrets.cabal b/lib/secrets/cardano-wallet-secrets.cabal index 7db57978f4a..afe0d9ec317 100644 --- a/lib/secrets/cardano-wallet-secrets.cabal +++ b/lib/secrets/cardano-wallet-secrets.cabal @@ -42,8 +42,7 @@ library , bytestring >= 0.10.12 && < 0.13 , cardano-crypto , cborg - , cryptonite ^>=0.30 - , crypto-hash-extra + , crypto-primitives , deepseq , generic-arbitrary , memory ^>=0.18 diff --git a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase.hs b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase.hs index 2276b426df6..1ec52cbd8c7 100644 --- a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase.hs +++ b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase.hs @@ -38,7 +38,7 @@ import Cardano.Crypto.Wallet , xPrvChangePass ) import Cardano.Wallet.Primitive.Passphrase.Types -import Crypto.Random.Types +import Cryptography.Core ( MonadRandom ) diff --git a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Current.hs b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Current.hs index 634a6a1ec95..cbc6da31070 100644 --- a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Current.hs +++ b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Current.hs @@ -25,13 +25,13 @@ import Cardano.Wallet.Primitive.Passphrase.Types import Control.Monad ( unless ) -import Crypto.KDF.PBKDF2 +import Cryptography.Core + ( MonadRandom (..) + ) +import Cryptography.KDF.PBKDF2 ( Parameters (..) , fastPBKDF2_SHA512 ) -import Crypto.Random.Types - ( MonadRandom (..) - ) import Data.ByteArray ( ScrubbedBytes ) diff --git a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Legacy.hs b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Legacy.hs index cc1a6202d34..7f6eef4b32b 100644 --- a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Legacy.hs +++ b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Legacy.hs @@ -34,12 +34,12 @@ import Cardano.Wallet.Primitive.Passphrase.Types ( Passphrase (..) , PassphraseHash (..) ) -import Crypto.Hash.Extra - ( blake2b256 - ) -import Crypto.Random.Types +import Cryptography.Core ( MonadRandom (..) ) +import Cryptography.Hash.Blake + ( blake2b256 + ) import Data.ByteArray.Encoding ( Base (..) , convertFromBase @@ -54,7 +54,7 @@ import Data.Word import qualified Codec.CBOR.Encoding as CBOR import qualified Codec.CBOR.Write as CBOR -import qualified Crypto.KDF.Scrypt as Scrypt +import qualified Cryptography.KDF.Scrypt as Scrypt import qualified Data.ByteArray as BA import qualified Data.ByteString.Char8 as B8 diff --git a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Types.hs b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Types.hs index 944bd8274fa..cffc3c656ae 100644 --- a/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Types.hs +++ b/lib/secrets/src/Cardano/Wallet/Primitive/Passphrase/Types.hs @@ -33,7 +33,7 @@ import Prelude import Control.DeepSeq ( NFData ) -import Crypto.Random.Types +import Cryptography.Core ( MonadRandom (..) ) import Data.Bifunctor diff --git a/lib/unit/cardano-wallet-unit.cabal b/lib/unit/cardano-wallet-unit.cabal index fcb7851dff6..1ea4988ef0d 100644 --- a/lib/unit/cardano-wallet-unit.cabal +++ b/lib/unit/cardano-wallet-unit.cabal @@ -97,8 +97,7 @@ test-suite unit , connection , containers , contra-tracer - , crypto-hash-extra - , cryptonite + , crypto-primitives , data-default , data-interval , deepseq diff --git a/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs index 16bfdcb7563..e5bacda094b 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Api/TypesSpec.hs @@ -470,7 +470,7 @@ import Control.Monad import Control.Monad.IO.Class ( liftIO ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.Aeson diff --git a/lib/unit/test/unit/Cardano/Wallet/DB/Arbitrary.hs b/lib/unit/test/unit/Cardano/Wallet/DB/Arbitrary.hs index c11fc7597b8..295a7d14b37 100644 --- a/lib/unit/test/unit/Cardano/Wallet/DB/Arbitrary.hs +++ b/lib/unit/test/unit/Cardano/Wallet/DB/Arbitrary.hs @@ -233,7 +233,7 @@ import Cardano.Wallet.Util import Control.DeepSeq ( NFData ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.ByteArray.Encoding diff --git a/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs b/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs index 7db4e67430a..8011afa1086 100644 --- a/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/DB/LayerSpec.hs @@ -245,7 +245,7 @@ import Control.Monad.IO.Class import Control.Tracer ( Tracer ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.ByteString diff --git a/lib/unit/test/unit/Cardano/Wallet/DB/Properties.hs b/lib/unit/test/unit/Cardano/Wallet/DB/Properties.hs index 595a4a80339..5cd0653ddb8 100644 --- a/lib/unit/test/unit/Cardano/Wallet/DB/Properties.hs +++ b/lib/unit/test/unit/Cardano/Wallet/DB/Properties.hs @@ -76,7 +76,7 @@ import Control.Monad.Trans import Control.Monad.Trans.Except ( ExceptT ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.ByteString diff --git a/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs b/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs index b706a400b5c..8eeafe73bfd 100644 --- a/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs +++ b/lib/unit/test/unit/Cardano/Wallet/DB/StateMachine.hs @@ -230,9 +230,11 @@ import Control.Monad import Control.Monad.IO.Unlift ( MonadIO ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_160 - , Digest + ) +import Cryptography.Hash.Core + ( Digest , digestFromByteString , hash ) diff --git a/lib/unit/test/unit/Cardano/Wallet/Primitive/Delegation/StateSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Primitive/Delegation/StateSpec.hs index 02ce2b8a384..d0fc21e98f3 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Primitive/Delegation/StateSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Primitive/Delegation/StateSpec.hs @@ -66,7 +66,7 @@ import Cardano.Wallet.Primitive.Types.Tx.TxOut import Control.Arrow ( first ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 ) import Data.Map diff --git a/lib/unit/test/unit/Cardano/Wallet/Primitive/TypesSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Primitive/TypesSpec.hs index 1a661c47b11..d3b0d09ef41 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Primitive/TypesSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Primitive/TypesSpec.hs @@ -153,7 +153,7 @@ import Control.Monad ( forM_ , replicateM ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.Either diff --git a/lib/unit/test/unit/Cardano/Wallet/RegistrySpec.hs b/lib/unit/test/unit/Cardano/Wallet/RegistrySpec.hs index 9d2865d865f..7e7dc2cf96c 100644 --- a/lib/unit/test/unit/Cardano/Wallet/RegistrySpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/RegistrySpec.hs @@ -38,7 +38,7 @@ import Control.Monad import Control.Tracer ( Tracer ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.Text diff --git a/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index 4075d4db548..d6042405b29 100644 --- a/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/unit/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -209,7 +209,7 @@ import Control.Monad.Trans.Except ( except , runExceptT ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 ) import Data.ByteString diff --git a/lib/unit/test/unit/Cardano/WalletSpec.hs b/lib/unit/test/unit/Cardano/WalletSpec.hs index f836a920283..5eaaa8ee545 100644 --- a/lib/unit/test/unit/Cardano/WalletSpec.hs +++ b/lib/unit/test/unit/Cardano/WalletSpec.hs @@ -261,7 +261,7 @@ import Control.Tracer ( natTracer , nullTracer ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.ByteString diff --git a/lib/wallet/api/http/Cardano/Wallet/Api/Types/Key.hs b/lib/wallet/api/http/Cardano/Wallet/Api/Types/Key.hs index 73150a2d493..8039bea6a57 100644 --- a/lib/wallet/api/http/Cardano/Wallet/Api/Types/Key.hs +++ b/lib/wallet/api/http/Cardano/Wallet/Api/Types/Key.hs @@ -59,7 +59,7 @@ import Codec.Binary.Bech32.TH import Control.DeepSeq ( NFData ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 ) import Data.Aeson.Types diff --git a/lib/wallet/cardano-wallet.cabal b/lib/wallet/cardano-wallet.cabal index b61029e9ae0..f93ca80b7d2 100644 --- a/lib/wallet/cardano-wallet.cabal +++ b/lib/wallet/cardano-wallet.cabal @@ -69,8 +69,7 @@ library , cborg , containers , contra-tracer - , crypto-hash-extra - , cryptonite + , crypto-primitives , deepseq , delta-store , delta-types @@ -298,7 +297,7 @@ library cardano-wallet-api-http , cardano-wallet-secrets , containers , contra-tracer - , crypto-hash-extra + , crypto-primitives , data-default , deepseq , directory @@ -437,4 +436,3 @@ executable mock-token-metadata-server , cardano-wallet:{cardano-wallet, mock-token-metadata} , optparse-applicative , wai-extra - diff --git a/lib/wallet/src/Cardano/Pool/Metadata.hs b/lib/wallet/src/Cardano/Pool/Metadata.hs index dc1d8153a8e..46e07823139 100644 --- a/lib/wallet/src/Cardano/Pool/Metadata.hs +++ b/lib/wallet/src/Cardano/Pool/Metadata.hs @@ -83,7 +83,7 @@ import Control.Tracer ( Tracer , traceWith ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b256 ) import Data.Aeson diff --git a/lib/wallet/src/Cardano/Wallet.hs b/lib/wallet/src/Cardano/Wallet.hs index d097b16bcfd..f6302eb8c6a 100644 --- a/lib/wallet/src/Cardano/Wallet.hs +++ b/lib/wallet/src/Cardano/Wallet.hs @@ -664,9 +664,11 @@ import Control.Tracer , contramap , traceWith ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_256 - , hash + ) +import Cryptography.Hash.Core + ( hash ) import Data.Bifunctor ( first diff --git a/lib/wallet/src/Cardano/Wallet/Address/Keys/Shared.hs b/lib/wallet/src/Cardano/Wallet/Address/Keys/Shared.hs index bb265b2076f..c681fa9fe2e 100644 --- a/lib/wallet/src/Cardano/Wallet/Address/Keys/Shared.hs +++ b/lib/wallet/src/Cardano/Wallet/Address/Keys/Shared.hs @@ -88,9 +88,11 @@ import Cardano.Wallet.Primitive.Types.RewardAccount import Control.Monad ( unless ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_160 - , Digest + ) +import Cryptography.Hash.Core + ( Digest , hash ) import Data.Either diff --git a/lib/wallet/src/Cardano/Wallet/Address/Keys/WalletKey.hs b/lib/wallet/src/Cardano/Wallet/Address/Keys/WalletKey.hs index b7152c70283..faa9573de04 100644 --- a/lib/wallet/src/Cardano/Wallet/Address/Keys/WalletKey.hs +++ b/lib/wallet/src/Cardano/Wallet/Address/Keys/WalletKey.hs @@ -71,14 +71,14 @@ import Control.Lens , view , (^.) ) -import Crypto.Hash +import Cryptography.Hash.Blake + ( blake2b224 + ) +import Cryptography.Hash.Core ( Digest , HashAlgorithm , hash ) -import Crypto.Hash.Extra - ( blake2b224 - ) -- | Re-encrypt a private key using a different passphrase. -- diff --git a/lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Migrations/V2/Schema.hs b/lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Migrations/V2/Schema.hs index 1dc6b8f581a..8c82fd02697 100644 --- a/lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Migrations/V2/Schema.hs +++ b/lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Migrations/V2/Schema.hs @@ -38,9 +38,11 @@ import Cardano.Slotting.Slot import Cardano.Wallet.DB.Sqlite.Types ( sqlSettings' ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_160 - , Digest + ) +import Cryptography.Hash.Core + ( Digest , digestFromByteString ) import Data.Aeson diff --git a/lib/wallet/src/Cardano/Wallet/Gen.hs b/lib/wallet/src/Cardano/Wallet/Gen.hs index 5c9243cf9a9..997d2aedc2c 100644 --- a/lib/wallet/src/Cardano/Wallet/Gen.hs +++ b/lib/wallet/src/Cardano/Wallet/Gen.hs @@ -70,7 +70,7 @@ import Cardano.Wallet.Unsafe import Control.Monad ( replicateM ) -import Crypto.Hash +import Cryptography.Hash.Core ( hash ) import Data.Maybe diff --git a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs index f6c71843f4b..f77af0999ef 100644 --- a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs +++ b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs @@ -240,9 +240,11 @@ import Control.DeepSeq import Control.Monad ( (>=>) ) -import Crypto.Hash +import Cryptography.Hash.Blake ( Blake2b_160 - , Digest + ) +import Cryptography.Hash.Core + ( Digest , digestFromByteString ) import Data.Aeson diff --git a/lib/wallet/src/Cardano/Wallet/Transaction/Delegation.hs b/lib/wallet/src/Cardano/Wallet/Transaction/Delegation.hs index 58e504451ee..cacff74f486 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction/Delegation.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction/Delegation.hs @@ -40,7 +40,7 @@ import Cardano.Wallet.Primitive.Types.Pool import Cardano.Wallet.Transaction ( DelegationAction (..) ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 ) import Data.ByteString.Short diff --git a/lib/wallet/src/Cardano/Wallet/Transaction/Voting.hs b/lib/wallet/src/Cardano/Wallet/Transaction/Voting.hs index ff3d5d2d119..00874f9613d 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction/Voting.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction/Voting.hs @@ -37,7 +37,7 @@ import Cardano.Wallet.Primitive.Types.Coin import Cardano.Wallet.Transaction ( VotingAction (..) ) -import Crypto.Hash.Extra +import Cryptography.Hash.Blake ( blake2b224 ) import Data.ByteString.Short diff --git a/lib/wallet/src/Data/Vector/Shuffle.hs b/lib/wallet/src/Data/Vector/Shuffle.hs index 621ac2b294b..25993f30fee 100644 --- a/lib/wallet/src/Data/Vector/Shuffle.hs +++ b/lib/wallet/src/Data/Vector/Shuffle.hs @@ -22,11 +22,9 @@ import Control.Monad.Trans.State.Strict ( evalStateT , state ) -import Crypto.Hash - ( hash - ) -import Crypto.Hash.Algorithms +import Cryptography.Hash.Core ( MD5 + , hash ) import Data.Text ( Text