Sha256: c448e8d1a413b54055f5a0d87679268e4b721a0a8cc970cf521c3a35a16f78cb

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

module BLS
  module_function

  class PairingError < StandardError; end

  # @param [BLS::PointG1] p
  # @param [BLS::PointG2] q
  # @param [Boolean] with_final_exp
  # @return [BLS::Fp12]
  # @raise [BLS::PairingError] Occur when p.zero? or q.zero?
  # @raise [ArgumentError]
  def pairing(p, q, with_final_exp: true)
    raise ArgumentError, 'p should be BLS::PointG1 object' unless p.is_a?(BLS::PointG1)
    raise ArgumentError, 'q should be BLS::PointG2 object' unless q.is_a?(BLS::PointG2)
    raise PairingError, 'No pairings at point of Infinity' if p.zero? || q.zero?

    p.validate!
    q.validate!
    looped = p.miller_loop(q)
    with_final_exp ? looped.final_exponentiate : looped
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bls12-381-0.3.0 lib/bls/pairing.rb