Comments (19)
class Implementation i where
ImplementationName :: i -> String
data Reference
instance Implementation Reference where
implementationName _ = "Reference"
data family DefaultImplementation prim
hash
, hashByteString
, hashLazyByteString
, hashFile
defined for DefaultImplementation. A version of above functions as hash'
, hashByteString'
etc for any implementation i
.
from raaz.
On Thu, Apr 11, 2013 at 07:57:28PM -0700, satvikc wrote:
data Reference instance Implementation Reference where implementationName _ = "Reference"
data family DefaultImplementation prim
Should this be type family instead of data family ?
Imagin the following situation: Say sha1 and sha256 has only reference
implementations then we would want
type instance DefaultImplementation SHA1 = Reference
type instance DefaultImplementation SHA256 = Reference
If we use data family we might have something like
data instance DefaultImplementation SHA1 = SHA1Implementation Reference
data instance DefaultImplementation SHA256 = SHA256Implementation Reference
This issue here is of
- Good error messages on compiling
- Flexibility.
We probably need to try both out and figure out.
from raaz.
Can you try finishing this work ?
from raaz.
I have added the Implementation class in Raaz.Primitives and divided the corresponding functions of hash in Raaz.Hash but I am not sure about the Mac code to make it work with any implementation because I can not add something like Implementation i => Mac (HMac h)
. If you see the code here I have explicitly forced the mac functions to work for DefaultImplementation h. If this is ok then I can go on changing the code for raaz-hash.
from raaz.
On Fri, May 24, 2013 at 05:44:19PM -0700, satvikc wrote:
The current code seems not correct to me.
class HasBlockSize p where
blockSize :: p -> Int
class (Show i, HasBlockSize p) => BlockImplementation i p where
data Cxt i p
process :: Cxt i p
-> Blocks p
-> ....
...
recomendedBlocks :: i -> p -> Blocks p
class ( HasBlockSize p,
, BlockImplementation (DefaultImplementation p) p
) => BlockPrimitive p where
type DefaultImplementation p :: *
---- In hash we have
class ( HasPadding h
, Eq h
, Storable h
, CryptoStore h
, HasBlockSize p
, BlockImplementation i h
) => HashImplemenation i h where
there will be an extra i sitting out
class ( BlockPrimitive h, HashImplementation (DefaultImplementation h) h)
=> Hash h where
Then I guess you can fix the Mac also. Further you will not need to do
all that forall quantifications.
Regards
ppk
from raaz.
The github issue tracker is irritating. It cannot handle email based response. By the way if you can think of better names for the classes involved that would be nice.
from raaz.
See the modified changes. I am still not sure how to get rid of ScopedTypeVariables
. I have also not provided default for toMACSecret
and toMACSecret'
too because I could not think of a proper name for them.
from raaz.
I think you can avoid the associated type families DefaultHashImplementation and DefaultMacImplementation.
You can instead have.
class (BlockPrimitive h, HashImplementation (DefaultBlockImplemenation h) h) => Hash h where
This forces that the DefaultBlockImplementation
of the underlying BlockPrimitive
to be the same as
the default Implementation of the Hash. This should avoid use of all the scoped variables.
I hate classes with no member function but I think in this case it makes sense to have this. The class Hash h
here just acts as an "and" of the constraints BlockPrimitive h
and HashImplementation (DefaultBlockImplementation h) h)
. But since haskell does not provide a way to define such "and" we are forced to include a new class.
Maybe we can immediately and an instance declaration and be done with it.
And similarly for Mac
from raaz.
We can have that, but I am still not sure how to get rid of Scoped type variables. Like in this what should I do??
-- | For default implementation.
hash :: forall h src. ( Hash h, ByteSource src )
=> src
-> IO h
hash = hash' ( undefined :: DefaultBlockImplementation h )
from raaz.
On Sun, May 26, 2013 at 06:14:00PM -0700, satvikc wrote:
We can have that, but I am still not sure how to get rid of Scoped type variables. Like in this what should I do??
-- | For default implementation. hash :: forall h src. ( Hash h, ByteSource src ) => src -> IO h hash = hash' ( undefined :: DefaultBlockImplementation h )
What is the error message for
hash :: ( Hash h, ByteSource src ) => src -> IO h
hash = hash' (undefined :: DefaultBlockImplementation h)
from raaz.
Could not deduce (HashImplementation
(DefaultBlockImplementation h0) h)
arising from a use of hash'
from the context (Hash h, ByteSource src)
bound by the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
at Raaz/Hash.hs:128:1-58
Possible fix:
add (HashImplementation
(DefaultBlockImplementation h0) h) to the context of
the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
or add an instance declaration for
(HashImplementation (DefaultBlockImplementation h0) h)
In the expression:
hash' (undefined :: DefaultBlockImplementation h)
In an equation for `hash':
hash = hash' (undefined :: DefaultBlockImplementation h)
from raaz.
On Mon, May 27, 2013 at 05:32:41AM -0700, satvikc wrote:
Could not deduce (HashImplementation (DefaultBlockImplementation h0) h) arising from a use of hash' from the context (Hash h, ByteSource src) bound by the type signature for hash :: (Hash h, ByteSource src) => src -> IO h at Raaz/Hash.hs:128:1-58 Possible fix: add (HashImplementation (DefaultBlockImplementation h0) h) to the context of the type signature for hash :: (Hash h, ByteSource src) => src -> IO h or add an instance declaration for (HashImplementation (DefaultBlockImplementation h0) h) In the expression: hash' (undefined :: DefaultBlockImplementation h) In an equation for `hash': hash = hash' (undefined :: DefaultBlockImplementation h)
Okey I see. Try the following.
hash src = hash'' underfined src
where hash'' :: ByteSource src => DefaultBlockImplementation h -> src -> IO h
hash'' impl src = hash' impl src
Regards
ppk
from raaz.
Raaz/Hash.hs:130:27:
Could not deduce (HashImplementation
(DefaultBlockImplementation h1) h1)
arising from a use of hash'
from the context (Hash h, ByteSource src)
bound by the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
at Raaz/Hash.hs:(128,1)-(130,40)
or from (ByteSource src1)
bound by the type signature for
hash'' :: ByteSource src1 =>
DefaultBlockImplementation h1 -> src1 -> IO h1
at Raaz/Hash.hs:130:9-40
Possible fix:
add (HashImplementation
(DefaultBlockImplementation h1) h1) to the context of
the type signature for
hash'' :: ByteSource src1 =>
DefaultBlockImplementation h1 -> src1 -> IO h1
or the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
or add an instance declaration for
(HashImplementation (DefaultBlockImplementation h1) h1)
In the expression: hash' impl src
In an equation for hash'': hash'' impl src = hash' impl src
In an equation for `hash':
hash src
= hash'' undefined src
where
hash'' ::
ByteSource src => DefaultBlockImplementation h -> src -> IO
h
hash'' impl src = hash' impl src
On Mon, May 27, 2013 at 8:50 AM, Piyush P Kurur [email protected]:
On Mon, May 27, 2013 at 05:32:41AM -0700, satvikc wrote:
Could not deduce (HashImplementation
(DefaultBlockImplementation h0) h)
arising from a use of hash'
from the context (Hash h, ByteSource src)
bound by the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
at Raaz/Hash.hs:128:1-58
Possible fix:
add (HashImplementation
(DefaultBlockImplementation h0) h) to the context of
the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
or add an instance declaration for
(HashImplementation (DefaultBlockImplementation h0) h)
In the expression:
hash' (undefined :: DefaultBlockImplementation h)
In an equation for `hash':hash = hash' (undefined :: DefaultBlockImplementation h)
Okey I see. Try the following.
hash src = hash'' underfined src
where hash'' :: ByteSource src => DefaultBlockImplementation h -> src ->
IO h
hash'' impl src = hash' impl srcRegards
ppk
—
Reply to this email directly or view it on GitHubhttps://github.com/piyush-kurur/raaz/issues/41#issuecomment-18497169
.
Satvik Chauhan
Fourth Year Under Graduate Student
Deptt. of Computer Science and Engineering
Indian Institute of Technology Kanpur
Kanpur-208016, INDIA
Email: [email protected] , [email protected]
from raaz.
On Mon, May 27, 2013 at 05:52:47AM -0700, satvikc wrote:
Raaz/Hash.hs:130:27:
Could not deduce (HashImplementation
(DefaultBlockImplementation h1) h1)
arising from a use of hash'
from the context (Hash h, ByteSource src)
bound by the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
at Raaz/Hash.hs:(128,1)-(130,40)
or from (ByteSource src1)
bound by the type signature for
hash'' :: ByteSource src1 =>
DefaultBlockImplementation h1 -> src1 -> IO h1
at Raaz/Hash.hs:130:9-40
Possible fix:
add (HashImplementation
(DefaultBlockImplementation h1) h1) to the context of
the type signature for
hash'' :: ByteSource src1 =>
DefaultBlockImplementation h1 -> src1 -> IO h1
or the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
or add an instance declaration for
(HashImplementation (DefaultBlockImplementation h1) h1)
In the expression: hash' impl src
In an equation for hash'': hash'' impl src = hash' impl src
In an equation for `hash':
hash src
= hash'' undefined src
where
hash'' ::
ByteSource src => DefaultBlockImplementation h -> src -> IO
h
hash'' impl src = hash' impl src
Do you have the constraint
HashImplementation (DefaultBlockImplementation h) in the definition of
the class for Hash.
Regards
ppk
from raaz.
Yes, You can look the current code at
https://github.com/satvikc/raaz/blob/master/raaz-primitives/Raaz/Hash.hs
On Mon, May 27, 2013 at 8:58 AM, Piyush P Kurur [email protected]:
On Mon, May 27, 2013 at 05:52:47AM -0700, satvikc wrote:
Raaz/Hash.hs:130:27:
Could not deduce (HashImplementation
(DefaultBlockImplementation h1) h1)
arising from a use of hash'
from the context (Hash h, ByteSource src)
bound by the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
at Raaz/Hash.hs:(128,1)-(130,40)
or from (ByteSource src1)
bound by the type signature for
hash'' :: ByteSource src1 =>
DefaultBlockImplementation h1 -> src1 -> IO h1
at Raaz/Hash.hs:130:9-40
Possible fix:
add (HashImplementation
(DefaultBlockImplementation h1) h1) to the context of
the type signature for
hash'' :: ByteSource src1 =>
DefaultBlockImplementation h1 -> src1 -> IO h1
or the type signature for
hash :: (Hash h, ByteSource src) => src -> IO h
or add an instance declaration for
(HashImplementation (DefaultBlockImplementation h1) h1)
In the expression: hash' impl src
In an equation for hash'': hash'' impl src = hash' impl src
In an equation for `hash':
hash src
= hash'' undefined src
where
hash'' ::
ByteSource src => DefaultBlockImplementation h -> src -> IO
h
hash'' impl src = hash' impl srcDo you have the constraint
HashImplementation (DefaultBlockImplementation h) in the definition of
the class for Hash.Regards
ppk
—
Reply to this email directly or view it on GitHubhttps://github.com/piyush-kurur/raaz/issues/41#issuecomment-18497450
.
Satvik Chauhan
Fourth Year Under Graduate Student
Deptt. of Computer Science and Engineering
Indian Institute of Technology Kanpur
Kanpur-208016, INDIA
Email: [email protected] , [email protected]
from raaz.
On Mon, May 27, 2013 at 06:07:37AM -0700, satvikc wrote:
Yes, You can look the current code at
https://github.com/satvikc/raaz/blob/master/raaz-primitives/Raaz/Hash.hs
I have edited the Hash file and now it does not use scoped type
variables for Hash. You still need to get the HMac thing working. But
I think it is straight forward. I am attaching the file with this mail
have a look.
Regards
ppk
from raaz.
I did attach the updated Raaz.Hash file. I am sending a separate mail to your cse account if you did not get the attachment.
from raaz.
Is there a reason you changed the implementation of hashFile
to use withFile
from using transformContextFile
. I am using transformContextFile
in the corresponding implementation for MAC
.
from raaz.
On Wed, May 29, 2013 at 01:26:26AM -0700, satvikc wrote:
Is there a reason you changed the implementation of
hashFile
to
usewithFile
from usingtransformContextFile
. I am using
transformContextFile
in the corresponding implementation for
MAC
.
I thought the code was simpler.
Regards
ppk
from raaz.
Related Issues (20)
- Uploading candidate release onto Debian experimental HOT 34
- 32-bit windows build fails on appveyor HOT 7
- Getting rid of unwanted files HOT 1
- Platform czars for raaz HOT 3
- Automatically run and check examples embedded in haddock
- Entropy and randomness quality tests.
- Backpack based modules HOT 1
- travis get random flags HOT 1
- Fix appveyor to build against 32-bit windows as well HOT 2
- Integrate standard test vectors.
- Integration of primitives from libverse HOT 1
- Raaz executable segfaults HOT 4
- Installation via Stack HOT 2
- Almost non-existent haddock documentation with the backpack based design HOT 2
- Use windows NUL file for /dev/null in the test for empty reads
- Apache 2.0 licensing HOT 9
- XChaCha20 variant HOT 2
- Use explicit_bzero and friends HOT 2
- upload `2.2` to hackage HOT 9
- Poly1305 tests based on inbuilt haskell `Integer` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raaz.