Saltpack::

Refinements module

Public Class Methods

beforenm( public_key, private_key )

Get the shared key for the box derived from the specified public_key and private_key.

# File lib/saltpack/refinements.rb, line 14
def self::beforenm( public_key, private_key )
        key = RbNaCl::Utils.zeros( RbNaCl::Box::BEFORENMBYTES )
        self.box_curve25519xsalsa20poly1305_beforenm( key, public_key, private_key ) or
                return nil

        return key
end
open_afternm( ciphertext, beforenm, nonce, num_bytes )

Decrypt the specified num_bytes of ciphertext using the given nonce and beforenm.

# File lib/saltpack/refinements.rb, line 25
def self::open_afternm( ciphertext, beforenm, nonce, num_bytes )
        message = RbNaCl::Utils.zeros( num_bytes )
        # m,c,clen,n,k
        self.box_curve25519xsalsa20poly1305_open_afternm( message,
                ciphertext, ciphertext.bytesize, nonce, beforenm ) or return nil

        return message
end