0xPolygonMiden / miden-base

Core components of the Polygon Miden rollup
MIT License
73 stars 45 forks source link

Add a way to access the script's hash from inside the script itself #977

Open tomyrd opened 5 days ago

tomyrd commented 5 days ago

Feature description

Would it be useful to have procedures in the kernel to obtain the context's script hash?

Why is this feature needed?

While implementing https://github.com/0xPolygonMiden/clob-example/pull/3 I needed to get the note script's hash from inside the note script itself. I ended up compiling and hashing the script and adding the digest to the note's inputs.

Maybe this case is too niche to deserve a dedicated procedure.

bobbinth commented 5 days ago

I think this is a good functionality to add. It could be done via a relatively simple kernel procedure - e.g., something like miden::note::get_script_hash. This procedure would return the hash of the currently executing note or error out if we are not currently executing any notes.