How to use the sodium-native.crypto_sign_seed_keypair function in sodium-native

To help you get started, we’ve selected a few sodium-native 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 LiskHQ / lisk-sdk / elements / lisk-cryptography / src / nacl / fast.ts View on Github external
export const getPublicKey: NaclInterface['getPublicKey'] = privateKey => {
	const publicKeyBytes = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
	const privateKeyBytes = Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES);

	sodium.crypto_sign_seed_keypair(publicKeyBytes, privateKeyBytes, privateKey);

	return publicKeyBytes;
};
github AraiEzzra / DDKCORE / shared / util / ed.ts View on Github external
public makeKeyPair(hash: Buffer): IKeyPair {
        const keyPair: IKeyPair = {
            publicKey: Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES),
            privateKey: Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES)
        };

        sodium.crypto_sign_seed_keypair(keyPair.publicKey, keyPair.privateKey, hash);
        return keyPair;
    }
github RiseVision / rise-node / packages / core-crypto / src / crypto_sodium_native.ts View on Github external
public makeKeyPair(hash: Buffer): IKeypair {
    const publicKey = Buffer.alloc(
      sodium.crypto_sign_PUBLICKEYBYTES
    ) as Buffer & As<'publicKey'>;
    const privateKey = Buffer.alloc(
      sodium.crypto_sign_SECRETKEYBYTES
    ) as Buffer & As<'privateKey'>;
    sodium.crypto_sign_seed_keypair(publicKey, privateKey, hash);
    return { privateKey, publicKey };
  }
github jwerle / hidden-machine / index.js View on Github external
crypto_sign_SEEDBYTES) ||
    Buffer.allocUnsafe(crypto_sign_SEEDBYTES)
  )

  const key = (
    ensureBufferWithSize(
      utils.toBuffer(opts.key, 'hex'),
      crypto_kdf_KEYBYTES) ||
    secretKey.slice(0, crypto_kdf_KEYBYTES)
  )

  if (!opts.publicKey || !opts.secretKey) {
    if (!opts.seed) {
      crypto_generichash_batch(seed, [ secret ])
    }
    crypto_sign_seed_keypair(publicKey, secretKey, seed)
  }

  if (true === opts.keygen) {
    return {
      publicKey, secretKey, secret, key
    }
  }

  opts.sign.publicKey = publicKey
  opts.sign.secretKey = secretKey

  opts.segment.key = key

  if (null !== nonce) {
    opts.segment.nonce = nonce
  }
github LiskHQ / lisk-sdk / framework / src / modules / chain / helpers / ed.js View on Github external
ed.makeKeypair = function(hash) {
	const publicKey = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
	const privateKey = Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES);
	sodium.crypto_sign_seed_keypair(publicKey, privateKey, hash);

	return {
		publicKey,
		privateKey,
	};
};
github LiskHQ / lisk-sdk / elements / lisk-cryptography / src / nacl / fast.ts View on Github external
export const getKeyPair: NaclInterface['getKeyPair'] = hashedSeed => {
	const publicKeyBytes = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
	const privateKeyBytes = Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES);

	sodium.crypto_sign_seed_keypair(publicKeyBytes, privateKeyBytes, hashedSeed);

	return {
		publicKeyBytes,
		privateKeyBytes,
	};
};
github mafintosh / sodium-signatures / sodium.js View on Github external
exports.keyPair = function (seed) {
  var publicKey = new Buffer(sodium.crypto_sign_PUBLICKEYBYTES)
  var secretKey = new Buffer(sodium.crypto_sign_SECRETKEYBYTES)

  if (seed) sodium.crypto_sign_seed_keypair(publicKey, secretKey, seed)
  else sodium.crypto_sign_keypair(publicKey, secretKey)

  return {
    publicKey: publicKey,
    secretKey: secretKey
  }
}
github emilbayes / rendezvous-point / index.js View on Github external
assert(message.byteLength <= 1000)

  var self = this
  var rendevousPoint = Buffer.allocUnsafe(sodium.crypto_kx_SESSIONKEYBYTES)

  sodium.crypto_kx_server_session_keys(
    rendevousPoint,
    null,
    self.keypair.publicKey,
    self.keypair.secretKey,
    remoteKey
  )

  var discoveryPk = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES)
  var discoverySk = sodium.sodium_malloc(sodium.crypto_sign_SECRETKEYBYTES)
  sodium.crypto_sign_seed_keypair(discoveryPk, discoverySk, rendevousPoint)

  self.dht.put({
    v: message,
    k: discoveryPk,
    seq: 0,
    sign: function (buf) {
      var sig = Buffer.alloc(sodium.crypto_sign_BYTES)
      sodium.crypto_sign_detached(sig, buf, discoverySk)
      return sig
    }
  }, cb)
}
github holochain / n3h / lib / mosodium / sign.js View on Github external
secretKey.writable(_secretKey => {
      sodium.crypto_sign_seed_keypair(publicKey, _secretKey, _seed)
    })
  })