Skip to main content

Account System & Identity Framework

The Shamwari Account System & Identity Framework (nxt.account.Account) provides the core identity, access control, balance management, and cryptographic primitives built directly into the Shamwari ledger runtime.

By housing identity management, account properties, forging lease balance transfers, and domain resolution directly within nxt.account—rather than relying on external virtual machine contracts—Shamwari achieves post-quantum cryptographic security, human-readable domain naming, granular institutional account typing, and zero-overhead account state tracking across BetaChains.


Core Capabilities & Architecture

  • Post-Quantum Cryptographic Identity: Hybrid public key infrastructure (ShamwariPublicKey) combining CRYSTALS-Kyber lattice-based key encapsulation (KyberPublicKey) and CRYSTALS-Dilithium digital signatures (DilithiumPublicKey).
  • Multi-Tier Account Categorization: Native account profiling (AccountType) with 16 distinct operational designations (e.g., BANK, MERCHANT, SAVINGS, AUTONOMOUS, GOVERNMENT).
  • Protocol-Native Domain Registry (.shamwari.network): Human-readable domain name registration, transfer, renewal, and search indexed directly on-chain (public.account_domain).
  • Autonomous Account Control & Recursive Delegation: Enables programmatic AI agents (AUTONOMOUS) to act under controller account permissions, featuring cycle-protected effective type resolution.
  • Forging Balance Leasing (AccountLease): Allows accounts to lease forging weight to pool operators or lessees without transferring balance ownership or spending rights.
  • Scoped Account Property Registry (AccountProperty): On-chain key-value tagging mechanism allowing account owners and third-party setters to attach verifiable metadata to target accounts.
  • Multi-Holding Balance Management: Dual-layer balance engines for digital assets/tokens (AccountTotem) and monetary units (AccountCurrency), tracking both confirmed and unconfirmed balances.

Cryptographic Identity & Public Key Infrastructure

Shamwari accounts bypass traditional ECDSA/secp256k1 curves in favor of post-quantum lattice cryptography.

┌────────────────────────────────────────────────────────┐
│ ShamwariPublicKey │
├───────────────────────────┬────────────────────────────┤
│ KyberPublicKey │ DilithiumPublicKey │
│ (Key Encapsulation / KEM) │ (Quantum-Resistant Sign) │
└─────────────┬─────────────┴──────────────┬─────────────┘
│ │
└─────────────┬──────────────┘


Combined Public Key Bytes


SHA-256 Digest


64-bit Long Account ID

1. Account ID Derivation Formula

An account's globally unique 64-bit integer identifier (AccountIdAccountId) is derived deterministically from its combined quantum-resistant public key bytes:

AccountId=Convert.fullHashToId(SHA-256(ShamwariPublicKey.getCombinedPublicKey()))AccountId = \text{Convert.fullHashToId}\Big(\text{SHA-256}(\text{ShamwariPublicKey.getCombinedPublicKey}())\Big)

Where:

  • ShamwariPublicKey.getCombinedPublicKey()=KyberPublicKey.getY()DilithiumPublicKey.getPublicKey()\text{ShamwariPublicKey.getCombinedPublicKey}() = \text{KyberPublicKey.getY}() \parallel \text{DilithiumPublicKey.getPublicKey}().
  • fullHashToId()\text{fullHashToId}() extracts the first 8 bytes of the 32-byte digest into a signed 64-bit integer representation.

Account Classifications & Autonomous Control (AccountType)

Shamwari enforces native account classifications via AccountType codes, enabling the ledger to restrict or allow specific operations (such as merchant payment processing or savings deposits) based on account roles:

1. Classification Matrix

