Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

sessionKeys (Ruby)

Gem Version Build Status Coverage Status Code Climate Inline docs

sessionKeys is a cryptographic tool for the generation of unique user IDs, and NaCl compatible Curve25519 encryption, and Ed25519 digital signature keys using Ruby.

It is compatible with grempe/session-keys-js which can generates identical IDs and crypto keys using Javascript when given the same username and passphrase values. Both libraries have extensive tests to ensure they remain interoperable.

The strength of the system lies in the fact that the keypairs are derived from passing an identifier such as a username or email address, and a high-entropy passphrase through the SHA256 cryptographic one-way hash function, and then 'stretching' that username/password into strong key material using the scrypt key derivation function.

For an overview of the security design, please see the README for the companion project grempe/session-keys-js


Add this line to your application's Gemfile:

gem 'session_keys'

And then execute:

$ bundle

Or install it yourself as:

$ gem install session_keys


require 'session_keys'

SessionKeys.generate('', 'my strong passphrase')

  id: '...',
  byte_keys: [...],
  hex_keys: [...],
  nacl_encryption_key_pairs: [...],
  nacl_encryption_key_pairs_base64: [...],
  nacl_signing_key_pairs: [...],
  nacl_signing_key_pairs_base64: [...],
  process_time: 250

Security Note : Each Array will contain eight values. Since each value at a particular Array index is derived from the same key material it is recommended to choose the different key types you need from different Array indexes. This ensures that each key type was not derived from the same value.

# uuid : array index 0

# encryption keypair : array index 1

# signing keypair : array index 2

Installation Security : Signed Git Commits

Most, if not all, of the commits and tags to the repository for this code are signed with my PGP/GPG code signing key. I have uploaded my code signing public keys to GitHub and you can now verify those signatures with the GitHub UI. See this list of commits and look for the Verified tag next to each commit. You can click on that tag for additional information.

You can also clone the repository and verify the signatures locally using your own GnuPG installation. You can find my certificates and read about how to conduct this verification at


After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.



(c) 2016 Glenn Rempe <> (


The gem is available as open source under the terms of the MIT License.


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the LICENSE.txt file for the specific language governing permissions and limitations under the License.