From d13ce585ab7a96b36e3f99cdf6da143a83f0bba6 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Fri, 7 Jul 2017 21:44:29 +0100 Subject: [PATCH] add further unrolling of Div8 to match Mod8 --- Crypto/Internal/Nat.hs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Crypto/Internal/Nat.hs b/Crypto/Internal/Nat.hs index 5b76e6c..39eae6f 100644 --- a/Crypto/Internal/Nat.hs +++ b/Crypto/Internal/Nat.hs @@ -10,6 +10,7 @@ module Crypto.Internal.Nat , byteLen , integralNatVal , type Div8 + , type Mod8 ) where import GHC.TypeLits @@ -84,7 +85,39 @@ type family Div8 (bitLen :: Nat) where Div8 30 = 3 Div8 31 = 3 Div8 32 = 4 - Div8 n = 4 + Div8 (n - 32) + Div8 33 = 4 + Div8 34 = 4 + Div8 35 = 4 + Div8 36 = 4 + Div8 37 = 4 + Div8 38 = 4 + Div8 39 = 4 + Div8 40 = 5 + Div8 41 = 5 + Div8 42 = 5 + Div8 43 = 5 + Div8 44 = 5 + Div8 45 = 5 + Div8 46 = 5 + Div8 47 = 5 + Div8 48 = 6 + Div8 49 = 6 + Div8 50 = 6 + Div8 51 = 6 + Div8 52 = 6 + Div8 53 = 6 + Div8 54 = 6 + Div8 55 = 6 + Div8 56 = 7 + Div8 57 = 7 + Div8 58 = 7 + Div8 59 = 7 + Div8 60 = 7 + Div8 61 = 7 + Div8 62 = 7 + Div8 63 = 7 + Div8 64 = 8 + Div8 n = 8 + Div8 (n - 64) type family IsDiv8 (bitLen :: Nat) (n :: Nat) where IsDiv8 bitLen 0 = 'True