create_signer - [mainnet]
Provides a common place for exporting create_signer
across the Aptos Framework.
To use create_signer, add the module below, such that:
friend aptos_framework::friend_wants_create_signer
where friend_wants_create_signer
is the module that needs create_signer
.
Note, that this is only available within the Aptos Framework.
This exists to make auditing straight forward and to limit the need to depend on account to have access to this.
Functions
create_signer
public(friend) fun create_signer(addr: address): signer
Implementation
public(friend) native fun create_signer(addr: address): signer;
Specification
High-level Requirements
No. | Requirement | Criticality | Implementation | Enforcement |
---|---|---|---|---|
1 | Obtaining a signer for an arbitrary account should only be available within the Aptos Framework. | Critical | The create_signer::create_signer function only allows friend modules to retrieve the signer for an arbitrarily address. | Enforced through function visibility. |
2 | The account owner should have the ability to create a signer for their account. | Medium | Before an Account resource is created, a signer is created for the specified new_address, and later, the Account resource is assigned to this signer. | Enforced by the move vm. |
3 | An account should only be able to create a signer for another account if that account has granted it signing capabilities. | Critical | The Account resource holds a signer_capability_offer field which allows the owner to share the signer capability with other accounts. | Formally verified via AccountContainsAddr. |
4 | A signer should be returned for addresses that are not registered as accounts. | Low | The signer is just a struct that wraps an address, allows for non-accounts to have a signer. | Formally verified via create_signer. |
Module-level Specification
pragma verify = true;pragma aborts_if_is_strict;
create_signer
public(friend) fun create_signer(addr: address): signer
Convert address to singer and return.
pragma opaque;aborts_if [abstract] false;ensures [abstract] signer::address_of(result) == addr;ensures [abstract] result == spec_create_signer(addr);
fun spec_create_signer(addr: address): signer;