cryptol/examples/MiniLock
Trevor Elliott 4dc5eda23a Expand the width table, and fix a bug in CryptoBox (Thanks @tommd)
The width table in CryptolTC.z3 wasn't large enough to solve constraints
about the width of 64-bit words. This change is a bit of a band-aid, as
larger words will expose the same problem. Longer-term, we should try to
solve these constraints after the SMT-based phase, using some other
approach.

The constraints in CryptoBox were too permissive, and when adjusted to
represent the true intent (that values fit within 64-bits), and the
width table was updated, the example will type-check again.

Thanks to @tommd for tracking both of these down.
2017-03-27 13:45:50 -07:00
..
prim Expand the width table, and fix a bug in CryptoBox (Thanks @tommd) 2017-03-27 13:45:50 -07:00
File.md Update examples to use (/\) instead of (&&) where appropriate, 2016-08-22 18:14:44 -07:00
Keys.cry Update examples to use (/\) instead of (&&) where appropriate, 2016-08-22 18:14:44 -07:00
README.md integrate MiniLock example 2016-01-19 18:19:35 -08:00

Minilock in Cryptol

miniLock is a low-barrier to use file encryption utility based on the algorithms:

  • SCrypt
    • PBKDF2
    • HMAC-SHA512
  • Blake2s
  • Base64
  • Base58
  • CryptoBox
    • Salsa20
    • Curve25519
    • Poly1305

This example is a specification of miniLock file encryption in Cryptol including all component algorithms as well as primitive JSON encoding to allow inter-operability between the official miniLock written in JavaScript and files produced by Cryptol.

Use

To encrypt a file consider:

CRYPTOLPATH=`pwd`/prim cryptol File.md

Then use the miniLock function such as can be seen in test_lock:

miniLock [(theirID, nonceA)] filename contents (myPrivKey, myPubKey) key nonceF (ephemPriv, ephemPub)

Note SCrypt, and thus miniLock ID and key derivation from user passwords, is too expensive for the Cryptol interpreter to compute on all but todays more powerful computers. The ID generation can be done using mkID from Keys.cry.

License

Copyright (c) 2013-2016 Galois, Inc. Distributed under the terms of the BSD3 license (see LICENSE file)