Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passphrase Primitives (encryption & check) #175

Merged
merged 2 commits into from
Apr 23, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Apr 23, 2019

Issue Number

#95

Overview

  • I have added some crypto primitives to hash / encrypt a passphrase and check an existing one against an already stored hash

Comments

This has been checked with the crypto team. A possible improvement later: use a timing loop instead of a fixed iteration count (i.e. loop for a short & constant period, and then, store the total number of iterations so that iterations are non-deterministic).

This is preparatory work for an upcoming keystore to store and retrieve encrypted private keys.

@KtorZ KtorZ requested a review from Anviking April 23, 2019 15:48
@KtorZ KtorZ self-assigned this Apr 23, 2019
@KtorZ KtorZ force-pushed the KtorZ/95/passphrase-primitives branch from 6a67224 to ea6df96 Compare April 23, 2019 15:48
Copy link
Collaborator

@Anviking Anviking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some thoughts on the MonadRandom ((->) (Passphrase "salt")) doc-comment.

This has been checked with the crypto team

👍

data ErrWrongPassphrase = ErrWrongPassphrase
deriving stock (Show, Eq)

-- | Little trick to be able to provide our own random "salt" in order to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this very confusing at first.

our own random "salt"

why call it random then?

Suggested change
-- | Little trick to be able to provide our own random "salt" in order to
-- | Little trick to be able to provide our own "random" salt in order to

or maybe:

Suggested change
-- | Little trick to be able to provide our own random "salt" in order to
-- | Little trick to provide a specific salt instead of a random one in order to

Regardless, adding the type signature as FYI in this comment somehow would make the point more explicit / difficult to miss:

>>> encryptPassphrase
	    :: MonadRandom m => Passphrase purpose -> m (Hash purpose)
>>> encryptPassphrase pwd (Passphrase @"salt" salt)
Hash "..."

if you don't find it too ugly.

Also, interesting trick 😮

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am all for better comments 👍

@@ -116,6 +125,15 @@ spec = do
goldenYoroiAddr (seed1, recPwd1) InternalChain accIx addrIx
"Ae2tdPwUPEZLSqQN7XNJRMJ6yHWdfFLaQgPPYgyJKrJnCVnRtbfw6EHRv1D"

describe "Passphrases" $ do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@KtorZ KtorZ force-pushed the KtorZ/95/passphrase-primitives branch from ea6df96 to 4a2b529 Compare April 23, 2019 20:27
@KtorZ KtorZ merged commit a0d5977 into master Apr 23, 2019
@KtorZ KtorZ deleted the KtorZ/95/passphrase-primitives branch April 23, 2019 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants