Module: SecretSharing::Prime

Extended by:
Prime
Included in:
Prime
Defined in:
lib/secret_sharing/prime.rb

Overview

This module is used to generate/calculate/retrieve primes.

Defined Under Namespace

Classes: CannotFindLargeEnoughPrime

Instance Method Summary collapse

Instance Method Details

#large_enough_prime(input) ⇒ Integer

Retrieves the next largest prime for the largest number in batch

Example

Prime.large_enough_prime 4
# => 7

Raises:


19
20
21
22
23
24
# File 'lib/secret_sharing/prime.rb', line 19

def large_enough_prime(input)
  standard_primes.each do |prime|
    return prime if prime > input
  end
  fail CannotFindLargeEnoughPrime, 'Input too large'
end