Module 0x2::authenticator_state
- Resource
AuthenticatorState
- Struct
AuthenticatorStateInner
- Struct
JWK
- Struct
JwkId
- Struct
ActiveJwk
- Constants
- Function
active_jwk_equal
- Function
jwk_equal
- Function
jwk_id_equal
- Function
string_bytes_lt
- Function
jwk_lt
- Function
create
- Function
load_inner_mut
- Function
load_inner
- Function
check_sorted
- Function
update_authenticator_state
- Function
deduplicate
- Function
expire_jwks
- Function
get_active_jwks
use 0x1::option;
use 0x1::string;
use 0x1::u64;
use 0x2::dynamic_field;
use 0x2::object;
use 0x2::transfer;
use 0x2::tx_context;
Resource AuthenticatorState
Singleton shared object which stores the global authenticator state. The actual state is stored in a dynamic field of type AuthenticatorStateInner to support future versions of the authenticator state.
struct AuthenticatorState has key
Fields
Struct AuthenticatorStateInner
struct AuthenticatorStateInner has store
Fields
Struct JWK
Must match the JWK struct in fastcrypto-zkp
struct JWK has copy, drop, store
Fields
Struct JwkId
Must match the JwkId struct in fastcrypto-zkp
struct JwkId has copy, drop, store
Fields
Struct ActiveJwk
struct ActiveJwk has copy, drop, store
Fields
Constants
Sender is not @0x0 the system address.
const ENotSystemAddress: u64 = 0;
const CurrentVersion: u64 = 1;
const EJwksNotSorted: u64 = 2;
const EWrongInnerVersion: u64 = 1;
Function active_jwk_equal
fun active_jwk_equal(a: &authenticator_state::ActiveJwk, b: &authenticator_state::ActiveJwk): bool
Implementation
Function jwk_equal
fun jwk_equal(a: &authenticator_state::JWK, b: &authenticator_state::JWK): bool
Implementation
Function jwk_id_equal
fun jwk_id_equal(a: &authenticator_state::JwkId, b: &authenticator_state::JwkId): bool
Implementation
Function string_bytes_lt
fun string_bytes_lt(a: &string::String, b: &string::String): bool
Implementation
Function jwk_lt
fun jwk_lt(a: &authenticator_state::ActiveJwk, b: &authenticator_state::ActiveJwk): bool
Implementation
Function create
Create and share the AuthenticatorState object. This function is call exactly once, when the authenticator state object is first created. Can only be called by genesis or change_epoch transactions.
fun create(ctx: &tx_context::TxContext)
Implementation
Function load_inner_mut
fun load_inner_mut(self: &mut authenticator_state::AuthenticatorState): &mut authenticator_state::AuthenticatorStateInner
Implementation
Function load_inner
fun load_inner(self: &authenticator_state::AuthenticatorState): &authenticator_state::AuthenticatorStateInner
Implementation
Function check_sorted
fun check_sorted(new_active_jwks: &vector<authenticator_state::ActiveJwk>)
Implementation
Function update_authenticator_state
Record a new set of active_jwks. Called when executing the AuthenticatorStateUpdate system transaction. The new input vector must be sorted and must not contain duplicates. If a new JWK is already present, but with a previous epoch, then the epoch is updated to indicate that the JWK has been validated in the current epoch and should not be expired.
fun update_authenticator_state(self: &mut authenticator_state::AuthenticatorState, new_active_jwks: vector<authenticator_state::ActiveJwk>, ctx: &tx_context::TxContext)
Implementation
Function deduplicate
fun deduplicate(jwks: vector<authenticator_state::ActiveJwk>): vector<authenticator_state::ActiveJwk>
Implementation
Function expire_jwks
fun expire_jwks(self: &mut authenticator_state::AuthenticatorState, min_epoch: u64, ctx: &tx_context::TxContext)
Implementation
Function get_active_jwks
Get the current active_jwks. Called when the node starts up in order to load the current JWK state from the chain.
fun get_active_jwks(self: &authenticator_state::AuthenticatorState, ctx: &tx_context::TxContext): vector<authenticator_state::ActiveJwk>