Sha256: 2ed1e9b5f01d7a10cfa0f4cb869da988076695a16cf9ab8a7ef3fdc7c3c3e5ac

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

module PolyPseudo
  class Pseudonym
    include PolyPseudo::PseudoId

    # @param [PolyPseudo::Key] closing_key
    def decrypt(decryption_key, closing_key)
      PolyPseudo.init!
      decryption_private_key = decryption_key.ec.private_key
      closing_private_key    = closing_key.ec.private_key

      product            = decryption_private_key.mod_mul(closing_private_key, PolyPseudo.config.group.order)
      point_2_multiplied = point_2.mul(closing_private_key)

      pseudo_point        = point_1
          .mul(product)
          .invert!
          .add(point_2_multiplied)
          .make_affine!

      @pseudonym = closing_key.recipient_key_set_version.to_s + pseudo_point.to_hex
    end

    def pseudonym
      @pseudonym || raise("Pseudonym not decrypted yet. call .decrypt first")
    end

    alias_method :pseudo_id, :pseudonym
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
poly_pseudo-0.1.4 lib/poly_pseudo/pseudonym.rb
poly_pseudo-0.1.3 lib/poly_pseudo/pseudonym.rb
poly_pseudo-0.1.2 lib/poly_pseudo/pseudonym.rb
poly_pseudo-0.1.1 lib/poly_pseudo/pseudonym.rb