Sha256: 098990df36bb0a296f9fb9574d411a89a37a29726c2e88f752f8943d7b0845ab

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

begin
  require 'ed448'
  Ed448.init
rescue LoadError
end

module Noise
  module Functions
    module DH
      class ED448
        DHLEN = Ed448::X448::X448_PRIVATE_BYTES

        def generate_keypair
          private_key = SecureRandom.random_bytes(DHLEN)
          public_key = Ed448::X448.derive_public_key(private_key)
          Noise::Key.new(private_key, public_key)
        end

        def dh(private_key, public_key)
          Ed448::X448.dh(public_key, private_key)
        end

        def dhlen
          DHLEN
        end

        def self.from_private(private_key)
          public_key = Ed448::X448.derive_public_key(private_key)
          Noise::Key.new(private_key, public_key)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
noise-ruby-0.10.0 lib/noise/functions/dh/ed448.rb
noise-ruby-0.9.4 lib/noise/functions/dh/ed448.rb