A substrate pallet that enables Manta's decentialized anynonymous payment (DAP) protocol.

Overview

pallet-manta-dap

This is a pallet that enables decentialized anynonymous payment (DAP) protocol. The best way to use this repo is to invoke it with a manta-runtime, available from either manta-node or cumulus.

Disclaimer: This code is a proof-of-concept; is not properly reviewed or audited and is likely to have severe bugs or security pitfalls. Use at your own risk!

Pre-computed tokens

cargo run --bin pre_comp --release

Test coverage

cargo install grcov
  • build and run test (extremely slow)
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
cargo +nightly-2021-01-29 test
  • generate the report
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
open target/debug/coverage/index.html
  • The report is also available within coverage folder.

Result

Benchmark

  • benchmark enviroment

AMD Ryzen 9 5900X 12-Core Processor; Ubuntu 20.04; rustc 1.50.0 (cb75ad5db 2021-02-10)

  • with criterion (take some time)
cargo bench

sample output

deserialization/hash param                        
                        time:   [113.15 us 113.18 us 113.23 us]
deserialization/commit param                        
                        time:   [132.49 us 132.51 us 132.53 us]
perdersen/hash param gen                        
                        time:   [7.0316 ms 7.0321 ms 7.0326 ms]
perdersen/commit open   time:   [59.471 us 59.490 us 59.511 us]
merkle_tree/with 1 leaf time:   [1.1660 ms 1.1664 ms 1.1669 ms]
merkle_tree/with 2 leaf time:   [1.3025 ms 1.3030 ms 1.3035 ms]
merkle_tree/with 3 leaf time:   [1.5725 ms 1.5730 ms 1.5735 ms]
transfer/ZKP verification                        
                        time:   [8.8006 ms 8.8016 ms 8.8028 ms]                   
  • with frame-benchmarking: within manta-node repo, run
cargo +nightly build --release -p manta-node -Z package-features --package manta-runtime --features runtime-benchmarks --wasm-execution compiled
target/release/manta-node benchmark --pallet pallet_manta_dap --extrinsic init --repeat 100 --execution=wasm --wasm-execution compiled
target/release/manta-node benchmark --pallet pallet_manta_dap --extrinsic transfer --repeat 100 --execution=wasm --wasm-execution compiled
target/release/manta-node benchmark --pallet pallet_manta_dap --extrinsic mint --repeat 100 --execution=wasm --wasm-execution compiled
target/release/manta-node benchmark --pallet pallet_manta_dap --extrinsic manta_transfer --repeat 100 --execution=wasm --wasm-execution compiled
target/release/manta-node benchmark --pallet pallet_manta_dap --extrinsic forfeit --repeat 100 --execution=wasm --wasm-execution compiled

sample output

