Rust based Virtual Machine on Avalanche that implements Bulletproof ZK Proofs.

Overview

BulletproofVM

Rust based Virtual Machine on Avalanche that implements Bulletproof ZK Proofs.

Zero-Knowledge Virtual Machine

This is a virtual machine (VM) implemented in Rust that allows you to execute transactions with zero-knowledge (ZK) proofs. The VM maintains a state consisting of accounts with balances and assets, and supports several types of transactions, including standard transactions for transferring assets between two accounts, smart contract transactions for executing arbitrary code on a contract account, multi-asset transactions for transferring multiple different assets between two accounts, and decentralized governance transactions for proposing and voting on changes to the system.

Features

  • Maintains a state consisting of accounts with balances and assets
  • Executes standard transactions for transferring assets between two accounts
  • Executes smart contract transactions for executing arbitrary code on a contract account
  • Executes multi-asset transactions for transferring multiple different assets between two accounts
  • Executes decentralized governance transactions for proposing and voting on changes to the system
  • Uses zero-knowledge (ZK) proofs to ensure the correctness and privacy of transactions

Dependencies

  • Rust 1.51 or higher
  • The curve25519-dalek library for implementing elliptic curve cryptography
  • The rand library for generating randomness
  • The bulletproofs library for implementing Bulletproof ZK proofs

Usage

  • To use the VM, create a new instance of the MyVirtualMachine struct and use its methods to create new accounts and execute transactions:
use zk_vm::{
    codec::{Codec, Decode, Encode},
    execution::{Execution, Executable},
    MyVirtualMachine,
    MyTransaction,
    SmartContractTransaction,
    MultiAssetTransaction,
    DecentralizedGovernanceTransaction,
    KeyPair,
    PublicKey,
};

// Create a new instance of the VM
let mut vm = MyVirtualMachine::new();

// Generate keypair for the sender and recipient
let sender_keypair = KeyPair::generate();
let recipient_keypair = KeyPair::generate();

// Create accounts for the sender and recipient
vm.create_account(sender_keypair);
vm.create_account(recipient_keypair);

// Construct a MyTransaction to transfer 100 units from the sender to the recipient
let tx = MyTransaction {
    sender: sender_keypair.public,
    recipient: recipient_keypair.public,
    amount: 100,
    proof: Proof::new(BulletproofGroth16),
};

// Serialize the transaction to a byte array
let bytes = tx.encode();

// Deserialize the transaction from the byte array
let tx = MyTransaction::decode(&bytes).unwrap();

// Execute the transaction on the VM
vm.execute(&tx).unwrap();

// Check the balances of the sender and recipient
let sender_account = vm.get_account(sender_keypair.public).unwrap();
assert_eq!(sender_account.balance, 900);
let recipient_account = vm.get_account(recipient_keypair.public).unwrap();
assert_eq!(recipient_account.balance, 100);

You can also execute other types of transactions, such as smart contract transactions, multi-asset transactions, and decentralized governance transactions, using the same process.

License

This project is licensed under the MIT License.

You might also like...
Safeguard your financial privacy with zero-knowledge proofs.

Spinner The Spinner project (https://spinner.cash) takes a privacy first approach to protect users crypto assets. It is a layer-2 protocol built on th

STARK - SNARK recursive zero knowledge proofs, combinaison of the Winterfell library and the Circom language

STARK - SNARK recursive proofs The point of this library is to combine the SNARK and STARK computation arguments of knowledge, namely the Winterfell l

Common protocol for generating ZK proofs for blocks on different blockchains.

Proof Protocol Decoder A flexible protocol that clients (eg. full nodes) can use to easily generate block proofs for different chains. Specification I

The Zero Knowledge Whitelist Tool is a powerful utility for managing an address whitelist using Zero-Knowledge (ZK) proofs.
The Zero Knowledge Whitelist Tool is a powerful utility for managing an address whitelist using Zero-Knowledge (ZK) proofs.

zk_whitelist: A Zero Knowledge Whitelist Tool The Zero Knowledge Whitelist Tool is a powerful utility for managing an address whitelist using Zero-Kno

A sparse merkle tree lib focused on efficient on-chain proofs. Enforces ordering within the merkle tree.

sparse-merkle-tree The merkle tree functions are located in sparse.ak. Currently the supported functionality is: Verifying a new root with an added me

Reference library that implements all the necessary functionality for developing a client that is compatible with TAPLE's DLT network.
Reference library that implements all the necessary functionality for developing a client that is compatible with TAPLE's DLT network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Core TAPLE (pronounced T+ 🍎 ['tapəl]) stands for Tracking (Autonomous)

