Commit Graph

13 Commits

Author SHA1 Message Date
Tutus Development c250c16e89 Add VPP (Vita Presence Protocol) to native Vita contract
Implement real-time proof-of-humanity presence tracking as OAuth 2.0 extension:

Native Contract Methods:
- recordPresence(sessionId, deviceHash): Record heartbeat for caller's Vita
- getPresence(tokenId): Get presence record with computed status
- getPresenceStatus(tokenId): Get computed status (offline/online/away/invisible)
- setPresenceVisibility(invisible): Toggle invisible mode
- getPresenceConfig(): Get VPP configuration values

State Types (pkg/core/state/vita.go):
- PresenceStatus enum: Offline, Online, Away, Invisible
- PresenceRecord: TokenID, LastHeartbeat, SessionID, DeviceHash, Status, Invisible
- PresenceConfig: PresenceWindow (60), AwayWindow (300), MinHeartbeatInterval (15),
  MaxHeartbeatInterval (60) - all in blocks (~seconds)

Security Features:
- Session and device hash must be exactly 32 bytes
- Rate limiting: Min 15 blocks between heartbeats
- Invisible mode: Heartbeats recorded but status hidden
- Caller must have active Vita token

Internal Methods for Cross-Contract Use:
- GetPresenceRecord, GetPresenceStatusInternal, IsOnline, IsPresent

Events:
- PresenceRecorded(tokenId, blockHeight, sessionId)
- PresenceVisibilityChanged(tokenId, invisible)

Tests (7 new):
- GetPresenceConfig, GetPresence_NonExistent, GetPresenceStatus_NonExistent
- RecordPresence_NoVita, RecordPresence_InvalidSession, RecordPresence_InvalidDevice
- SetPresenceVisibility_NoVita

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 17:01:59 +00:00
Tutus Development f006f1623c Native contracts complete - all tests passing 2025-12-27 15:45:47 +00:00
Tutus Development a63b3dcb70 Migrate from GitHub to git.marketally.com
Update all module paths and import statements from github.com/tutus-one
to git.marketally.com/tutus-one for self-hosted Git server migration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-27 09:54:31 -05:00
Tutus Development b63db20f34 Add Ancora audit logging and tutustest helpers
Ancora enhancements:
- Add audit logging integration for all operations
- Provider registration, data root updates, erasure operations
- getAuditLog query method for GDPR transparency

Test infrastructure:
- Add vitahelper package for registering test Vitas
- Add tutustest helpers: crosscontract, events, government, roles
- Fix DataTypePresence constant in Ancora test

State updates:
- Fix state_anchors TreeAlgorithm enum values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 01:40:21 -05:00
Tutus Development 3eaae08a38 Implement ADR-008 on-chain security features
Add three key security mechanisms for the Tutus blockchain:

1. Commit-Reveal for Investments (collocatio.go)
   - Two-phase investment pattern to prevent front-running attacks
   - User commits hash(amount || nonce || investor), waits 10 blocks,
     then reveals actual amount with nonce for verification
   - Methods: commitInvestment, revealInvestment, cancelCommitment
   - InvestmentCommitment state type with CommitmentStatus enum
   - Configurable delay (10 blocks) and reveal window (1000 blocks)

2. Whale Concentration Limits (collocatio.go)
   - Enforces max 5% (configurable) of opportunity pool per investor
   - Prevents wealth concentration in investment opportunities
   - Check performed in invest() method before accepting investment

3. Sybil Resistance Vesting (vita.go)
   - New Vita tokens have 30-day vesting period (2,592,000 blocks)
   - VestedUntil field added to Vita state struct
   - Methods: setVesting (committee), isFullyVested, getVestingInfo
   - Cross-contract methods: IsFullyVestedInternal, GetVestedUntil
   - Prevents mass creation of fake identities for manipulation

Documentation:
- Added docs/ADR-008-UI-Implementation-Guide.md for frontend developers
  with code examples, flow diagrams, and error handling guidance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 13:23:54 +00:00
Tutus Development 961c17a0cc Add Ancora native contract for off-chain data anchoring
Implement ADR-004 Phase 1 - the Ancora (Latin for "anchor") contract
provides Merkle root anchoring for off-chain data with proof verification:

Core Features:
- Data root management: Track Merkle roots per VitaID and DataType
  (Medical, Education, Investment, Documents, Custom)
- Provider registry: Committee-managed authorization for data providers
  with rate limiting and cooldown periods
- Proof verification: Verify Merkle proofs against anchored roots
  supporting SHA256, Keccak256, and Poseidon algorithms
