decred / tinydecred

Python tools for Decred
ISC License
27 stars 14 forks source link

rando: refactor random generation of keys and hashes #117

Closed teknico closed 4 years ago

teknico commented 4 years ago

Currently new keys and hashes are generated with calls to rando.generateSeed all over the codebase, sometimes using the KEY_SIZE and HASH_SIZE constants and often wrapping the resulting byte sequence with ByteArray.

This PR refactors most of those calls to use four new functions instead: newHash, newHashRaw, newKey, newKeyRaw. This reduces redundancy and increases clarity about the meaning of each generated byte sequence.

It also includes a lot of formatting cleanup in test_txscript.py.

Please check the changes, I'm a little fuzzy about the semantic differences among seeds, hashes and keys. Do we also need two newSeed and newSeedRaw functions and a SEED_SIZE constant?