Skip to content

Prevent Stack Overlaps in Hashing Functions via Persistent Workspaces #645

@BowTiedWoo

Description

@BowTiedWoo

Currently, each call to the hashing functions sha256, sha512, and hash160 creates a new workspace by using stack-pointer. This leads to inefficient memory usage.

More critically, it introduces the potential for memory-related bugs when a hashing function is used inside a function that is invoked via contract-call?.

To resolve this, each hashing function should allocate its workspace once, store the location in a OnceCell, and reuse it across subsequent calls.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions