The Move packages¶
How the three bridge packages fit together, what bridge_authenticator checks step by step, and why the Rust relayer and the Move decoder agree on every byte.
You will learn / You need
You will learn: the role of each package, the storage layout of BridgeAA, the authenticator's check order with source lines, and the byte contract between the relayer and Move.
You need: Account abstraction and a little Move. The full
function list and abort codes are in the Move reference; this page explains
how the code works and does not repeat that table.
The packages¶
All three live under stealth_name_service/Move/, use edition 2024, have no dependencies beyond the
framework, and publish at address 0x0.
| Package | File | Chain | Role |
|---|---|---|---|
bridge_source |
stealth_name_service/Move/bridge_source/sources/bridge_source.move |
Source | Emits CrossChainRequest; records acknowledgements. |
bridge_abstract_account |
stealth_name_service/Move/bridge_abstract_account/sources/bridge_abstract_account.move |
Destination (and source for aa acks) |
The BridgeAA account and its #[authenticator]. |
bridge_target |
stealth_name_service/Move/bridge_target/sources/bridge_target.move |
Destination | A sample destination: record emits what it received. |
sequenceDiagram
participant U as User
participant S as bridge_source
participant R as Relayer
participant A as BridgeAA authenticator
participant T as bridge_target
U->>S: request(config, target, args, …)
S-->>R: CrossChainRequest event
R->>A: PTB + signed intents
A->>A: verify chain, ACL, signature, PTB
A->>T: record(...) runs as BridgeAA
R->>S: acknowledge(config, request_id, digest)
S-->>R: RequestAcknowledged event
bridge_source¶
create_config(chain_id)creates aSourceConfig { id, chain_id }and freezes it. The chain id can never change, and the relayer passes the config as["immutable", id], which the backend caches.request()asserts that the target module and function are non-empty (EEmptyTargetModule,EEmptyTargetFunction), then emitsCrossChainRequest. It stamps three fields itself rather than trusting the caller:request_id = ctx.fresh_object_address(),source_chain_idfrom the config, andsource_sender = ctx.sender().intent_bytes()produces the intent layout the authenticator decodes.request_idis not part of it.acknowledge()emitsRequestAcknowledgedwith the chain id from the config.acknowledge_pure()takes the chain id as a plain argument instead, so anaa-mode acknowledgement carries only pure inputs; the authenticator rejects object arguments.
BridgeAA storage¶
BridgeAA is a shared object with only a UID. Everything else hangs off it as dynamic fields.
| Dynamic field name | Value | Written by |
|---|---|---|
ChainIdFieldName {} |
u64 chain id of this account's chain |
create() |
AclKey { source_chain_id, source_sender } |
AclEntry { pk_bytes, scheme } |
create(), add_acl_entry() |
ChainIdFieldName has no fields, so its BCS is a single byte. The relayer reproduces that key to read
the chain id: zero_field_move_struct_key_is_one_byte_not_zero in
stealth_name_service/backend/testing_backend/src/bridge/aa.rs pins it.
create() (lines 111-143 of bridge_abstract_account.move) takes parallel vectors of initial ACL
entries, requires at least one and equal lengths, stores the chain id, inserts the entries, and
registers the account with account::create_account_v1 so that bridge_authenticator is its
authenticator. add_acl_entry() inserts or overwrites; remove_acl_entry() aborts if the entry is
absent. Both require the transaction to come from the account itself. validate_pk_bytes() requires
32 bytes for scheme 0 (ed25519), 33 for scheme 1 (secp256k1), and rejects an all-zero key.
The authenticator, step by step¶
bridge_authenticator (lines 151-175) receives the two pure inputs of the MoveAuthenticator: the BCS
vector of encoded intents and the BCS vector of signatures, plus the account object.
flowchart TD
A["intents, signatures"] --> B{"intents empty?"}
B -- yes --> X1["ENoIntents"]
B -- no --> C{"same length?"}
C -- no --> X2["ELengthMismatch"]
C -- yes --> D["decode_intents()"]
D --> E["for each intent"]
E --> F{"target chain =<br/>account chain?"}
F -- no --> X3["EWrongTargetChain"]
F -- yes --> G{"ACL entry for<br/>(source chain, sender)?"}
G -- no --> X4["ESenderNotInAcl"]
G -- yes --> H{"signature valid<br/>over message?"}
H -- no --> X5["EInvalidSignature"]
H -- yes --> I["verify_ptb_matches_intents()"]
I --> J{"every intent has<br/>a matching call?"}
J -- no --> X6["abort"]
J -- yes --> K["authenticated"]
| Step | Function | Lines | What it compares |
|---|---|---|---|
| Decode | decode_intent() |
460-501 | BCS layout of CrossChainIntent. Trailing bytes abort with EInvalidSignature (line 489). |
| Chain | verify_intent_signatures() |
265 | intent.target_chain_id against the account's chain id. |
| ACL | borrow_acl_entry() |
273, 284-287 | Entry for (source_chain_id, source_sender). |
| Message | compute_intent_message() |
275, 292-297 | Domain tag ++ account address ++ intent bytes. |
| Signature | verify_signature_with_entry() |
277, 301-309 | ed25519_verify or secp256k1_verify(…, 1) (SHA-256). |
| PTB | verify_ptb_matches_intents() |
312-325 | Each intent has a call in the PTB. |
| Call | call_matches_intent() |
374-445 | Package, module, function, argument count, type args, and for each argument: a pure input whose bytes equal the intent's. |
The order matters for debugging: a wrong chain id aborts before the ACL is read, and an ACL miss aborts before the signature is checked. The Move reference lists the same order with the abort codes.
Only pure inputs can match (call_matches_intent() requires each argument to be a pure input). That is
why object arguments are rejected: see
Why only pure arguments are matched.
Signing compatibility¶
The relayer and Move must build the same message from the same bytes.
| Piece | Move | Rust |
|---|---|---|
| Domain tag | INTENT_DOMAIN_TAG (line 70) |
INTENT_DOMAIN_TAG in src/bridge/intent.rs |
| Intent layout | decode_intent() |
CrossChainIntent::encode() |
| Message | compute_intent_message() |
signing_message(): raw tag, 32 raw address bytes, intent bytes |
| ed25519 | ed25519_verify over the message |
IntentSigner signs the raw message, not sign_secure |
| secp256k1 | secp256k1_verify(…, 1): SHA-256 of the message |
IntentSigner signs the SHA-256 digest |
| Arguments | Compared byte for byte with pure inputs | append_intent_call() passes the intent's bytes verbatim |
intent_bytes() in bridge_source produces the same layout, which
intent_bytes_match_the_decoder_layout (Move) and encode_matches_the_move_decoder_layout (Rust) pin.
secp256r1 keys are refused by the relayer before anything is signed.
bridge_target¶
record(source_chain_id, nonce, payload, ctx) emits Recorded with the arguments and
executed_by = ctx.sender(). Run through BridgeAA, executed_by is the account's address, which is
how a test shows the call ran as the account.
Events¶
| Event | Package | Emitted by |
|---|---|---|
CrossChainRequest |
bridge_source |
request() |
RequestAcknowledged |
bridge_source |
acknowledge(), acknowledge_pure() |
Recorded |
bridge_target |
record() |
Deprecated
The older abstract_account package and its aa_init / /api/SendAAPTB path predate
bridge_abstract_account. Use One-time bridge setup instead.
Configuration knobs¶
The packages have no configuration. The relayer side reads their ids from Bridge account and Acknowledgement variables.
Tests that pin the behaviour¶
Move unit tests live next to each package's sources, under tests/.
bridge_source_tests.move: create_config_freezes_with_given_chain_id,
request_stamps_config_chain_id_and_tx_sender, intent_bytes_match_the_decoder_layout,
intent_bytes_exclude_request_id, request_accepts_empty_args_and_type_args,
request_rejects_empty_target_module, request_rejects_empty_target_function,
acknowledge_stamps_config_chain_id_and_tx_sender,
acknowledge_is_independent_of_request_and_stays_off_the_intent,
acknowledge_pure_stamps_the_supplied_chain_id_and_tx_sender,
acknowledge_pure_and_acknowledge_emit_the_same_event.
bridge_abstract_account_tests.move:
| Area | Tests |
|---|---|
| Creation | create_rejects_zero_initial_acl_entries, create_rejects_mismatched_initial_acl_vector_lengths, create_seeds_initial_acl_entry, bootstrap_acl_entry_can_authenticate_without_ever_calling_add_acl_entry, create_sets_correct_chain_id, account_address_matches_uid_address |
| ACL | has_acl_entry_returns_false_when_absent, add_acl_entry_by_owner_succeeds, add_acl_entry_overwrites_existing_entry, add_acl_entry_rejects_all_zero_public_key, add_acl_entry_rejects_wrong_length_public_key, add_acl_entry_rejects_unsupported_scheme, add_acl_entry_by_non_owner_aborts, remove_acl_entry_by_owner_succeeds, remove_acl_entry_by_non_owner_aborts, remove_acl_entry_not_present_aborts |
| Rotation | rotate_auth_function_ref_by_owner_succeeds, rotate_auth_function_ref_by_non_owner_aborts |
| Authenticator | authenticator_rejects_intent_signature_length_mismatch, authenticator_rejects_empty_intents, authenticator_rejects_wrong_target_chain, authenticator_rejects_sender_not_in_acl, authenticator_rejects_invalid_signature, authenticator_rejects_malformed_intent_bytes, authenticator_rejects_no_matching_call, authenticator_rejects_a_call_carrying_an_object_argument, authenticator_accepts_real_signature_with_matching_call |
bridge_target_tests.move: record_emits_payload_and_tx_sender, record_accepts_empty_payload.