Our confidence in the scratch space code isn’t particularly high. It reinvents bump allocation, but it had a few issues in the past. All the code that uses scratch space is currently unreachable from the public API (except that we have secp256k1_scratch_create
and secp256k1_scratch_destroy
themselves in the public API.
A much simpler alternative is to get rid of scratch spaces and just assume the existence of malloc
/free
and use these directly. The disadvantage of this is that it’s a bit harder for platforms that don’t have malloc
.
Another alternative is to rework the scratch space code. It may be possible to simply it and improve its usability.
I think our future directions on this should be guided by whatever we feel is best for our cases: