Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiasset integration #119

Merged
merged 9 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 27 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
name: Set-Up & Build
name: Set-Up & Build & Test

# Controls when the action will run.
on:
push:
branches:
- "**" # matches every branch
- "!master" # excludes master
pull_request:
branches:
- "**" # matches every branch
- "!master" # excludes master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
branches:
- "**" # matches every branch
- "!master" # excludes master
pull_request:
branches:
- "**" # matches every branch
- "!master" # excludes master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-18.04
build:
# The type of runner that the job will run on
runs-on: ubuntu-18.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set-Up
run: sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl
- name: Set-Up
run: sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl

- name: Install Rustup
run: curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: Install Rustup
run: curl https://sh.rustup.rs -sSf | sh -s -- -y

- name: Build
run: ./scripts/build.sh
- name: Build
run: ./scripts/build.sh

- name: Test
run: ./scripts/test.sh
- name: Test
run: ./scripts/test.sh
80 changes: 76 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use frame_benchmarking::whitelisted_caller;
use std::collections::BTreeMap;
use node_template_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, EVMConfig,
Expand Down Expand Up @@ -62,6 +63,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
whitelisted_caller(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for benchmarking

],
true,
)
Expand Down
2 changes: 1 addition & 1 deletion pallets/merkle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub mod pallet {

/// The pallet's configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config + balances::Config {
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: IsType<<Self as frame_system::Config>::Event> + From<Event<Self>>;
/// The overarching group ID type
Expand Down
70 changes: 56 additions & 14 deletions pallets/merkle/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,14 @@ fn should_verify_simple_zk_proof_of_membership() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, vec![ScalarData(leaf)]));
let root = MerkleGroups::get_merkle_root(0).unwrap();

let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let leaf_index_comms: Vec<Commitment> = leaf_index_comms_cr.iter().map(|x| Commitment(*x)).collect();
Expand Down Expand Up @@ -489,8 +495,14 @@ fn should_not_verify_invalid_commitments_for_leaf_creation() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, vec![ScalarData(leaf)]));
let root = MerkleGroups::get_merkle_root(0).unwrap();

let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let mut comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let mut rng = OsRng::default();
Expand Down Expand Up @@ -534,8 +546,14 @@ fn should_not_verify_invalid_private_inputs() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, vec![ScalarData(leaf)]));
let root = MerkleGroups::get_merkle_root(0).unwrap();

let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let mut comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let leaf_index_comms: Vec<Commitment> = leaf_index_comms_cr.iter().map(|x| Commitment(*x)).collect();
Expand Down Expand Up @@ -581,8 +599,14 @@ fn should_not_verify_invalid_path_commitments_for_membership() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, vec![ScalarData(leaf)]));
let root = MerkleGroups::get_merkle_root(0).unwrap();

let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let mut leaf_index_comms: Vec<Commitment> = leaf_index_comms_cr.iter().map(|x| Commitment(*x)).collect();
Expand Down Expand Up @@ -627,8 +651,14 @@ fn should_not_verify_invalid_transcript() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, vec![ScalarData(leaf)]));
let root = MerkleGroups::get_merkle_root(0).unwrap();

let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let leaf_index_comms: Vec<Commitment> = leaf_index_comms_cr.iter().map(|x| Commitment(*x)).collect();
Expand Down Expand Up @@ -687,8 +717,14 @@ fn should_verify_zk_proof_of_membership() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, keys_data));

let root = MerkleGroups::get_merkle_root(0).unwrap();
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf5, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf5,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let leaf_index_comms: Vec<Commitment> = leaf_index_comms_cr.iter().map(|x| Commitment(*x)).collect();
Expand Down Expand Up @@ -725,8 +761,14 @@ fn should_verify_large_zk_proof_of_membership() {
assert_ok!(MerkleGroups::add_members(Origin::signed(1), 0, vec![ScalarData(leaf)]));

let root = MerkleGroups::get_merkle_root(0).unwrap();
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) =
ftree.prove_zk(root.0, leaf, Scalar::zero(), Scalar::zero(), &ftree.hash_params.bp_gens, prover);
let (proof, (comms_cr, nullifier_hash, leaf_index_comms_cr, proof_comms_cr)) = ftree.prove_zk(
root.0,
leaf,
Scalar::zero(),
Scalar::zero(),
&ftree.hash_params.bp_gens,
prover,
);

let comms: Vec<Commitment> = comms_cr.iter().map(|x| Commitment(*x)).collect();
let leaf_index_comms: Vec<Commitment> = leaf_index_comms_cr.iter().map(|x| Commitment(*x)).collect();
Expand Down
4 changes: 4 additions & 0 deletions pallets/mixer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] }
bulletproofs = { version = "2.0.0", branch = "main", git = "https://github.com/edgeware-builders/bulletproofs", default-features = false, features = ["yoloproofs"] }
merlin = { version = "2.0.0", default-features = false }
frame-benchmarking = { default-features = false, version = "3.0.0", optional = true }
orml-traits = { version = "0.4.0", default-features = false }
orml-currencies = { version = "0.4.0", default-features = false }
orml-tokens = { version = "0.4.0", default-features = false }

[dependencies.curve25519-gadgets]
branch = "main"
Expand Down Expand Up @@ -48,6 +51,7 @@ std = [
"balances/std",
"frame-support/std",
"frame-system/std",
"orml-tokens/std",
"frame-benchmarking/std",
"merkle/std",
]
Expand Down