Skip to content

nymos-xyz/nym-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NymScript Language

A privacy-preserving smart contract language for the Nym blockchain platform.

Features

🔒 Privacy-First Design

  • Privacy annotations: @private, @secret, @anonymous, @obfuscated
  • Zero-knowledge proofs: Automatic ZK-STARK and SNARK generation
  • Encrypted computation: Homomorphic encryption and secure multi-party computation
  • Anonymous function calls: Mix network routing for contract interactions
  • Timing attack resistance: @constant_time execution guarantees

🛡️ Quantum-Resistant Cryptography

  • ML-DSA signatures: Post-quantum digital signatures
  • ML-KEM encryption: Quantum-safe key encapsulation
  • SHA-3 family: Keccak-based hashing functions
  • Commitment schemes: Privacy-preserving commitments and reveals

💻 Smart Contract Features

  • Contract deployment: Automated deployment with verification
  • State management: Privacy-preserving state storage and updates
  • Event system: Anonymous and encrypted event emissions
  • Gas optimization: Efficient execution with privacy guarantees

Quick Start

Installation

cargo build --release

Basic Contract Example

contract PrivacyToken {
    @private
    mapping(address => uint256) private balances;
    
    @anonymous
    event Transfer(address indexed from, address indexed to, uint256 value);
    
    @secret
    function transfer(@anonymous address to, @encrypted uint256 amount) public {
        require(balances[msg.sender] >= amount, "Insufficient balance");
        
        balances[msg.sender] -= amount;
        balances[to] += amount;
        
        emit Transfer(msg.sender, to, amount);
    }
    
    @private
    function getBalance(@anonymous address account) public view returns (uint256) {
        return balances[account];
    }
}

Compilation

nymscript compile --input contract.nym --output contract.wasm

Deployment

nymscript deploy --contract contract.wasm --network testnet

Privacy Features

Privacy Annotations

  • @private: Encrypts data with automatic key management
  • @secret: Requires zero-knowledge proofs for execution
  • @anonymous: Routes calls through mix networks
  • @obfuscated: Obfuscates access patterns
  • @constant_time: Ensures timing attack resistance
  • @mixing(rounds: N): Specifies mix network routing rounds

Cryptographic Primitives

  • zkproof(): Generate zero-knowledge proofs
  • commit()/reveal(): Commitment-reveal schemes
  • encrypt()/decrypt(): Privacy-preserving encryption
  • hash(), sha256(), sha3(): Cryptographic hashing
  • generate_stealth_address(): Anonymous addresses

Privacy Types

  • PrivateUint256: Encrypted integer type
  • SecretBytes32: Secret byte array
  • AnonymousAddress: Anonymous address type
  • EncryptedString: Encrypted string type
  • ZKProof: Zero-knowledge proof type
  • Commitment: Cryptographic commitment
  • StealthAddress: Stealth address type

Development

Building

cargo build

Testing

cargo test

Documentation

cargo doc --open

Architecture

Compiler Pipeline

  1. Lexical Analysis: Tokenization with privacy keyword recognition
  2. Parsing: AST generation with privacy annotations
  3. Privacy Analysis: Vulnerability detection and optimization
  4. Code Generation: WASM bytecode with privacy guarantees
  5. Optimization: Gas and privacy optimizations

Privacy Guarantees

  • Confidentiality: Data encryption and access control
  • Anonymity: Mix network routing and stealth addresses
  • Unlinkability: Transaction graph privacy
  • Timing Safety: Constant-time execution patterns
  • Metadata Privacy: Minimal information leakage

Integration

Nym Blockchain

  • Native integration with Nym consensus mechanism
  • Quantum-resistant cryptography throughout
  • Privacy-preserving execution environment

Development Tools

  • VS Code extension with privacy analysis
  • Testing framework for privacy properties
  • Debugging tools with privacy preservation

Contributing

We welcome contributions! Please see our contributing guidelines.

License

This project is licensed under the MIT License.

Support


Privacy-First Smart Contracts with NymScript 🔒

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages