###
This file is part of the Lockbox package.

Copyright © 2013 Erin Millard

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
###

EncryptionCipher = require './EncryptionCipher'
InvalidPublicKeyException = require './Exception/InvalidPublicKeyException'

module.exports = class BoundEncryptionCipher

  constructor: ( \
    key,
    encryptionCipher = new EncryptionCipher,
    ursa = (require 'ursa')
  ) ->
    try
      ursa.assertKey key
    catch error
      throw new InvalidPublicKeyException key, error

    @_key = key
    @_encryptionCipher = encryptionCipher

  encrypt: (data) ->
    @_encryptionCipher.encrypt @_key, data
