cw-auths

Crates.iocw-auths
lib.rscw-auths
version0.3.1
created_at2025-05-19 16:58:36.779023+00
updated_at2025-05-19 19:50:27.873321+00
descriptionAuthentication library for smart accounts of CosmWasm
homepage
repositoryhttps://github.com/MegaRockLabs/cw-auths
max_upload_size
id1680046
size90,985
Kromsten (kromsten)

documentation

README

cw-auths

Storage / Replay

The library is aim tp provide helpful primitives for verifying and then storing credentials in a secure and easy way

# first verify all the credentials and then store them stored in the storage
credential_data.save_cosmwasm(deps.api, deps.storage, &env, &info)?;

When replay attack protection is enabled, the library will enforce the message to include a contract address, a chain id and a nonce that should be equal to the current account number

After a successful verification an account contract must increment the nonce to prevent replay attacks

increment_account_number(deps.storage)?;

The library also provides a helper function to verify the signed actions which will verify the credentials and then increment the nonce automatically

verify_signed_actions(deps.api, deps.storage, &env, data)?;

Registries / Factories

In some cases you can want to use credemtials for accounts that are not yet created and therefire do not have an account number (unless instantiate2 is used).

In cases like that you can use address of a registry / factory contract in data to sign. Later after the account contract is created you can create a new Env object with overwritten contract address

let registry_env = Env {
    contract: ContractInfo { address: info.sender.clone() },
    ..env.clone()
};

data.save_cosmwasm(api, storage, &registry_env, &info)?;
Commit count: 11

cargo fmt