Function init trasfer mint manta_transfer forfeit
Rust 640 us 13 us 1.9 ms 10.1 ms 8.8 ms
Wasm 2.8 ms 111 us 13.1 ms 130 ms 107 ms
Comments
  • [Pallet-Manta-Pay] #37 - Configure weights in the manta pay pallet

    [Pallet-Manta-Pay] #37 - Configure weights in the manta pay pallet

    closes #37

    • Adds the auto-generated weights.rs file, from the benchmark process.
    • Integrates each extrinsic's weight function.
    • Benchmarking is performed with a more typical AWS instance described in the README
    Pallet-Manta-Pay 
    opened by ghzlatarev 14
  • #13 CI/CD - Create initial github action to check compilation and formatting

    #13 CI/CD - Create initial github action to check compilation and formatting

    CI/CD : Create check.yml for compilation and formatting github action

    • The check.yml first runs yamllint
    • Then installs rustup and runs the following commands: cargo check --release cargo fmt --all -- --check cargo nightly clippy --release cargo test --release
    opened by ghzlatarev 8
  • Storage refactor

    Storage refactor

    This is part of storage refactor with: https://github.com/Manta-Network/Manta/pull/152

    The major goal is to remove all the O(N) operations with O(1) (or at least O(Log N) ) operations.

    • [x] update to v2-macro. (Thanks a lot to @ghzlatarev 's prototype code)
    • [x] test new storage data structures
    • [x] finalize storage data structure design
    • [x] reimplement pallet-manta-pay
    • [x] move zkp unit tests to manta-api
    • [x] rewrite frame unit tests
    • [x] update readme.md
    • [x] performance tests with empty ledger state.
    • [x] create a binary for generating pre-computed coins
    • [x] readme, doc, semantic versioning.
    opened by stechu 4
  • CI to include manta repo when pallet-manta-pay is updated

    CI to include manta repo when pallet-manta-pay is updated

    closes #54

    Add additional CI to checkout and build the Manta repository when pallet-manta-pay is updated:

    1. git clone https://github.com/Manta-Network/Manta
    2. cd Manta
    3. replace line in Cargo.toml file with sed
    4. cargo build --release --all-features
    Pallet-Manta-Pay Testnet-Release Manta-Node 
    opened by ghzlatarev 3
  • Refactor asset id and balance

    Refactor asset id and balance

    Refactor asset id and balance. [Only merge when all check box checked].

    • [x] refactor asset id and balance
    • [x] store ciphertext for both mint and transfer
    • [x] pass all internal test
    • [x] pass framebenchmark test
    opened by stechu 2
  • Must fail tests for the private_transfer extrinsic

    Must fail tests for the private_transfer extrinsic

    closes #48

    • Adding the following must-fail tests for the private_transfer extrinsic
      • transferring_with_hash_param_mismatch_should_not_work
      • transferring_spent_coin_should_not_work_sender_1
      • transferring_spent_coin_should_not_work_sender_2
      • transferring_with_invalid_ledger_state_should_not_work
      • transferring_existing_coins_should_not_work
      • transferring_with_invalid_zkp_param_should_not_work
      • transferring_with_zkp_verification_fail_should_not_work
    • Adding the following must-fail tests for the reclaim extrinsic:
      • reclaim_without_init_should_not_work
      • reclaim_with_overdrawn_pool_should_not_work
    enhancement Testnet-Release 
    opened by ghzlatarev 2
  • [Manta] Refactor

    [Manta] Refactor

    • moving out the crypto algorithms to manta-crypto
    • moving out the asset definitions to pallet-manta-pay
    • better circuit abstraction
    • [Important] better extrinsic interfaces: this breaks some of current API
    opened by zhenfeizhang 2
  • Integration with `manta-rs`

    Integration with `manta-rs`

    TODO

    • [x] Add merkle tree update for UTXOs
    • [x] Use verification keys from manta-sdk
      • [x] Import the verification keys
      • [x] Deserialize them to use them for verification
    • [x] Update tests for new protocol
    • [ ] Recompute weights
    • [x] Update dependencies:
      • [x] https://github.com/Manta-Network/sdk/pull/3
      • [x] https://github.com/Manta-Network/manta-rs/pull/13
    opened by bhgomes 1
  • Update to Arkworks 0.3.x

    Update to Arkworks 0.3.x

    • Updated APIs/documentation at the pallet implementation level
    • converted tests

    Updates to Storage

    • had to add TwoToOneHashChecksum to the storage system
    • will have to change all of the stored checksums because the new ones are different (at the minimum they will be different for verifying keys)

    TODO

    • [ ] Fix failing test cases (they fail because of arkworks bugs)
    • [x] Convert benchmarks
    • [ ] Fix failing benchmarks
    • [ ] Audit the pallet implementation
    opened by bhgomes 1
  • Consistent naming for checksum storage

    Consistent naming for checksum storage

    I was having trouble with the macros trying to call transfer_zkp_key_checksum and reclaim_zkp_key_checksum from manta-subxt, so I just changed the variable naming schemes to be consistent with CoinShard and it seemed to fix it, unclear why. This PR is paired with an update to Manta.

    opened by gabcbrown 1
  • Add reclaim extrinsic must fail tests

    Add reclaim extrinsic must fail tests

    closes #48

    Adding the following must-fail tests for the private_transfer extrinsic

    • reclaim_with_hash_param_mismatch_should_not_work
    • reclaim_with_overdrawn_pool_should_not_work
    • reclaim_spent_coin_should_not_work
    • reclaim_spent_coin_should_not_work_2
    • reclaim_with_invalid_zkp_param_should_not_work
    • reclaim_with_invalid_ledger_state_should_not_work
    • reclaim_with_zkp_verification_fail_should_not_work
    Testnet-Release 
    opened by ghzlatarev 1
Releases(v0.2.0)
  • v0.2.0(Oct 25, 2021)

    What's Changed

    • allow mint zero coin by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/79
    • add cipher text to mint payload by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/80
    • bump version by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/81
    • Refactor asset id and balance by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/85
    • Fix Receiver Circuit Bug by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/86
    • Consistent naming for checksum storage by @gabcbrown in https://github.com/Manta-Network/pallet-manta-pay/pull/87
    • Secondary script to check for successful integrations downstream [ready-to-merge] by @ghzlatarev in https://github.com/Manta-Network/pallet-manta-pay/pull/84
    • Change Mint/Transfer/Reclaim Interface by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/88
    • Storage refactor by @stechu in https://github.com/Manta-Network/pallet-manta-pay/pull/91

    New Contributors

    • @ghzlatarev made their first contribution in https://github.com/Manta-Network/pallet-manta-pay/pull/18
    • @Dengjianping made their first contribution in https://github.com/Manta-Network/pallet-manta-pay/pull/47
    • @liuchengxu made their first contribution in https://github.com/Manta-Network/pallet-manta-pay/pull/53
    • @gabcbrown made their first contribution in https://github.com/Manta-Network/pallet-manta-pay/pull/87

    Full Changelog: https://github.com/Manta-Network/pallet-manta-pay/compare/v0.1.1-w3f...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1-rococo-v1(Mar 5, 2021)

  • v0.1.0-w3f(Mar 5, 2021)

Owner
Manta Network
An interoperable privacy protocol for the DeFi Stack
Manta Network
InvArch Pallet Library - IP Infrastructure for Substrate

InvArch-Pallet-Library Intro This repository should contains the Pallets used in the InvArch blockchain, and reviews their relationships and functions

InvArch 20 Dec 18, 2022
Substrate Pallet for chaotic experimentations

Chaos Pallet The Chaos module is used to inject chaos into a Substrate Runtime and intentionally break things. Overview The Chaos module provides func

Bernardo A. Rodrigues 2 Apr 7, 2022
Faterium Substrate Node, Runtime, and Pallets. Contains "faterium-polls-pallet" with logic of Faterium Polls.

Faterium Substrate Node Faterium - a place where fates are forged. This is the official implementation of Faterium Crowdfunding Polls in Rust as Subst

Faterium 3 Dec 15, 2022
Freelance payment protocol written in Rust.. (with multi-sig signing for dispute settling)

Freelance Escrow payment protocol ?? About The freelance protocol is a protocol built on decentralized and open systems such as blockchain and decentr

Femi Bolaji 4 Jan 3, 2023
Kryptokrona SDK in Rust for building decentralized private communication and payment systems.

Kryptokrona Rust SDK Kryptokrona is a decentralized blockchain from the Nordic based on CryptoNote, which forms the basis for Monero, among others. Cr

null 5 May 25, 2023
A Rust library to interact with the MPesa API, simplifying B2C payment integrations and more.

MPesa SDK (Rust Library) A Rust library to interact with the MPesa API, simplifying B2C payment integrations and more. Features Configuration manageme

Ismael GraHms 8 Aug 23, 2023
Substrate blockchain generated with Substrate Startkit

Substrate Node Template A new FRAME-based Substrate node, ready for hacking ?? Getting Started This project contains some configuration files to help

HoangDuong 1 Oct 19, 2021
Substrate blockchain generated with Substrate Startkit

Substrate Node Template A new FRAME-based Substrate node, ready for hacking ?? Getting Started This project contains some configuration files to help

HoangDuong 1 Oct 19, 2021
Substrate blockchain generated with Substrate Startkit

Substrate Node Template A new FRAME-based Substrate node, ready for hacking ?? Getting Started This project contains some configuration files to help

Liam Parry 0 Nov 6, 2021
The implementation of the chain extension for `pallet-assets`

Pallet assets chain extension ⚠️ Chain extension contains vulnerabilities: Don't use it in the production. Fixing vulnerabilities requires changes on

Supercolony 2 Aug 22, 2022
A specialized blockchain for testing use cases with the FRAME NFTs Pallet.

Substrate NFTs Node The Substrate NFTs node is a specialized blockchain for testing use cases with the FRAME NFTs Pallet. ?? The purpose of this node

Sacha Lansky 4 May 25, 2023
Basilisk node - cross-chain liquidity protocol built on Substrate

Basilisk node Local Development Follow these steps to prepare a local Substrate development environment ??️ Simple Setup Install all the required depe

Galactic Council 52 Dec 27, 2022
Biddi Network enables custom p2p swaps in Solana ocean 🌊.

Peer to peer, decentralized protocol which allow direct swaps between 2 network participants for custom tokens without liquidity pools on Solana blockchain.

Biddi Network 2 Nov 1, 2022
Rust implementation of Namada, a sovereign proof-of-stake blockchain that enables asset-agnostic private transfers

Namada Overview Namada is a sovereign proof-of-stake blockchain, using Tendermint BFT consensus, that enables multi-asset private transfers for any na

anoma 144 Jan 2, 2023
Substrate: The platform for blockchain innovators

Substrate · Substrate is a next-generation framework for blockchain innovation ?? . Trying it out Simply go to substrate.dev and follow the installati

Parity Technologies 7.7k Dec 30, 2022
Substrate Node for Anmol Network

Anmol Substrate Node ?? ??️ ?? Anmol is the First Cross-Chain NFT Toolkit, on Polkadot. Introducing: Moulds NFT Breeding Multi-Chain NFT Migration ink

Anmol Network 12 Aug 28, 2022
Substrate NFT !ink smart contract base

Substrate !ink NFT simple implementation This is a simple working version of base NFT smart contract written using latest (as of this date) !ink 3.0.0

POLK4.NET 14 Dec 3, 2022
Filecoin to substrate bridge

filecoindot A Substrate pallet to bridge from Filecoin to any blockchain built using the Substrate framework, including Polkadot parachains. How to in

ChainSafe 23 Nov 23, 2022
Substrate Node Template Generator

Substrate Node Template Generator A tool to generate stand-alone node templates of a customized Substrate clients used in "Substrate Library Extension

Parity Technologies 2 Feb 11, 2022