Skip to content

Instantly share code, notes, and snippets.

@grantr
grantr / curvecp_handshake.rb
Last active July 19, 2018 15:16
CurveCP handshake protocol in Ruby
# A demonstration of the CurveCP handshake protocol. This protocol has many
# favorable security properties described at http://curvecp.org.
#
# In addition to its security advantages, it has the following favorable properties:
# * Needs only 2 messages (1 from client, 1 from server) before application
# messages can be exchanged (3 before the server can send application messages)
# * Does not require the server to keep protocol state between handshake messages.
#
# An overview of the protocol:
#
@tarcieri
tarcieri / semiprivate.rb
Created February 9, 2013 23:58
Trying to put together a semiprivate key system
# Experimenting with implementing semiprivate keys with RbNaCl
require 'rbnacl'
require 'hkdf'
module Semiprivate
class WriteKey
def initialize(seed)
if seed.bytesize != 32
raise ArgumentError, "seed must be 32 bytes"