The math.primes.safe vocabulary implements words to calculate safe prime numbers. Safe primes are of the form p = 2q + 1, where p, q are prime. Safe primes have desirable qualities for cryptographic applications.

Testing if a number is a safe prime:

Generating safe prime numbers:

Testing if a number is a safe prime:

safe-prime? ( q -- ? )

Generating safe prime numbers:

next-safe-prime ( n -- q )

random-safe-prime ( numbits -- p )