status-im / nim-secp256k1

A wrapper for libsecp256k1
Apache License 2.0
7 stars 5 forks source link

use requiredInit #22

Closed arnetheduck closed 4 years ago

arnetheduck commented 4 years ago

Use requiredInit on keys - this simplifies error handling by providing more compile-time guarantees through type.

Loophole: clear will leave an invalid key in memory, not guaranteed by type - it requires an explicit action to produce, so it's somewhat better than the current situation where by default, keys are invalid, but it's not watertight.

something like a sink would be needed which would have to guarantee that clear is the last use of the instance.