Skip to content

refactor: add miden::protocol::auth module with public auth event constants#2377

Merged
PhilippGackstatter merged 1 commit into0xMiden:nextfrom
Farukest:feat/issue-2370-auth-events-constants
Feb 3, 2026
Merged

refactor: add miden::protocol::auth module with public auth event constants#2377
PhilippGackstatter merged 1 commit into0xMiden:nextfrom
Farukest:feat/issue-2370-auth-events-constants

Conversation

@Farukest
Copy link
Copy Markdown
Contributor

Summary

  • Created crates/miden-protocol/asm/protocol/auth.masm with public constants:
    • AUTH_REQUEST_EVENT
    • AUTH_UNAUTHORIZED_EVENT
  • Updated 4 auth modules in miden-standards to import these constants instead of defining them locally
  • Removed custom event handling from build.rs since events are now defined in the protocol module

Closes #2370

@Farukest
Copy link
Copy Markdown
Contributor Author

The pub const approach has a limitation: the emit instruction only accepts local constant names, not namespaced constants like emit.module::CONSTANT.

So even if we define pub const AUTH_REQUEST_EVENT in miden::protocol::auth_events, we can't use it as emit.auth_events::AUTH_REQUEST_EVENT in other modules.

@bobbinth is there a way to import a pub const and use it with emit? Or is this a limitation of the current MASM assembler?

@PhilippGackstatter
Copy link
Copy Markdown
Contributor

That's probably a question for @bitwalker.

@bitwalker
Copy link
Copy Markdown
Collaborator

The pub const approach has a limitation: the emit instruction only accepts local constant names, not namespaced constants like emit.module::CONSTANT.

So even if we define pub const AUTH_REQUEST_EVENT in miden::protocol::auth_events, we can't use it as emit.auth_events::AUTH_REQUEST_EVENT in other modules.

@bobbinth is there a way to import a pub const and use it with emit? Or is this a limitation of the current MASM assembler?

Importing constants via use some::module::CONSTANT makes CONSTANT available as if it had been defined in the same module, the same is true of procedures. Unfortunately, due to an issue in the linker (that I will submit a patch for here later today), if the first component of the external path is not a module that exists, symbol resolution will fail.

However, a workaround is to do the following instead:

use some::module

const CONSTANT = module::CONSTANT

# OR

const CONSTANT = ::some::module::CONSTANT

As I mentioned above though, this shouldn't be necessary, i.e. use some::module::CONSTANT should just work (once I've addressed that annoying bug today). We should be able to get that out in a patch for the v0.20 VM ASAP.

@Farukest Farukest force-pushed the feat/issue-2370-auth-events-constants branch from 01901f7 to 137cafa Compare February 2, 2026 17:32
…stants

This adds a new auth.masm module under miden::protocol that exports
public constants for authentication events:
- AUTH_REQUEST_EVENT: emitted when requesting an authentication signature
- AUTH_UNAUTHORIZED_EVENT: emitted when authentication is unauthorized

The constants are defined using the event() function and can be imported
by other modules.

Note: Due to a linker bug in miden-assembly, direct imports like
`use miden::protocol::auth::AUTH_REQUEST_EVENT` don't work yet.
As a workaround, modules define local constants that reference the
full path: `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`

