A privacy-preserving smart contract language for the Nym blockchain platform.
- 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_timeexecution guarantees
- 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
- 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
cargo build --releasecontract 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];
}
}
nymscript compile --input contract.nym --output contract.wasmnymscript deploy --contract contract.wasm --network testnet@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
zkproof(): Generate zero-knowledge proofscommit()/reveal(): Commitment-reveal schemesencrypt()/decrypt(): Privacy-preserving encryptionhash(),sha256(),sha3(): Cryptographic hashinggenerate_stealth_address(): Anonymous addresses
PrivateUint256: Encrypted integer typeSecretBytes32: Secret byte arrayAnonymousAddress: Anonymous address typeEncryptedString: Encrypted string typeZKProof: Zero-knowledge proof typeCommitment: Cryptographic commitmentStealthAddress: Stealth address type
cargo buildcargo testcargo doc --open- Lexical Analysis: Tokenization with privacy keyword recognition
- Parsing: AST generation with privacy annotations
- Privacy Analysis: Vulnerability detection and optimization
- Code Generation: WASM bytecode with privacy guarantees
- Optimization: Gas and privacy optimizations
- 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
- Native integration with Nym consensus mechanism
- Quantum-resistant cryptography throughout
- Privacy-preserving execution environment
- VS Code extension with privacy analysis
- Testing framework for privacy properties
- Debugging tools with privacy preservation
We welcome contributions! Please see our contributing guidelines.
This project is licensed under the MIT License.
- Documentation: NymScript Guide
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Privacy-First Smart Contracts with NymScript 🔒