Skip to content

Commit ee0fab8

Browse files
committed
fix comments
1 parent 32cb38e commit ee0fab8

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

account_auth_example/sources/account_auth_example.move

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ module account_auth_example::main_m;
22

33
use iota::auth_context::AuthContext;
44

5-
public struct AUTH_ARG_VALUE has drop {}
5+
public struct AUTH_SOME_AUTHENTICATE_FN has drop {}
66

7-
public fun arg_value(_val: u8, _auth_ctx: &AuthContext, _ctx: &TxContext) {}
7+
// WON'T BUILD WITH THESE
8+
// public struct AUTH_FAIL has drop {}
9+
// public struct AUTH_NOT_AUTHENTICATE has drop {}
10+
11+
public fun some_authenticate_fn(_val: u8, _auth_ctx: &AuthContext, _ctx: &TxContext) {}
12+
13+
public fun not_authenticate(_val: u8, _ctx: &TxContext) {}

account_auth_example/tests/account_auth_example_test.move

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#[test_only]
22
module account_auth_example::account_auth_example_tests;
33

4-
use account_auth_example::main_m::AUTH_ARG_VALUE;
4+
use account_auth_example::main_m::AUTH_SOME_AUTHENTICATE_FN;
55
use iota::account::create_auth_info_v1_fotw;
66

77
public struct NOT_AOTW has drop {}
88

9-
// WON'T BUILD
10-
// public struct AUTH_FAIL has drop {}
11-
129
#[test]
1310
fun aotw_success() {
14-
create_auth_info_v1_fotw<AUTH_ARG_VALUE>();
11+
create_auth_info_v1_fotw<AUTH_SOME_AUTHENTICATE_FN>();
1512
}
1613

1714
#[test, expected_failure]

iota-execution/latest/iota-verifier/src/authenticate_one_time_witness_verifier.rs

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
// Copyright (c) 2025 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

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:
916
//!
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
1725
use iota_types::{
1826
Identifier,
1927
error::ExecutionError,
2028
move_package::{FnInfoMap, is_test_fun},
2129
};
2230
use move_binary_format::file_format::{CompiledModule, DatatypeHandle, SignatureToken};
23-
use move_core_types::{ident_str, identifier::IdentStr};
2431

2532
use crate::{
2633
account_auth_verifier::verify_authenticate_func,
@@ -30,18 +37,7 @@ use crate::{
3037

3138
pub const AOTW_PREFIX: &str = "AUTH_"; // authenticate one-time witness prefix
3239

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.
4541
pub fn verify_module(
4642
module: &CompiledModule,
4743
fn_info_map: &FnInfoMap,

0 commit comments

Comments
 (0)