A CLI application that implements multi-key-turn security via Shamir's Secret Sharing.

agree agree is a CLI tool for easily applying multi-key-turn security via Shamirs Secret Sharing. Project state agree is unstable. Version semantics:

Implements ERC-5564 for the bn254 curve using arkworks-rs

erc-5564-bn254 Uses the arkworks-rs suite of libraries, and utilities from rln Usage Note: this scheme should be used with the fork of circom-rln. use

🗂️ A simple, opinionated, tool, written in Rust, for declaratively managing Git repos on your machine.

gitrs 🗂️ A simple, opinionated, tool, written in Rust, for declaretively managing Git repos on your machine. "simple" - limited in what it supports.

Owner
null
Avalanche primitive types in Rust (experimental)

AvalancheGo Compatibility Crate Version(s) AvalancheGo Version(s) Protocol Version v0.0.134-155 v1.9.2,v1.9.3 19 v0.0.156-176 v1.9.4 20 v0.0.177-200 v

Ava Labs 26 Feb 4, 2023
Avalanche APIs/VM SDK in Rust

avalanche-rs ⚠️ avalanche-rs is alpha-level software and is not ready for production use. Do not use avalanche-rs to run production workloads. See the

Ava Labs 30 Oct 10, 2023
A low-level assembly language for the Ethereum Virtual Machine built in blazing-fast pure rust.

huff-rs • huff-rs is a Huff compiler built in rust. What is a Huff? Huff is a low-level programming language designed for developing highly optimized

Huff 276 Dec 31, 2022
DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support

DeFiCh/metachain is a codename research & development for DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support . Proposed as a DFIP on Nov 2021; D

DeFiChain 19 Dec 6, 2022
ZKP fork for rust-secp256k1, adds wrappers for range proofs, pedersen commitments, etc

rust-secp256k1 rust-secp256k1 is a wrapper around libsecp256k1, a C library by Peter Wuille for producing ECDSA signatures using the SECG curve secp25

null 53 Dec 19, 2022
Bulletproofs and Bulletproofs+ Rust implementation for Aggregated Range Proofs over multiple elliptic curves

Bulletproofs This library implements Bulletproofs+ and Bulletproofs aggregated range proofs with multi-exponent verification. The library supports mul

[ZenGo X] 62 Dec 13, 2022
Thaler's Proofs, Args, and ZK Implemented in Rust using arkworks

rthaler • Dr. Thaler's book Proofs, Args, and ZK implemented in rust using the arkworks cryptographic rust toolset. Various Zero Knowledge Protocols a

null 4 Jun 19, 2022
Noir is a domain specific language for zero knowledge proofs

The Noir Programming Language Noir is a Domain Specific Language for SNARK proving systems. It has been designed to use any ACIR compatible proving sy

null 404 Jan 1, 2023
P2P Network to verify authorship & ownership, store & deliver proofs.

Anagolay Network Node Anagolay is a next-generation framework for ownerships, copyrights and digital licenses. ?? Local Development The installation a

Anagolay Network 5 May 30, 2022
The Light Protocol program verifies zkSNARK proofs to enable anonymous transactions on Solana.

Light Protocol DISCLAIMER: THIS SOFTWARE IS NOT AUDITED. Do not use in production! Tests cd ./program && cargo test-bpf deposit_should_succeed cd ./pr

null 36 Dec 17, 2022