- GDPR erasure: Right-to-be-forgotten workflow with pending/confirmed/denied
  status and configurable grace periods
- Data portability: Generate attestations for cross-system data transfer

Contract Methods:
- registerProvider/revokeProvider: Committee authorization for providers
- updateDataRoot: Anchor new Merkle root with version tracking
- verifyProof: Validate leaf inclusion against anchored root
- requestErasure/confirmErasure/denyErasure: GDPR erasure workflow
- generatePortabilityAttestation: Data portability support

Cross-Contract Integration:
- Vita: Identity verification via ExistsInternal/OwnerOfInternal
- Tutus: Committee authority for provider management

State Types (pkg/core/state/state_anchors.go):
- RootInfo: Merkle root metadata with version and algorithm
- ErasureInfo: GDPR erasure request tracking
- ProviderConfig: Authorized provider configuration
- StateAnchorsConfig: Global contract settings
- Enums: DataType, TreeAlgorithm, ErasureStatus

Contract ID: -27

Tests (15 test cases):
- Configuration and query tests
- Provider registration/revocation tests
- Authorization and error handling tests
- Data type and algorithm validation tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 12:42:05 +00:00
Tutus Development 32d12b5106 Normalize line endings in security remediation files
Convert CRLF to LF line endings in native contract and state files
modified during security remediation. Ensures consistent line endings
across Windows and Linux development environments.