CodeEnum ValueDescription & Purpose
1NONEUnclassified standard account. Default state upon initial key publication.
2BANKRegulated banking institution authorized for fiat issuer and clearing operations.
3FSPFinancial Service Provider handling remittance, micro-credit, and brokerage.
4MFIMicrofinance Institution focused on micro-credit and rural group lending.
5MERCHANTVerified point-of-sale or online merchant permitted to receive business payments.
6BUSINESSCommercial corporate account with bulk payroll and supply chain capabilities.
7SAVINGSRestricted accumulation account subject to deposit filtering and vault time-locks.
8DEVELOPERSoftware architect or smart contract deployer profile.
9PERSONALIndividual retail user account.
10AUTONOMOUSProgrammatic AI agent or automated service account operating under delegated control.
11NGONon-Governmental Organization driving targeted social subsidy distribution.
12GOVERNMENTSovereign state entity, tax collector, or municipal treasury authority.
13ACADEMICEducational institution issuing digital certificates and credentials.
14ORGANIZATIONCo-operative, industry association, or non-profit body.
15SOLE_TRADERRegistered individual business operator or informal vendor.
16AGENTCash-in / cash-out liquidity agent or banking representative.

2. Recursive Effective Type Resolution

When an account is flagged as AUTONOMOUS, its operational capabilities default to its controlling account's effective type. To prevent infinite loops in nested control chains, Account.resolveEffectiveType() uses a visitation set (VV) to detect cyclic delegation:

private AccountType resolveEffectiveType(Set<Long> visited) {
if (!visited.add(this.id)) return AccountType.AUTONOMOUS; // Cycle guard
AutonomousAccountControl ctrl = AutonomousAccountControl.get(this.id);
if (ctrl == null) return AccountType.AUTONOMOUS;
Account controller = Account.getAccount(ctrl.getControlAccountId());
if (controller == null) return AccountType.AUTONOMOUS;
AccountInfo controllerInfo = controller.getAccountInfo();
AccountType controllerRaw = (controllerInfo == null) ? AccountType.NONE : controllerInfo.getAccountType();
if (controllerRaw != AccountType.AUTONOMOUS) return controllerRaw;
return controller.resolveEffectiveType(visited);
}

Data Model & Relational Schema

Account identity, public keys, holdings, leased forging weights, properties, and domain names are indexed in versioned relational database tables.

1. Primary Account Entities

TablePrimary / Composite KeyEntity ClassDescription
public.accountid, heightAccountMaster account state, active lessee IDs, and height markers.
public.public_keyaccount_id, heightPublicKeyCryptographic public key repository storing Kyber and Dilithium public keys.
public.account_infoaccount_id, heightAccountInfoProfile metadata (URLs, README, gender, DOB, nationality, peer address).
public.account_domaindomain, heightAccountDomainProtocol-native .shamwari.network domain handles and expiration records.
public.account_propertyid, heightAccountPropertyKey-value properties assigned to accounts by recipient or external setters.
public.account_leaselessor_id, heightAccountLeaseActive and scheduled forging balance lease parameters.
public.account_totemaccount_id, totem_idAccountTotemConfirmed and unconfirmed digital asset/token holdings (QNTQNT).
public.account_currencyaccount_id, currency_idAccountCurrencyConfirmed and unconfirmed monetary unit holdings (QNTQNT).
public.account_subscriptionaccount_id, service_idAccountSubscriptionValidated subscription entitlement records and expiry heights.

2. Public Key Record (public.public_key)

FieldTypeDescription
account_idlongUnique 64-bit account identifier.
kyber_public_keybyte[]Public key byte array for CRYSTALS-Kyber key encapsulation.
dilithium_public_keybyte[]Public key byte array for CRYSTALS-Dilithium quantum-safe digital signatures.
heightintBlock height at which the public key was published.
latestbooleanFlag indicating the current active version.

3. Account Information Schema (public.account_info)

FieldTypeDescription
account_idlongAssociated account ID.
websiteVARCHAROfficial website URL.
displayVARCHARPublic display handle or name.
read_meVARBINARYEncrypted or plain text account overview payload.
typebyteNumerical code mapping to AccountType enum (1 to 161 \text{ to } 16).
genderVARCHAROptional profile gender string.
date_of_birthVARCHARISO date string (YYYY-MM-DD) for age verification.
nationalityVARCHARISO country code or nationality description.
peer_addressVARCHARIP address or hostname of dedicated network node.
heightintBlock height of profile update.

