]> gitweb.factorcode.org Git - factor.git/blob - basis/math/primes/safe/safe-docs.factor
Switch to https urls
[factor.git] / basis / math / primes / safe / safe-docs.factor
1 ! Copyright (C) 2009 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel math ;
4 IN: math.primes.safe
5
6 HELP: next-safe-prime
7 { $values
8     { "n" integer }
9     { "q" integer }
10 }
11 { $description "Tests consecutive numbers and returns the next safe prime. A safe prime is desirable in cryptography applications such as Diffie-Hellman and SRP6." } ;
12
13 HELP: random-safe-prime
14 { $values
15     { "numbits" integer }
16     { "p" integer }
17 }
18 { $description "Returns a safe prime number " { $snippet "numbits" } " bits in length, with the topmost bit set to one." } ;
19
20 HELP: safe-prime?
21 { $values
22     { "q" integer }
23     { "?" boolean }
24 }
25 { $description "Tests whether the number is a safe prime. A safe prime " { $snippet "p" } " must be prime, as must " { $snippet "(p - 1) / 2" } "." } ;
26
27
28 ARTICLE: "math.primes.safe" "Safe prime numbers"
29 "The " { $vocab-link "math.primes.safe" } " vocabulary implements words to calculate safe prime numbers. Safe primes are of the form " { $snippet "p = 2q + 1" } ", where " { $snippet "p" } ", " { $snippet "q" } " are prime. Safe primes have desirable qualities for cryptographic applications." $nl
30
31 "Testing if a number is a safe prime:"
32 { $subsections safe-prime? }
33 "Generating safe prime numbers:"
34 { $subsections
35     next-safe-prime
36     random-safe-prime
37 } ;
38
39 ABOUT: "math.primes.safe"