@@ -2757,13 +2757,18 @@ Generates a pseudo-random prime of `size` bits.
27572757If ` options.safe ` is ` true ` , the prime will be a safe prime -- that is,
27582758` (prime - 1) / 2 ` will also be a prime.
27592759
2760- If ` options.add ` and ` options.rem ` are set, the prime will satisfy the
2761- condition that ` prime % add = rem ` . The ` options.rem ` is ignored if
2762- ` options.add ` is not given. If ` options.safe ` is ` true ` , ` options.add `
2763- is given, and ` options.rem ` is ` undefined ` , then the prime generated
2764- will satisfy the condition ` prime % add = 3 ` . Otherwise if ` options.safe `
2765- is ` false ` and ` options.rem ` is ` undefined ` , ` options.add ` will be
2766- ignored.
2760+ The ` options.add ` and ` options.rem ` parameters can be used to enforce additional
2761+ requirements, e.g., for Diffie-Hellman:
2762+
2763+ * If ` options.add ` and ` options.rem ` are both set, the prime will satisfy the
2764+ condition that ` prime % add = rem ` .
2765+ * If only ` options.add ` is set and ` options.safe ` is not ` true ` , the prime will
2766+ satisfy the condition that ` prime % add = 1 ` .
2767+ * If only ` options.add ` is set and ` options.safe ` is set to ` true ` , the prime
2768+ will instead satisfy the condition that ` prime % add = 3 ` . This is necessary
2769+ because ` prime % add = 1 ` for ` options.add > 2 ` would contradict the condition
2770+ enforced by ` options.safe ` .
2771+ * ` options.rem ` is ignored if ` options.add ` is not given.
27672772
27682773Both ` options.add ` and ` options.rem ` must be encoded as big-endian sequences
27692774if given as an ` ArrayBuffer ` , ` SharedArrayBuffer ` , ` TypedArray ` , ` Buffer ` , or
@@ -2790,15 +2795,20 @@ added: REPLACEME
27902795Generates a pseudo-random prime of ` size ` bits.
27912796
27922797If ` options.safe ` is ` true ` , the prime will be a safe prime -- that is,
2793- ` (prime - 1) ` / 2 will also be a prime.
2794-
2795- If ` options.add ` and ` options.rem ` are set, the prime will satisfy the
2796- condition that ` prime % add = rem ` . The ` options.rem ` is ignored if
2797- ` options.add ` is not given. If ` options.safe ` is ` true ` , ` options.add `
2798- is given, and ` options.rem ` is ` undefined ` , then the prime generated
2799- will satisfy the condition ` prime % add = 3 ` . Otherwise if ` options.safe `
2800- is ` false ` and ` options.rem ` is ` undefined ` , ` options.add ` will be
2801- ignored.
2798+ ` (prime - 1) / 2 ` will also be a prime.
2799+
2800+ The ` options.add ` and ` options.rem ` parameters can be used to enforce additional
2801+ requirements, e.g., for Diffie-Hellman:
2802+
2803+ * If ` options.add ` and ` options.rem ` are both set, the prime will satisfy the
2804+ condition that ` prime % add = rem ` .
2805+ * If only ` options.add ` is set and ` options.safe ` is not ` true ` , the prime will
2806+ satisfy the condition that ` prime % add = 1 ` .
2807+ * If only ` options.add ` is set and ` options.safe ` is set to ` true ` , the prime
2808+ will instead satisfy the condition that ` prime % add = 3 ` . This is necessary
2809+ because ` prime % add = 1 ` for ` options.add > 2 ` would contradict the condition
2810+ enforced by ` options.safe ` .
2811+ * ` options.rem ` is ignored if ` options.add ` is not given.
28022812
28032813Both ` options.add ` and ` options.rem ` must be encoded as big-endian sequences
28042814if given as an ` ArrayBuffer ` , ` SharedArrayBuffer ` , ` TypedArray ` , ` Buffer ` , or
0 commit comments