switch truncate_digest_for_ecdsa to context manager

Also adds a docstring to fix #1335
Merge pull request #1349 from reaperhulk/more-ctx-mger

switch truncate_digest_for_ecdsa to context manager