4. Account Domain Schema (public.account_domain)

FieldTypeDescription
domainVARCHARUnique domain prefix (e.g., "treasury" for "treasury.shamwari.network").
domain_lowerVARCHARLowercase normalized domain string for case-insensitive lookup.
account_idlongCurrent owning account ID bound to the domain.
timestampintEpoch timestamp of last domain registration, transfer, or renewal.
expiration_heightintBlock height at which the domain ownership expires unless renewed.
heightintBlock height of record update.

5. Account Property Schema (public.account_property)

FieldTypeDescription
idlongUnique transaction ID of the property creation.
chainintBetaChain identifier context where the property was set.
recipient_idlongAccount ID receiving the property tag.
setter_idlongAccount ID that authored the property (equals recipient_id if self-set).
propertyVARCHARProperty key name (max 32 bytes32 \text{ bytes}).
valueVARCHARProperty string value (max 160 bytes160 \text{ bytes}).
heightintBlock height when property was established or modified.

Domain Registration & Lifecycle (.shamwari.network)

Accounts can register human-readable handles ending in .shamwari.network. Domains function as aliases for 64-bit account IDs across transaction forms and API endpoints.

┌─────────────────────────────────────────────────┐
│ registerDomain() / Initial Name Claim │
└────────────────────────┬────────────────────────┘


┌─────────────────────────────────────────────────┐
│ ACTIVE DOMAIN │
│ expirationHeight = currentHeight + 2,628,000 │
└────────┬───────────────┬───────────────┬────────┘
│ │ │
renewDomain() │ │ │ transferDomain()
(Extends Height) │ │ │ (Reassigns Owner)
▼ │ ▼
┌────────────────┐ │ ┌────────────────┐
│ Height Extended│ │ │ New Owner ID │
└────────────────┘ │ └────────────────┘

Height Reached │
(height >= expiry) │

┌─────────────────────────────────────────────────┐
│ EXPIRED DOMAIN │
│ (Available for New Name Claim) │
└─────────────────────────────────────────────────┘

1. Domain Validity & Expiration Formula

Domains are granted for fixed block windows equivalent to 1 calendar year (365 days365 \text{ days} assuming 12 second12 \text{ second} block time):

DOMAIN_VALIDITY_BLOCKS=7,200×365=2,628,000 blocks\text{DOMAIN\_VALIDITY\_BLOCKS} = 7,200 \times 365 = 2,628,000 \text{ blocks}

When a domain is initialised or renewed, its new expiration height is computed as:

ExpirationHeightnew=ExpirationHeightcurrent+2,628,000 blocks\text{ExpirationHeight}_{\text{new}} = \text{ExpirationHeight}_{\text{current}} + 2,628,000 \text{ blocks}


Consensus Balance Leasing Engine (AccountLease)

To support proof-of-stake consensus without forcing accounts to move funds into custody or cold-storage pools, Shamwari provides native balance leasing via AccountLease.

1. Leasing Parameters

  • Lessor: Account granting forging weight.
  • Lessee: Account receiving forging weight to generate blocks on BetaChains.
  • Leasing Period: Defined by current_leasing_height_from and current_leasing_height_to.

2. State Transitions

The core ledger processor evaluates leasing transitions at the start of each block during AFTER_BLOCK_APPLY:

