How to use the tweetnacl.lowlevel function in tweetnacl

To help you get started, we’ve selected a few tweetnacl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mafintosh / sodium-encryption / browser.js View on Github external
exports.scalarMultiplicationKeyPair = function (secretKey) {
  if (!secretKey) secretKey = Buffer(tweetnacl.randomBytes(tweetnacl.lowlevel.crypto_scalarmult_SCALARBYTES))
  return {
    secretKey: secretKey,
    publicKey: Buffer(tweetnacl.scalarMult.base(secretKey))
  }
}
github mafintosh / sodium-signatures / browser.js View on Github external
exports.keyPair = function (seed) {
  var publicKey = Buffer(tweetnacl.lowlevel.crypto_sign_PUBLICKEYBYTES)
  var secretKey = Buffer(tweetnacl.lowlevel.crypto_sign_SECRETKEYBYTES)

  if (seed) {
    if (seed.length !== tweetnacl.lowlevel.crypto_sign_SEEDBYTES) {
      throw new Error('Seed must be ' + tweetnacl.lowlevel.crypto_sign_SEEDBYTES + ' bytes long')
    }

    secretKey.fill(seed, 0, seed.length)
    tweetnacl.lowlevel.crypto_sign_keypair(publicKey, secretKey, true)
  } else {
    tweetnacl.lowlevel.crypto_sign_keypair(publicKey, secretKey)
  }

  return {publicKey: publicKey, secretKey: secretKey}
}
github mafintosh / sodium-encryption / browser.js View on Github external
exports.key = function () {
  return Buffer(tweetnacl.randomBytes(tweetnacl.lowlevel.crypto_secretbox_KEYBYTES))
}
github mafintosh / sodium-signatures / browser.js View on Github external
exports.keyPair = function (seed) {
  var publicKey = Buffer(tweetnacl.lowlevel.crypto_sign_PUBLICKEYBYTES)
  var secretKey = Buffer(tweetnacl.lowlevel.crypto_sign_SECRETKEYBYTES)

  if (seed) {
    if (seed.length !== tweetnacl.lowlevel.crypto_sign_SEEDBYTES) {
      throw new Error('Seed must be ' + tweetnacl.lowlevel.crypto_sign_SEEDBYTES + ' bytes long')
    }

    secretKey.fill(seed, 0, seed.length)
    tweetnacl.lowlevel.crypto_sign_keypair(publicKey, secretKey, true)
  } else {
    tweetnacl.lowlevel.crypto_sign_keypair(publicKey, secretKey)
  }

  return {publicKey: publicKey, secretKey: secretKey}
}
github splunk / splunk-aws-project-trumpet / cloudtrail-serverless / lambda_code / cloudtrail_logger / node_modules / bcrypt-pbkdf / index.js View on Github external
'use strict';

var crypto_hash_sha512 = require('tweetnacl').lowlevel.crypto_hash;

/*
 * This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a
 * result, it retains the original copyright and license. The two files are
 * under slightly different (but compatible) licenses, and are here combined in
 * one file.
 *
 * Credit for the actual porting work goes to:
 *  Devi Mandiri 
 */

/*
 * The Blowfish portions are under the following license:
 *
 * Blowfish block cipher for OpenBSD
 * Copyright 1997 Niels Provos 
github mafintosh / sodium-encryption / browser.js View on Github external
exports.nonce = function () {
  return Buffer(tweetnacl.randomBytes(tweetnacl.lowlevel.crypto_box_NONCEBYTES))
}