Skip to content

Advice map loading in Miden SDK#627

Merged
bitwalker merged 3 commits intonextfrom
greenhat/i626-advice-map-sdk
Aug 9, 2025
Merged

Advice map loading in Miden SDK#627
bitwalker merged 3 commits intonextfrom
greenhat/i626-advice-map-sdk

Conversation

@greenhat
Copy link
Contributor

@greenhat greenhat commented Aug 1, 2025

Close #626

This PR is stacked on the #555 and should be merged after it

This PR adds the following functions to the Miden SDK:

/// Pushes a list of field elements onto the advice stack. The list is looked up in the advice map using `key` as the key.
/// Returns the number of elements pushed on the advice stack.
fn adv_push_mapvaln(key: Word) -> Felt;
/// Pops an arbitrary number of words from the advice stack and asserts it matches the commitment.
fn adv_load_preimage(num_words: Felt, commitment: Word) -> Vec<Felt>;

@greenhat greenhat marked this pull request as ready for review August 1, 2025 14:21
@greenhat greenhat requested a review from bitwalker August 1, 2025 14:21
@greenhat greenhat linked an issue Aug 1, 2025 that may be closed by this pull request
Copy link
Collaborator

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a couple of small things I'd like to change before merging.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should call this advice.masm instead? I don't think I'd know to look for these intrinsics in a module named io.masm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Advice ops are in IO ops section of the book, but IO might be far too generic for the intrinsic file name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d236627

Comment on lines 9 to 12
pub use crypto::*;
pub use debug::*;
pub use felt::*;
pub use io::*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to hide the namespacing and re-export everything from t he top level like this - I'd rather try to match the structure of the Miden standard library. Even if we do our own organization, I still think it aids discovery when things are namespaced.

For example, miden_stdlib_sys::merge (which I saw in the diff somewhere here) does not tell you what that function is at all, while miden_stdlib_sys::crypto::merge at least hints that it is a crypto-related operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. What about the types? I suppose we export types from the root, or do we want to export them from specific crates as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d236627

Base automatically changed from greenhat/i544-run-basic-wallet-testnet to next August 6, 2025 03:39
@greenhat greenhat force-pushed the greenhat/i626-advice-map-sdk branch from b230f2d to 4815892 Compare August 6, 2025 03:51
@greenhat
Copy link
Contributor Author

greenhat commented Aug 6, 2025

Thank you! I addressed your notes. Please do another round.

Copy link
Collaborator

@bitwalker bitwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bitwalker bitwalker merged commit 48f06f1 into next Aug 9, 2025
9 checks passed
@bitwalker bitwalker deleted the greenhat/i626-advice-map-sdk branch August 9, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Advice map loading API in Miden SDK

2 participants