Skip to content

Commit 43e78c0

Browse files
committed
fixups in Entropy
1 parent a1b579f commit 43e78c0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,28 +326,29 @@ with open("vk.pem", "wb") as f:
326326
## Entropy
327327

328328
Creating a signing key with `SigningKey.generate()` requires some form of
329-
entropy (as opposed to `from_secret_exponent/from_string/from_der/from_pem`,
329+
entropy (as opposed to
330+
`from_secret_exponent`/`from_string`/`from_der`/`from_pem`,
330331
which are deterministic and do not require an entropy source). The default
331332
source is `os.urandom()`, but you can pass any other function that behaves
332-
like os.urandom as the entropy= argument to do something different. This may
333-
be useful in unit tests, where you want to achieve repeatable results. The
334-
ecdsa.util.PRNG utility is handy here: it takes a seed and produces a strong
333+
like `os.urandom` as the `entropy=` argument to do something different. This
334+
may be useful in unit tests, where you want to achieve repeatable results. The
335+
`ecdsa.util.PRNG` utility is handy here: it takes a seed and produces a strong
335336
pseudo-random stream from it:
336337

337338
```python
338339
from ecdsa.util import PRNG
339340
from ecdsa import SigningKey
340-
rng1 = PRNG("seed")
341+
rng1 = PRNG(b"seed")
341342
sk1 = SigningKey.generate(entropy=rng1)
342-
rng2 = PRNG("seed")
343+
rng2 = PRNG(b"seed")
343344
sk2 = SigningKey.generate(entropy=rng2)
344345
# sk1 and sk2 are the same key
345346
```
346347

347348
Likewise, ECDSA signature generation requires a random number, and each
348349
signature must use a different one (using the same number twice will
349350
immediately reveal the private signing key). The `sk.sign()` method takes an
350-
entropy= argument which behaves the same as `SigningKey.generate(entropy=)`.
351+
`entropy=` argument which behaves the same as `SigningKey.generate(entropy=)`.
351352

352353
## Deterministic Signatures
353354

0 commit comments

Comments
 (0)