Files normalized:
- pkg/core/native/*.go (15 files)
- pkg/core/state/*.go (3 files)
- devnotes.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 04:31:25 -05:00
Tutus Development 1b4a61fcf7 Add security remediation infrastructure and fixes
Implement comprehensive security infrastructure from Security-Remediation-Plan.md:

New Infrastructure Files:
- circuit_breaker.go (ARCH-001): Circuit breaker pattern for contract failures
  with Closed/Open/Half-Open state machine and emergency shutdown
- invariants.go (ARCH-003): Formal verification with 14 critical invariants
  and TLA+ specifications for runtime verification
- canary_deployment.go (ARCH-004): Feature flags with percentage-based rollout
  and auto-rollback on error rate threshold
- audit_logger.go (ARCH-005): Comprehensive audit logging with multi-index
  querying across 8 categories (Auth, Access, Data, Governance, etc.)
- config_registry.go (LOW-003): Configuration governance infrastructure
- event_archival.go (LOW-001): Event log archival with Merkle commitments
- validation.go (LOW-002): Common input validation constants and utilities
- role_registry_domain.go (CRIT-002): Domain-specific committee roles
  (Legal, Health, Education, Economy, Identity, Governance)

Contract Security Fixes:
- contract.go: Add HasDomainCommitteeAuthority to IRoleRegistry interface
- lex.go: Remove duplicate ErrReasonTooLong declaration
- salus.go, eligere.go, palam.go, pons.go, scire.go, tribute.go:
  Line ending normalization and security validation integration
- collocatio.go: Security validation for investment operations

State Type Updates:
- state/pons.go, state/salus.go, state/tribute.go: Line ending fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 09:06:14 +00:00
Tutus Development a18363ce0b Add Annos lifespan contract and Eligere voting age integration
Implement the Annos (Latin for "years") contract for tracking citizen
lifespan and age-based entitlements:

Annos Contract (pkg/core/native/annos.go):
- LifespanRecord tracks birth/death timestamps per Vita holder
- Age calculation from birthTimestamp (provided during registration)
- Life stages: Child (0-17), Youth (18-25), Adult (26-64), Elder (65+)
- Entitlement checks: isVotingAge, isAdult, isRetirementAge, isAlive
- recordDeath method (committee only) for mortality tracking
- Cross-contract methods for internal use by other contracts

State Types (pkg/core/state/annos.go):
- LifeStage, LifespanStatus enums
- LifespanRecord, AnnosConfig structs with serialization

Vita Integration:
- Updated register() to accept birthTimestamp parameter
- birthTimestamp is the actual birth date, NOT the mint date
- Calls Annos.RegisterBirthInternal() after minting Vita
- Enables existing adults to register with their real birth date

Eligere Integration:
- Added Annos IAnnos field to Eligere struct
- Added voting age check in vote() method
- Voters must be 18+ (configurable via AnnosConfig.VotingAge)
- New ErrUnderVotingAge error for underage voters

Contract Wiring:
- Added eligere.Annos = annos in NewDefaultContracts()
- Contract ID: -26 (next after Collocatio)

Tests (pkg/core/native/native_test/annos_test.go):
- 17 comprehensive tests covering all Annos functionality
- Age-based tests for Child, Youth, Adult life stages
- Note: Elder test skipped (uint64 can't represent pre-1970 dates)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 00:55:29 +00:00
Tutus Development 64c682cd68 Rename NEO to Annos and GAS to Lub native contracts
Rename the core governance and utility tokens to reflect Tutus
blockchain's identity-centric design:

- NEO -> Annos (Latin for "years" - governance token tied to Vita)
- GAS -> Lub (lubrication - utility/fee token)

File renames:
- native_neo.go -> native_annos.go
- native_gas.go -> native_lub.go
- native_neo_candidate.go -> native_annos_candidate.go

Struct/interface renames:
- NEO struct -> Annos, INEO -> IAnnos
- GAS struct -> Lub, IGAS -> ILub

Constants updated:
- nativenames: Neo="NeoToken" -> Annos="AnnosToken"
- nativenames: Gas="GasToken" -> Lub="LubToken"
- NEOTotalSupply -> AnnosTotalSupply
- GASFactor -> LubFactor

Regenerated nativehashes for new manifest names.

Updated all native contracts, blockchain.go, test files,
CLI wallet, and RPC client packages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 11:34:42 +00:00
Tutus Development 30b3be30ce Add Eligere native contract for democratic voting
Implement the Eligere (Latin for "to choose/elect") contract providing
democratic governance infrastructure for citizens:

Core Features:
- Proposal lifecycle: Draft -> Active -> Passed/Rejected -> Executed
- One-person-one-vote via Vita token (soul-bound identity)
- Configurable quorum (default 10%) and thresholds (50%/67%)
- Execution delay for passed proposals before implementation

Contract Methods:
- createProposal: Create proposals with categories (Law, Investment, etc)
- vote: Cast votes (Yes/No/Abstain) with Vita verification
- tallyVotes: Finalize voting after deadline with quorum checks
- executeProposal: Execute passed proposals after delay
- Query methods: getProposal, getVote, hasVoted, getConfig

Cross-Contract Integration:
- Vita: Add GetTotalTokenCount() for quorum calculations
- Lex: Add RatifyAmendmentInternal() for law amendment execution
- Wire Eligere into blockchain.go with proper validation

Test Updates:
- Update Vita suspend test to use Lex liberty restriction (due process)
- Update management tests for Federation/Eligere hardfork timing
- Add Vita registration to VTS tests for property rights checks
- Update NEP17 contracts list to include VTS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 06:30:43 +00:00
Tutus Development 96f77823e5 Integrate Lex rights enforcement into VTS and Vita contracts
Wire Lex contract into core contracts for constitutional rights enforcement:

VTS Integration:
- Add Lex dependency to VTS struct
- Add property rights check in transferUnrestricted() - blocks transfers
  if sender's RightProperty is restricted via Lex
- Add property rights check in spend() - blocks spending if restricted

Vita Integration:
- Add Lex dependency to Vita struct
- Add liberty rights check in suspend() - requires valid liberty
  restriction order from Lex before suspension (due process)
- Add liberty rights check in revoke() - requires restriction order
  before permanent revocation

Blockchain Integration:
- Add lex field to Blockchain struct
- Add Lex initialization and validation in NewBlockchain()

Contract Wiring:
- Wire vts.Lex = lex for property rights enforcement
- Wire vita.Lex = lex for liberty rights enforcement

This ensures constitutional rights are automatically enforced:
- No property transfers without property rights
- No identity suspension/revocation without judicial due process

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 05:43:31 +00:00
Tutus Development f03564d676 Add free GAS for Vita holders with cross-chain fee splitting
Rename PersonToken to Vita (soul-bound identity token) and implement
fee exemption system for citizens:

- Add Federation native contract for cross-chain Vita coordination
  - Visitor registry for Vita holders from other chains
  - Configurable visiting fee percentage (default 50%)
  - Inter-chain debt tracking for settlement between chains

- Modify GAS contract to burn fees from Treasury for Vita holders
  - Local Vita: 100% paid by local Treasury
  - Visiting Vita: Split between local Treasury and inter-chain debt
  - Deficit tracking when Treasury is underfunded

- Update mempool and blockchain to skip fee checks for Vita exempt users
  - Add IsVitaFeeExempt() to Feer interface
  - Modify verifyAndPoolTx() to allow zero-fee transactions

- Rename PersonToken -> Vita across codebase
  - Update state, native contract, and tests
  - Maintain same functionality with clearer naming

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 04:27:55 +00:00