Closes 0xMiden#2370
@Farukest Farukest force-pushed the feat/issue-2370-auth-events-constants branch from 137cafa to 3315a8d Compare February 2, 2026 17:37
bitwalker added a commit to 0xMiden/miden-vm that referenced this pull request Feb 2, 2026
In the course of looking into an issue described
[here](0xMiden/protocol#2377 (comment)),
I discovered that a lot of the symbol resolver complexity was due to
handling edge cases at the wrong level. Not only did this result in a
lot of excess complexity, but it also failed to account for issues such
as the one identified in the linked comment above.

This commit rewrites the core `resolve_path` implementation to work in
terms of "expanding" a path into its absolute form, and then resolving
the absolute path. This is much more efficient, since we can take a
couple of shortcuts based on a few rules, and results in much more
intuitive behavior, and a considerably simpler implementation.

Two new tests were added to catch a few edge cases that were not well
represented by our existing test suite, and can be used to prevent
future regressions as well.

This is a non-breaking change in the public interface of the assembler.
bitwalker added a commit to 0xMiden/miden-vm that referenced this pull request Feb 2, 2026
In the course of looking into an issue described
[here](0xMiden/protocol#2377 (comment)),
I discovered that a lot of the symbol resolver complexity was due to
handling edge cases at the wrong level. Not only did this result in a
lot of excess complexity, but it also failed to account for issues such
as the one identified in the linked comment above.

This commit rewrites the core `resolve_path` implementation to work in
terms of "expanding" a path into its absolute form, and then resolving
the absolute path. This is much more efficient, since we can take a
couple of shortcuts based on a few rules, and results in much more
intuitive behavior, and a considerably simpler implementation.

Two new tests were added to catch a few edge cases that were not well
represented by our existing test suite, and can be used to prevent
future regressions as well.

This is a non-breaking change in the public interface of the assembler.
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter 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 to me!

@PhilippGackstatter PhilippGackstatter merged commit 5c9201a into 0xMiden:next Feb 3, 2026
15 checks passed
Farukest added a commit to Farukest/miden-base that referenced this pull request Feb 4, 2026
Resolve merge conflicts with recent changes:
- 0xMiden#2369: Updated offset numbers for new get_asset API
- 0xMiden#2377: Keep pub const prefix for all offset constants
bobbinth pushed a commit to 0xMiden/miden-vm that referenced this pull request Feb 4, 2026
)

* refactor(assembly): improve link-time symbol resolution internals

In the course of looking into an issue described
[here](0xMiden/protocol#2377 (comment)),
I discovered that a lot of the symbol resolver complexity was due to
handling edge cases at the wrong level. Not only did this result in a
lot of excess complexity, but it also failed to account for issues such
as the one identified in the linked comment above.

This commit rewrites the core `resolve_path` implementation to work in
terms of "expanding" a path into its absolute form, and then resolving
the absolute path. This is much more efficient, since we can take a
couple of shortcuts based on a few rules, and results in much more
intuitive behavior, and a considerably simpler implementation.

Two new tests were added to catch a few edge cases that were not well
represented by our existing test suite, and can be used to prevent
future regressions as well.

This is a non-breaking change in the public interface of the assembler.
Farukest added a commit to Farukest/miden-base that referenced this pull request Feb 5, 2026
Replace the temporary workaround constants introduced in PR 0xMiden#2377 with
direct imports from `miden::protocol::auth`. The linker bug that required
the workaround has been fixed in miden-vm#2637.

Changes:
- Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`
  with `use miden::protocol::auth::AUTH_REQUEST_EVENT`
- Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`
  with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`

Closes 0xMiden#2392
Farukest added a commit to Farukest/miden-base that referenced this pull request Feb 5, 2026
Replace the temporary workaround constants introduced in PR 0xMiden#2377 with
direct imports from `miden::protocol::auth`. The linker bug that required
the workaround has been fixed in miden-vm#2637.

Changes:
- Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`
  with `use miden::protocol::auth::AUTH_REQUEST_EVENT`
- Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`
  with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`

Closes 0xMiden#2392
Farukest added a commit to Farukest/miden-base that referenced this pull request Feb 5, 2026
Replace the temporary workaround constants introduced in PR 0xMiden#2377 with
direct imports from `miden::protocol::auth`. The linker bug that required
the workaround has been fixed in miden-vm#2637.

Changes:
- Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`
  with `use miden::protocol::auth::AUTH_REQUEST_EVENT`
- Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`
  with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`

Closes 0xMiden#2392
PhilippGackstatter added a commit that referenced this pull request Feb 5, 2026
…#2404)

* refactor: replace auth event constant workarounds with direct imports

Replace the temporary workaround constants introduced in PR #2377 with
direct imports from `miden::protocol::auth`. The linker bug that required
the workaround has been fixed in miden-vm#2637.

Changes:
- Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`
  with `use miden::protocol::auth::AUTH_REQUEST_EVENT`
- Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`
  with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`

Closes #2392

* chore: update miden-assembly to v0.20.6 for constant import support

---------

Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Mar 9, 2026
…stants (0xMiden#2377)

This adds a new auth.masm module under miden::protocol that exports
public constants for authentication events:
- AUTH_REQUEST_EVENT: emitted when requesting an authentication signature
- AUTH_UNAUTHORIZED_EVENT: emitted when authentication is unauthorized

The constants are defined using the event() function and can be imported
by other modules.

Note: Due to a linker bug in miden-assembly, direct imports like
`use miden::protocol::auth::AUTH_REQUEST_EVENT` don't work yet.
As a workaround, modules define local constants that reference the
full path: `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`

Closes 0xMiden#2370
afa7789 pushed a commit to afa7789/miden-base that referenced this pull request Mar 9, 2026
…0xMiden#2404)

* refactor: replace auth event constant workarounds with direct imports

Replace the temporary workaround constants introduced in PR 0xMiden#2377 with
direct imports from `miden::protocol::auth`. The linker bug that required
the workaround has been fixed in miden-vm#2637.

Changes:
- Replace `const AUTH_REQUEST_EVENT = ::miden::protocol::auth::AUTH_REQUEST_EVENT`
  with `use miden::protocol::auth::AUTH_REQUEST_EVENT`
- Replace `const AUTH_UNAUTHORIZED_EVENT = ::miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`
  with `use miden::protocol::auth::AUTH_UNAUTHORIZED_EVENT`

Closes 0xMiden#2392

* chore: update miden-assembly to v0.20.6 for constant import support

---------

Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
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.

Add auth events to miden::protocol

3 participants