ActiveLesseeId(height)={currentLesseeIdif currentLeasingHeightFromheightcurrentLeasingHeightTonextLesseeIdif height=nextLeasingHeightFromnullif height>currentLeasingHeightTonextLesseeId=null\text{ActiveLesseeId}(\text{height}) = \begin{cases} \text{currentLesseeId} & \text{if } \text{currentLeasingHeightFrom} \le \text{height} \le \text{currentLeasingHeightTo} \\ \text{nextLesseeId} & \text{if } \text{height} = \text{nextLeasingHeightFrom} \\ \text{null} & \text{if } \text{height} > \text{currentLeasingHeightTo} \land \text{nextLesseeId} = \text{null} \end{cases}


Profile Mathematics & Calculations

1. Age Calculation from Date of Birth

For compliant user accounts (AccountInfo), age is calculated dynamically using ISO calendar periods:

Age=Period.between(LocalDate.parse(dateOfBirth),LocalDate.now()).getYears()\text{Age} = \text{Period.between}(\text{LocalDate.parse}(\text{dateOfBirth}), \text{LocalDate.now}()).\text{getYears}()

If dateOfBirth is null or unparseable, getAge() returns 1-1.


2. Double-Spending Guard

When modifying account balances (AccountTotem or AccountCurrency), the engine verifies that confirmed and unconfirmed quantities satisfy positivity constraints:

checkBalance(AccountId,Qconfirmed,Qunconfirmed):Qconfirmed0Qunconfirmed0\text{checkBalance}(AccountId, Q_{\text{confirmed}}, Q_{\text{unconfirmed}}): \quad Q_{\text{confirmed}} \ge 0 \land Q_{\text{unconfirmed}} \ge 0

If either value drops below zero, a DoubleSpendingException is raised, rolling back the transaction.


Event Listener Matrix

The Account System exposes event listeners across identity, domain, leasing, subscription, and loan modules:

Event EnumTrigger Condition
TOTEM_BALANCEConfirmed asset balance updated for an account.
UNCONFIRMED_TOTEM_BALANCEUnconfirmed pending asset balance adjusted.
CURRENCY_BALANCEConfirmed currency balance modified.
UNCONFIRMED_CURRENCY_BALANCEUnconfirmed pending currency balance adjusted.
LEASE_SCHEDULEDFuture forging balance lease scheduled by lessor.
LEASE_STARTEDScheduled lease height reached; forging weight transferred.
LEASE_ENDEDLeasing period expired; forging weight restored to lessor.
SET_PROPERTYAccount property assigned or modified.
DELETE_PROPERTYAccount property deleted.
ACCOUNT_DOMAIN_REGISTRATIONNew .shamwari.network domain handle registered.
ACCOUNT_DOMAIN_DEREGISTRATIONDomain handle revoked or deregistered.
ACCOUNT_DOMAIN_TRANSFERDomain handle transferred to recipient account ID.
ACCOUNT_DOMAIN_RENEWALDomain handle renewed for 2,628,000 blocks2,628,000 \text{ blocks}.
ACCOUNT_DOMAIN_EXPIRATIONDomain handle expired and returned to available registry.
ACCOUNT_SUBSCRIPTION_CREATIONAccess entitlement extended or created for service ID.

APIDescription
GetAccountGet account details
GetBalanceGet account balance
GetEffectiveBalanceGet effective balance
GetGuaranteedBalanceGet guaranteed balance
GetAccountPublicKeyGet account public key
RegisterAccountDomainRegister domain
RenewAccountDomainRenew domain
TransferAccountDomainTransfer domain
DeregisterAccountDomainDeregister domain
SetAccountPropertySet account property
DeleteAccountPropertyDelete account property
AddAccountPermissionAdd account permission
RemoveAccountPermissionRemove account permission
GetAccountTotemsGet account Totems
GetAccountCurrencyLoansGet account currency loans

Primary Institutional Use Cases

  • Post-Quantum Treasury Management: Enterprise treasuries and central banks operate accounts protected against quantum computing attacks using hybrid Kyber/Dilithium keys.
  • Human-Readable Banking Handles: Users send fiat and platform assets directly to human-readable domain handles (e.g., payroll.shamwari.network) instead of cryptographic public key hashes.
  • Delegated AI Agent Commerce: Financial institutions deploy AUTONOMOUS accounts for AI trading bots and automated agents, binding them to corporate account policies while isolating risk.
  • Non-Custodial Consensus Staking: High-net-worth accounts and institutional holders lease forging weight (AccountLease) to validator nodes, earning block rewards without transferring token custody.