1
1
// Copyright (c) 2025 IOTA Stiftung
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- //! A module can define a list of authenticate functions that can be used
5
- //! to authenticate an account. This list is private to the module and
6
- //! cannot be modified by other modules.
7
- //! The list is defined as a constant vector of vector<u8> where each inner
8
- //! vector<u8> is the UTF-8 bytes of the function name.
4
+ //! A module can define a several Authenticate One Time Witnesses (AOTW). An
5
+ //! AOTW is a type that is never instantiated, and this property is enforced by
6
+ //! the system.
7
+ //! We define an authenticate one-time witness type as a struct type that has
8
+ //! the name starting with a predefined prefix followed by the name of an
9
+ //! authenticate function in capital letters, and possessing certain special
10
+ //! properties specified below (please note that by convention, "regular" struct
11
+ //! type names are expressed in camel case).
12
+ //! In other words, if a module defines a struct type whose name is starting
13
+ //! with the predefined AOTW prefix and has no fields, then this type MUST
14
+ //! possess these special properties, otherwise the module definition will be
15
+ //! considered invalid and will be rejected by the validator:
9
16
//!
10
- //! The authenticate functions must be defined in the same module as the
11
- //! constant.
12
- //! The module's `init` function must call
13
- //! `iota::account::publish_authenticate_registry` exactly once, passing the
14
- //! constant as the argument. The `publish_authenticate_registry` function is
15
- //! responsible for registering the authenticate functions and is defined in the
16
- //! `iota::account`.
17
+ //! - it has a struct name where the prefix is followed by the name of a
18
+ //! function in capital letters:
19
+ //! - this function MUST be found in the same module;
20
+ //! - this function MUST be a valid authenticate function;
21
+ //! - it has only one ability: drop
22
+ //! - it has only one arbitrarily named field of type boolean or it is empty
23
+ //! - its definition does not involve type parameters
24
+ //! - it is never instantiated anywhere in its defining module
17
25
use iota_types:: {
18
26
Identifier ,
19
27
error:: ExecutionError ,
20
28
move_package:: { FnInfoMap , is_test_fun} ,
21
29
} ;
22
30
use move_binary_format:: file_format:: { CompiledModule , DatatypeHandle , SignatureToken } ;
23
- use move_core_types:: { ident_str, identifier:: IdentStr } ;
24
31
25
32
use crate :: {
26
33
account_auth_verifier:: verify_authenticate_func,
@@ -30,18 +37,7 @@ use crate::{
30
37
31
38
pub const AOTW_PREFIX : & str = "AUTH_" ; // authenticate one-time witness prefix
32
39
33
- pub const ACCOUNT_MODULE : & IdentStr = ident_str ! ( "account" ) ;
34
- pub const PUBLISH_AUTHENTICATE_REGISTRY_FN_NAME : & IdentStr =
35
- ident_str ! ( "publish_authenticate_registry" ) ;
36
-
37
- /// Checks if the module conforms to the authenticate functions rules only if it
38
- /// has a call instruction to the `0x2::account::publish_authenticate_registry`
39
- /// function within the `init` function.
40
- ///
41
- /// If the module does not have such call instruction, then it is considered to
42
- /// not use authenticate functions and thus the module is considered valid.
43
- /// If the module does have such call instruction, then it must conform to the
44
- /// rules.
40
+ /// Checks if the module conforms to the authenticate one time witness rules.
45
41
pub fn verify_module (
46
42
module : & CompiledModule ,
47
43
fn_info_map : & FnInfoMap ,
0 commit comments