move Nat specific to Cryptonite's insternal module
This commit is contained in:
parent
f9b593520f
commit
cd552ae5f6
@ -73,10 +73,7 @@ shakeFinalizeOutput :: (IsDivisibleBy8 bitLen, KnownNat bitLen)
|
||||
-> IO ()
|
||||
shakeFinalizeOutput d ctx dig = do
|
||||
c_sha3_finalize_shake ctx
|
||||
c_sha3_output ctx dig (fromInteger (natVal d `div` 8))
|
||||
|
||||
byteLen :: (KnownNat bitlen, IsDivisibleBy8 bitlen, Num a) => proxy bitlen -> a
|
||||
byteLen d = fromInteger (natVal d `div` 8)
|
||||
c_sha3_output ctx dig (byteLen d)
|
||||
|
||||
foreign import ccall unsafe "cryptonite_sha3_init"
|
||||
c_sha3_init :: Ptr (Context a) -> Word32 -> IO ()
|
||||
|
||||
@ -6,10 +6,18 @@
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
module Crypto.Internal.Nat
|
||||
( type IsDivisibleBy8
|
||||
, byteLen
|
||||
, integralNatVal
|
||||
) where
|
||||
|
||||
import GHC.TypeLits
|
||||
|
||||
byteLen :: (KnownNat bitlen, IsDivisibleBy8 bitlen, Num a) => proxy bitlen -> a
|
||||
byteLen d = fromInteger (natVal d `div` 8)
|
||||
|
||||
integralNatVal :: (KnownNat bitlen, Num a) => proxy bitlen -> a
|
||||
integralNatVal = fromInteger . natVal
|
||||
|
||||
type family IsDiv8 (bitLen :: Nat) (n :: Nat) where
|
||||
IsDiv8 bitLen 0 = 'True
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user