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

Add transfer circuit gadget #170

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ dusk-bls12_381 = { version = "0.13", default-features = false }
bls12_381-bls = { version = "0.3", default-features = false }
dusk-jubjub = { version = "0.14", default-features = false, features = ["zeroize"] }
dusk-poseidon = { version = "0.33", default-features = false }
jubjub-schnorr = { version = "0.3", default-features = false }
poseidon-merkle = { version = "0.5", features = ["rkyv-impl", "zk", "size_32"] }
jubjub-schnorr = { version = "0.3", default-features = false, features = ["double"] }
subtle = { version = "^2.2.1", default-features = false }
ff = { version = "0.13", default-features = false }
aes-gcm = "0.10"
zeroize = { version = "1", default-features = false, features = ["derive"] }
rkyv = { version = "0.7", optional = true, default-features = false }
bytecheck = { version = "0.6", optional = true, default-features = false }
rand = "0.8"

[dev-dependencies]
assert_matches = "1.3"
rand = "0.8"
rkyv = { version = "0.7", default-features = false, features = ["size_32"] }
lazy_static = "1.4"

[features]
default = [] # "alloc" is suggested as default feature but would be breaking change
Expand All @@ -43,9 +45,15 @@ rkyv-impl = [
]
zk = [
"dusk-plonk",
"jubjub-schnorr/alloc",
]

[[test]]
name = "gadgets"
path = "tests/gadgets.rs"
name = "encryption_gadgets"
path = "tests/encryption_gadgets.rs"
required-features = ["zk"]

[[test]]
name = "transfer_gadget"
path = "tests/transfer_gadget.rs"
required-features = ["zk"]
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ pub mod error;
pub mod fee;
/// Transparent and Obfuscated Notes
pub mod note;
/// Transfer gadgets
#[cfg(feature = "zk")]
pub mod transfer;

/// Phoenix Core Keys & Addresses
mod keys;
Expand Down
9 changes: 8 additions & 1 deletion src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use dusk_jubjub::{
use crate::aes;

use dusk_poseidon::sponge::hash;

use ff::Field;
use rand_core::{CryptoRng, RngCore};

Expand Down Expand Up @@ -264,7 +265,7 @@ impl Note {
}

/// Return the type of the note
pub const fn note(&self) -> NoteType {
pub const fn note_type(&self) -> NoteType {
self.note_type
}

Expand Down Expand Up @@ -331,6 +332,12 @@ impl Ownable for Note {
}
}

impl Ownable for &Note {
fn stealth_address(&self) -> &StealthAddress {
&self.stealth_address
}
}

// Serialize into 105 + ENCRYPTION_SIZE bytes, where 105 is the size of all the
// note elements without the encryption. ENCRYPTION_SIZE = PLAINTEXT_SIZE +
// ENCRYPTION_EXTRA_SIZE
Expand Down
Loading