mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 23:27:56 -05:00
cleanup imports by flattening everything to submodules.
This commit is contained in:
@@ -22,6 +22,10 @@ pub use block::{Block, BlockInfo, BlockProposal, Header};
|
||||
|
||||
/// Constants
|
||||
pub mod constants;
|
||||
pub use constants::{
|
||||
TESTNET_BOOTSTRAP_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_TIMESTAMP,
|
||||
TESTNET_INITIAL_DISTRIBUTION,
|
||||
};
|
||||
|
||||
/// Consensus block leader information
|
||||
pub mod lead_info;
|
||||
@@ -47,6 +51,7 @@ pub use clock::{Clock, Ticks};
|
||||
|
||||
/// Consensus participation coin functions and definitions
|
||||
pub mod leadcoin;
|
||||
pub use leadcoin::LeadCoin;
|
||||
|
||||
/// Utility types
|
||||
pub mod types;
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{pedersen::pedersen_commitment_u64, poseidon_hash, SecretKey},
|
||||
pasta::{arithmetic::CurveAffine, group::Curve, pallas},
|
||||
use darkfi_sdk::crypto::{
|
||||
pallas, pasta_prelude::*, pedersen_commitment_u64, poseidon_hash, SecretKey,
|
||||
};
|
||||
|
||||
use halo2_proofs::circuit::Value;
|
||||
@@ -26,11 +25,7 @@ use log::debug;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
use darkfi::{
|
||||
zk::{
|
||||
proof::{Proof, ProvingKey},
|
||||
vm::ZkCircuit,
|
||||
vm_stack::Witness,
|
||||
},
|
||||
zk::{Proof, ProvingKey, Witness, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
|
||||
@@ -17,15 +17,11 @@
|
||||
*/
|
||||
|
||||
use darkfi::{
|
||||
zk::{proof::ProvingKey, vm::ZkCircuit, vm_stack::Witness, Proof},
|
||||
zk::{Proof, ProvingKey, Value, Witness, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
use darkfi_sdk::{
|
||||
crypto::{poseidon_hash, PublicKey, TokenId},
|
||||
pasta::pallas,
|
||||
};
|
||||
use halo2_proofs::circuit::Value;
|
||||
use darkfi_sdk::crypto::{pallas, poseidon_hash, PublicKey, TokenId};
|
||||
use log::debug;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
|
||||
@@ -16,28 +16,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
pedersen::pedersen_commitment_u64, poseidon_hash, MerkleNode, PublicKey, SecretKey, TokenId,
|
||||
},
|
||||
incrementalmerkletree,
|
||||
incrementalmerkletree::Hashable,
|
||||
pasta::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{ff::Field, Curve},
|
||||
pallas,
|
||||
},
|
||||
use darkfi_sdk::crypto::{
|
||||
merkle_prelude::*, pallas, pasta_prelude::*, pedersen::pedersen_commitment_u64, poseidon_hash,
|
||||
MerkleNode, MerklePosition, PublicKey, SecretKey, TokenId,
|
||||
};
|
||||
use darkfi_serial::{SerialDecodable, SerialEncodable};
|
||||
use halo2_proofs::circuit::Value;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
use darkfi::{
|
||||
zk::{
|
||||
proof::{Proof, ProvingKey},
|
||||
vm::ZkCircuit,
|
||||
vm_stack::Witness,
|
||||
},
|
||||
zk::{Proof, ProvingKey, Value, Witness, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
@@ -58,7 +45,7 @@ pub struct ProposalStakeInput {
|
||||
pub secret: SecretKey,
|
||||
//pub note: money::transfer::wallet::Note,
|
||||
pub note: darkfi_money_contract::client::Note,
|
||||
pub leaf_position: incrementalmerkletree::Position,
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub signature_secret: SecretKey,
|
||||
}
|
||||
@@ -76,7 +63,7 @@ pub struct ProposeCall {
|
||||
pub inputs: Vec<ProposalStakeInput>,
|
||||
pub proposal: Proposal,
|
||||
pub dao: Dao,
|
||||
pub dao_leaf_position: incrementalmerkletree::Position,
|
||||
pub dao_leaf_position: MerklePosition,
|
||||
pub dao_merkle_path: Vec<MerkleNode>,
|
||||
pub dao_merkle_root: MerkleNode,
|
||||
}
|
||||
|
||||
@@ -16,30 +16,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
keypair::Keypair, pedersen::pedersen_commitment_u64, poseidon_hash, MerkleNode, Nullifier,
|
||||
PublicKey, SecretKey,
|
||||
},
|
||||
incrementalmerkletree,
|
||||
incrementalmerkletree::Hashable,
|
||||
pasta::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{ff::Field, Curve},
|
||||
pallas,
|
||||
},
|
||||
use darkfi_sdk::crypto::{
|
||||
merkle_prelude::*, pallas, pasta_prelude::*, pedersen_commitment_u64, poseidon_hash, Keypair,
|
||||
MerkleNode, MerklePosition, Nullifier, PublicKey, SecretKey,
|
||||
};
|
||||
use darkfi_serial::{SerialDecodable, SerialEncodable};
|
||||
use halo2_proofs::circuit::Value;
|
||||
use log::debug;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
use darkfi::{
|
||||
zk::{
|
||||
proof::{Proof, ProvingKey},
|
||||
vm::ZkCircuit,
|
||||
vm_stack::Witness,
|
||||
},
|
||||
zk::{Proof, ProvingKey, Value, Witness, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
@@ -67,7 +53,7 @@ pub struct BuilderInput {
|
||||
pub secret: SecretKey,
|
||||
//pub note: money::transfer::wallet::Note,
|
||||
pub note: darkfi_money_contract::client::Note,
|
||||
pub leaf_position: incrementalmerkletree::Position,
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub signature_secret: SecretKey,
|
||||
}
|
||||
@@ -107,17 +93,6 @@ impl Builder {
|
||||
|
||||
let signature_public = PublicKey::from_secret(input.signature_secret);
|
||||
|
||||
/*
|
||||
let zk_info = zk_bins.lookup(&"dao-vote-burn".to_string()).unwrap();
|
||||
|
||||
let zk_info = if let ZkContractInfo::Binary(info) = zk_info {
|
||||
info
|
||||
} else {
|
||||
panic!("Not binary info")
|
||||
};
|
||||
let zk_bin = zk_info.bincode.clone();
|
||||
*/
|
||||
|
||||
// Note from the previous output
|
||||
let note = input.note;
|
||||
let leaf_pos: u64 = input.leaf_position.into();
|
||||
@@ -246,16 +221,6 @@ impl Builder {
|
||||
let all_vote_commit = pedersen_commitment_u64(vote_value, vote_value_blind);
|
||||
let all_vote_commit_coords = all_vote_commit.to_affine().coordinates().unwrap();
|
||||
|
||||
/*
|
||||
let zk_info = zk_bins.lookup(&"dao-vote-main".to_string()).unwrap();
|
||||
let zk_info = if let ZkContractInfo::Binary(info) = zk_info {
|
||||
info
|
||||
} else {
|
||||
panic!("Not binary info")
|
||||
};
|
||||
let zk_bin = zk_info.bincode.clone();
|
||||
*/
|
||||
|
||||
let prover_witnesses = vec![
|
||||
// proposal params
|
||||
Witness::Base(Value::known(proposal_dest_x)),
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{MerkleNode, Nullifier, PublicKey},
|
||||
pasta::{group::Group, pallas},
|
||||
};
|
||||
use darkfi_sdk::crypto::{pallas, pasta_prelude::*, MerkleNode, Nullifier, PublicKey};
|
||||
use darkfi_serial::{SerialDecodable, SerialEncodable};
|
||||
|
||||
#[derive(SerialEncodable, SerialDecodable)]
|
||||
|
||||
@@ -20,22 +20,14 @@ use std::io::Cursor;
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
contract_id::{DAO_CONTRACT_ID, MONEY_CONTRACT_ID},
|
||||
ContractId, MerkleNode, MerkleTree, PublicKey,
|
||||
pallas, pasta_prelude::*, ContractId, MerkleNode, MerkleTree, PublicKey, DAO_CONTRACT_ID,
|
||||
MONEY_CONTRACT_ID,
|
||||
},
|
||||
db::{
|
||||
db_contains_key, db_del, db_get, db_init, db_lookup, db_set, SMART_CONTRACT_ZKAS_DB_NAME,
|
||||
},
|
||||
error::{ContractError, ContractResult},
|
||||
merkle::merkle_add,
|
||||
msg,
|
||||
pasta::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{Curve, Group},
|
||||
pallas,
|
||||
},
|
||||
tx::ContractCall,
|
||||
util::set_return_data,
|
||||
merkle_add, msg, set_return_data, ContractCall,
|
||||
};
|
||||
use darkfi_serial::{deserialize, serialize, Decodable, Encodable, WriteExt};
|
||||
|
||||
@@ -242,7 +234,6 @@ fn process_instruction(cid: ContractId, ix: &[u8]) -> ContractResult {
|
||||
let mut proposal_votes: ProposalVotes = deserialize(&proposal_votes)?;
|
||||
|
||||
// Check the Merkle roots and nullifiers for the input coins are valid
|
||||
// TODO: vote_nullifiers is useless
|
||||
let money_roots_db = db_lookup(money_cid, MONEY_CONTRACT_COIN_ROOTS_TREE)?;
|
||||
let money_nullifier_db = db_lookup(money_cid, MONEY_CONTRACT_NULLIFIERS_TREE)?;
|
||||
let dao_vote_nulls_db = db_lookup(cid, DAO_VOTE_NULLS)?;
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
*/
|
||||
|
||||
use darkfi::{
|
||||
zk::proof::{Proof, ProvingKey},
|
||||
zk::{Proof, ProvingKey},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
use darkfi_sdk::{
|
||||
crypto::{pedersen::ValueBlind, MerkleNode, PublicKey, SecretKey, TokenId},
|
||||
incrementalmerkletree,
|
||||
pasta::{group::ff::Field, pallas},
|
||||
use darkfi_sdk::crypto::{
|
||||
pallas, pasta_prelude::*, MerkleNode, MerklePosition, PublicKey, SecretKey, TokenId, ValueBlind,
|
||||
};
|
||||
|
||||
use rand::rngs::OsRng;
|
||||
@@ -34,42 +32,6 @@ use darkfi_money_contract::{
|
||||
state::{ClearInput, Input, MoneyTransferParams, Output},
|
||||
};
|
||||
|
||||
/*
|
||||
use darkfi::{
|
||||
crypto::{
|
||||
burn_proof::create_burn_proof,
|
||||
mint_proof::create_mint_proof,
|
||||
types::{
|
||||
DrkCoinBlind, DrkSerial, DrkSpendHook, DrkUserData, DrkUserDataBlind, DrkValueBlind,
|
||||
},
|
||||
},
|
||||
Result,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
contract::money::{
|
||||
transfer::validate::{CallData, ClearInput, Input, Output},
|
||||
CONTRACT_ID,
|
||||
},
|
||||
note,
|
||||
util::{FuncCall, ZkContractInfo, ZkContractTable},
|
||||
};
|
||||
*/
|
||||
|
||||
/*
|
||||
#[derive(Clone, SerialEncodable, SerialDecodable)]
|
||||
pub struct Note {
|
||||
pub serial: DrkSerial,
|
||||
pub value: u64,
|
||||
pub token_id: TokenId,
|
||||
pub spend_hook: DrkSpendHook,
|
||||
pub user_data: DrkUserData,
|
||||
pub coin_blind: DrkCoinBlind,
|
||||
pub value_blind: DrkValueBlind,
|
||||
pub token_blind: DrkValueBlind,
|
||||
}
|
||||
*/
|
||||
|
||||
pub struct Builder {
|
||||
pub clear_inputs: Vec<BuilderClearInputInfo>,
|
||||
pub inputs: Vec<BuilderInputInfo>,
|
||||
@@ -83,7 +45,7 @@ pub struct BuilderClearInputInfo {
|
||||
}
|
||||
|
||||
pub struct BuilderInputInfo {
|
||||
pub leaf_position: incrementalmerkletree::Position,
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub secret: SecretKey,
|
||||
pub note: Note,
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
*/
|
||||
|
||||
use chacha20poly1305::{AeadInPlace, ChaCha20Poly1305, KeyInit};
|
||||
use darkfi_sdk::crypto::{
|
||||
diffie_hellman::{kdf_sapling, sapling_ka_agree},
|
||||
PublicKey, SecretKey,
|
||||
};
|
||||
use darkfi_sdk::crypto::{diffie_hellman, PublicKey, SecretKey};
|
||||
use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
@@ -31,8 +28,8 @@ pub const AEAD_TAG_SIZE: usize = 16;
|
||||
pub fn encrypt<T: Encodable>(note: &T, public: &PublicKey) -> Result<EncryptedNote2> {
|
||||
let ephem_secret = SecretKey::random(&mut OsRng);
|
||||
let ephem_public = PublicKey::from_secret(ephem_secret);
|
||||
let shared_secret = sapling_ka_agree(&ephem_secret, public);
|
||||
let key = kdf_sapling(&shared_secret, &ephem_public);
|
||||
let shared_secret = diffie_hellman::sapling_ka_agree(&ephem_secret, public);
|
||||
let key = diffie_hellman::kdf_sapling(&shared_secret, &ephem_public);
|
||||
|
||||
let mut input = Vec::new();
|
||||
note.encode(&mut input)?;
|
||||
@@ -56,8 +53,8 @@ pub struct EncryptedNote2 {
|
||||
|
||||
impl EncryptedNote2 {
|
||||
pub fn decrypt<T: Decodable>(&self, secret: &SecretKey) -> Result<T> {
|
||||
let shared_secret = sapling_ka_agree(secret, &self.ephem_public);
|
||||
let key = kdf_sapling(&shared_secret, &self.ephem_public);
|
||||
let shared_secret = diffie_hellman::sapling_ka_agree(secret, &self.ephem_public);
|
||||
let key = diffie_hellman::kdf_sapling(&shared_secret, &self.ephem_public);
|
||||
|
||||
let ciphertext_len = self.ciphertext.len();
|
||||
let mut plaintext = vec![0_u8; ciphertext_len];
|
||||
|
||||
@@ -16,20 +16,16 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{coin::Coin, constants::MERKLE_DEPTH, MerkleNode, SecretKey},
|
||||
incrementalmerkletree,
|
||||
incrementalmerkletree::{bridgetree::BridgeTree, Tree},
|
||||
use darkfi_sdk::crypto::{
|
||||
merkle_prelude::*, Coin, MerkleNode, MerklePosition, MerkleTree, SecretKey,
|
||||
};
|
||||
|
||||
use darkfi_money_contract::client::{EncryptedNote, Note};
|
||||
|
||||
pub type MerkleTree = BridgeTree<MerkleNode, { MERKLE_DEPTH }>;
|
||||
|
||||
pub struct OwnCoin {
|
||||
pub coin: Coin,
|
||||
pub note: Note,
|
||||
pub leaf_position: incrementalmerkletree::Position,
|
||||
pub leaf_position: MerklePosition,
|
||||
}
|
||||
|
||||
pub struct WalletCache {
|
||||
|
||||
@@ -19,24 +19,17 @@ use std::collections::HashMap;
|
||||
|
||||
use darkfi::{
|
||||
consensus::{
|
||||
constants::{
|
||||
TESTNET_BOOTSTRAP_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_TIMESTAMP,
|
||||
TESTNET_INITIAL_DISTRIBUTION,
|
||||
},
|
||||
ValidatorState, ValidatorStatePtr,
|
||||
ValidatorState, ValidatorStatePtr, TESTNET_BOOTSTRAP_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES,
|
||||
TESTNET_GENESIS_TIMESTAMP, TESTNET_INITIAL_DISTRIBUTION,
|
||||
},
|
||||
wallet::WalletDb,
|
||||
zk::{proof::ProvingKey, vm::ZkCircuit, vm_stack::empty_witnesses},
|
||||
zk::{empty_witnesses, ProvingKey, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
contract_id::{DAO_CONTRACT_ID, MONEY_CONTRACT_ID},
|
||||
ContractId, Keypair,
|
||||
},
|
||||
crypto::{pasta_prelude::*, ContractId, Keypair, DAO_CONTRACT_ID, MONEY_CONTRACT_ID},
|
||||
db::SMART_CONTRACT_ZKAS_DB_NAME,
|
||||
pasta::group::ff::PrimeField,
|
||||
};
|
||||
use darkfi_serial::serialize;
|
||||
use log::{info, warn};
|
||||
|
||||
@@ -19,19 +19,10 @@
|
||||
use darkfi::{tx::Transaction, Result};
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
coin::Coin,
|
||||
contract_id::{DAO_CONTRACT_ID, MONEY_CONTRACT_ID},
|
||||
keypair::Keypair,
|
||||
pedersen::pedersen_commitment_u64,
|
||||
poseidon_hash, MerkleNode, SecretKey, TokenId,
|
||||
merkle_prelude::*, pallas, pasta_prelude::*, pedersen_commitment_u64, poseidon_hash, Coin,
|
||||
Keypair, MerkleNode, MerkleTree, SecretKey, TokenId, DAO_CONTRACT_ID, MONEY_CONTRACT_ID,
|
||||
},
|
||||
incrementalmerkletree::Tree,
|
||||
pasta::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{ff::Field, Curve, Group},
|
||||
pallas,
|
||||
},
|
||||
tx::ContractCall,
|
||||
ContractCall,
|
||||
};
|
||||
use darkfi_serial::{Decodable, Encodable};
|
||||
use log::debug;
|
||||
@@ -41,7 +32,7 @@ use darkfi_dao_contract::{
|
||||
dao_client,
|
||||
dao_client::{exec as dao_exec_client, propose as dao_propose_client, vote as dao_vote_client},
|
||||
money_client, note,
|
||||
wallet_cache::{MerkleTree, WalletCache},
|
||||
wallet_cache::WalletCache,
|
||||
DaoFunction,
|
||||
};
|
||||
|
||||
|
||||
@@ -27,32 +27,18 @@
|
||||
|
||||
use chacha20poly1305::{AeadInPlace, ChaCha20Poly1305, KeyInit};
|
||||
use darkfi::{
|
||||
consensus::leadcoin::LeadCoin,
|
||||
zk::{
|
||||
proof::{Proof, ProvingKey},
|
||||
vm::ZkCircuit,
|
||||
vm_stack::Witness,
|
||||
},
|
||||
consensus::LeadCoin,
|
||||
zk::{Proof, ProvingKey, Witness, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
ClientFailed, Error, Result,
|
||||
};
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
constants::MERKLE_DEPTH,
|
||||
diffie_hellman::{kdf_sapling, sapling_ka_agree},
|
||||
pedersen::{pedersen_commitment_base, pedersen_commitment_u64, ValueBlind, ValueCommit},
|
||||
poseidon_hash, Keypair, MerkleNode, Nullifier, PublicKey, SecretKey, TokenId,
|
||||
},
|
||||
incrementalmerkletree,
|
||||
incrementalmerkletree::{bridgetree::BridgeTree, Hashable, Tree},
|
||||
pasta::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{
|
||||
ff::{Field, PrimeField},
|
||||
Curve,
|
||||
},
|
||||
pallas,
|
||||
},
|
||||
use darkfi_sdk::crypto::{
|
||||
diffie_hellman::{kdf_sapling, sapling_ka_agree},
|
||||
merkle_prelude::*,
|
||||
pallas,
|
||||
pasta_prelude::*,
|
||||
pedersen_commitment_base, pedersen_commitment_u64, poseidon_hash, Keypair, MerkleNode,
|
||||
MerklePosition, MerkleTree, Nullifier, PublicKey, SecretKey, TokenId, ValueBlind, ValueCommit,
|
||||
};
|
||||
use darkfi_serial::{serialize, Decodable, Encodable, SerialDecodable, SerialEncodable};
|
||||
use halo2_proofs::circuit::Value;
|
||||
@@ -136,7 +122,7 @@ pub struct OwnCoin {
|
||||
/// Coin's nullifier,
|
||||
pub nullifier: Nullifier,
|
||||
/// Coin's leaf position in the Merkle tree of coins
|
||||
pub leaf_position: incrementalmerkletree::Position,
|
||||
pub leaf_position: MerklePosition,
|
||||
}
|
||||
|
||||
/// The `Note` holds the inner attributes of a `Coin`
|
||||
@@ -227,7 +213,7 @@ struct TransactionBuilderClearInputInfo {
|
||||
}
|
||||
|
||||
struct TransactionBuilderInputInfo {
|
||||
pub leaf_position: incrementalmerkletree::Position,
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub secret: SecretKey,
|
||||
pub note: Note,
|
||||
@@ -262,7 +248,7 @@ impl TransferBurnRevealed {
|
||||
user_data_blind: pallas::Base,
|
||||
coin_blind: pallas::Base,
|
||||
secret_key: SecretKey,
|
||||
leaf_position: incrementalmerkletree::Position,
|
||||
leaf_position: MerklePosition,
|
||||
merkle_path: Vec<MerkleNode>,
|
||||
signature_secret: SecretKey,
|
||||
) -> Self {
|
||||
@@ -450,7 +436,7 @@ pub fn create_transfer_burn_proof(
|
||||
user_data_blind: pallas::Base,
|
||||
coin_blind: pallas::Base,
|
||||
secret_key: SecretKey,
|
||||
leaf_position: incrementalmerkletree::Position,
|
||||
leaf_position: MerklePosition,
|
||||
merkle_path: Vec<MerkleNode>,
|
||||
signature_secret: SecretKey,
|
||||
) -> Result<(Proof, TransferBurnRevealed)> {
|
||||
@@ -602,12 +588,12 @@ fn create_unstake_burn_proof(
|
||||
public_key: pallas::Base,
|
||||
sk: pallas::Base,
|
||||
sk_root: pallas::Base,
|
||||
sk_pos: incrementalmerkletree::Position,
|
||||
sk_pos: MerklePosition,
|
||||
sk_path: Vec<MerkleNode>,
|
||||
commitment_merkle_path: Vec<MerkleNode>,
|
||||
commitment: pallas::Point,
|
||||
commitment_root: pallas::Base,
|
||||
commitment_pos: incrementalmerkletree::Position,
|
||||
commitment_pos: MerklePosition,
|
||||
slot: u64,
|
||||
nonce: pallas::Base,
|
||||
nullifier: pallas::Base,
|
||||
@@ -665,7 +651,7 @@ pub fn build_half_swap_tx(
|
||||
value_blinds: &[ValueBlind],
|
||||
token_blinds: &[ValueBlind],
|
||||
coins: &[OwnCoin],
|
||||
tree: &BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
tree: &MerkleTree,
|
||||
mint_zkbin: &ZkBinary,
|
||||
mint_pk: &ProvingKey,
|
||||
burn_zkbin: &ZkBinary,
|
||||
@@ -856,7 +842,7 @@ pub fn build_transfer_tx(
|
||||
value: u64,
|
||||
token_id: TokenId,
|
||||
coins: &[OwnCoin],
|
||||
tree: &BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
tree: &MerkleTree,
|
||||
mint_zkbin: &ZkBinary,
|
||||
mint_pk: &ProvingKey,
|
||||
burn_zkbin: &ZkBinary,
|
||||
@@ -1070,9 +1056,9 @@ pub fn build_transfer_tx(
|
||||
pub fn build_stake_tx(
|
||||
//pubkey: &PublicKey,
|
||||
coins: &[OwnCoin],
|
||||
tx_tree: &mut BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
cm_tree: &mut BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
sk_tree: &mut BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
tx_tree: &mut MerkleTree,
|
||||
cm_tree: &mut MerkleTree,
|
||||
sk_tree: &mut MerkleTree,
|
||||
mint_zkbin: &ZkBinary,
|
||||
mint_pk: &ProvingKey,
|
||||
burn_zkbin: &ZkBinary,
|
||||
@@ -1204,12 +1190,12 @@ pub fn build_unstake_tx(
|
||||
pk,
|
||||
coin.coin1_sk,
|
||||
coin.coin1_sk_root.inner(),
|
||||
incrementalmerkletree::Position::from(coin.coin1_sk_pos as usize),
|
||||
MerklePosition::from(coin.coin1_sk_pos as usize),
|
||||
coin.coin1_sk_merkle_path.to_vec(),
|
||||
coin.coin1_commitment_merkle_path.to_vec(),
|
||||
coin.coin1_commitment,
|
||||
coin.coin1_commitment_root.inner(),
|
||||
incrementalmerkletree::Position::from(coin.coin1_commitment_pos as usize),
|
||||
MerklePosition::from(coin.coin1_commitment_pos as usize),
|
||||
coin.slot,
|
||||
coin.nonce,
|
||||
nullifier,
|
||||
|
||||
@@ -19,21 +19,13 @@
|
||||
#[cfg(not(feature = "no-entrypoint"))]
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
pedersen::{pedersen_commitment_base, pedersen_commitment_u64},
|
||||
token_id::DARK_TOKEN_ID,
|
||||
Coin, ContractId, MerkleNode, MerkleTree, PublicKey,
|
||||
pallas, pasta_prelude::*, pedersen_commitment_base, pedersen_commitment_u64, Coin,
|
||||
ContractId, MerkleNode, MerkleTree, PublicKey, DARK_TOKEN_ID,
|
||||
},
|
||||
db::{db_contains_key, db_get, db_init, db_lookup, db_set, SMART_CONTRACT_ZKAS_DB_NAME},
|
||||
error::ContractResult,
|
||||
merkle::merkle_add,
|
||||
msg,
|
||||
pasta::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{Curve, Group},
|
||||
pallas,
|
||||
},
|
||||
tx::ContractCall,
|
||||
util::set_return_data,
|
||||
msg, set_return_data, ContractCall,
|
||||
};
|
||||
|
||||
use darkfi_sdk::error::ContractError;
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
pedersen::{ValueBlind, ValueCommit},
|
||||
Coin, MerkleNode, Nullifier, PublicKey, TokenId,
|
||||
},
|
||||
pasta::pallas,
|
||||
use darkfi_sdk::crypto::{
|
||||
pallas, Coin, MerkleNode, Nullifier, PublicKey, TokenId, ValueBlind, ValueCommit,
|
||||
};
|
||||
use darkfi_serial::{SerialDecodable, SerialEncodable};
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
use darkfi::{tx::Transaction, Result};
|
||||
use darkfi_sdk::{
|
||||
crypto::{poseidon_hash, MerkleNode, Nullifier, TokenId},
|
||||
incrementalmerkletree::Tree,
|
||||
pasta::{group::ff::Field, pallas},
|
||||
tx::ContractCall,
|
||||
crypto::{
|
||||
merkle_prelude::*, pallas, pasta_prelude::*, poseidon_hash, MerkleNode, Nullifier, TokenId,
|
||||
},
|
||||
ContractCall,
|
||||
};
|
||||
use darkfi_serial::Encodable;
|
||||
use log::info;
|
||||
|
||||
@@ -19,27 +19,21 @@ use std::collections::HashMap;
|
||||
|
||||
use darkfi::{
|
||||
consensus::{
|
||||
constants::{
|
||||
TESTNET_BOOTSTRAP_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_TIMESTAMP,
|
||||
TESTNET_INITIAL_DISTRIBUTION,
|
||||
},
|
||||
ValidatorState, ValidatorStatePtr,
|
||||
ValidatorState, ValidatorStatePtr, TESTNET_BOOTSTRAP_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES,
|
||||
TESTNET_GENESIS_TIMESTAMP, TESTNET_INITIAL_DISTRIBUTION,
|
||||
},
|
||||
tx::Transaction,
|
||||
wallet::WalletDb,
|
||||
zk::{proof::ProvingKey, vm::ZkCircuit, vm_stack::empty_witnesses},
|
||||
zk::{empty_witnesses, ProvingKey, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
use darkfi_sdk::{
|
||||
crypto::{
|
||||
constants::MERKLE_DEPTH, contract_id::MONEY_CONTRACT_ID, ContractId, Keypair, MerkleNode,
|
||||
PublicKey, TokenId,
|
||||
pasta_prelude::*, ContractId, Keypair, MerkleTree, PublicKey, TokenId, MONEY_CONTRACT_ID,
|
||||
},
|
||||
db::SMART_CONTRACT_ZKAS_DB_NAME,
|
||||
incrementalmerkletree::bridgetree::BridgeTree,
|
||||
pasta::group::ff::PrimeField,
|
||||
tx::ContractCall,
|
||||
ContractCall,
|
||||
};
|
||||
use darkfi_serial::{serialize, Encodable};
|
||||
use log::{info, warn};
|
||||
@@ -83,10 +77,10 @@ pub struct MoneyTestHarness {
|
||||
pub burn_zkbin: ZkBinary,
|
||||
pub mint_pk: ProvingKey,
|
||||
pub burn_pk: ProvingKey,
|
||||
pub faucet_merkle_tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
pub alice_merkle_tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
pub bob_merkle_tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
pub charlie_merkle_tree: BridgeTree<MerkleNode, MERKLE_DEPTH>,
|
||||
pub faucet_merkle_tree: MerkleTree,
|
||||
pub alice_merkle_tree: MerkleTree,
|
||||
pub bob_merkle_tree: MerkleTree,
|
||||
pub charlie_merkle_tree: MerkleTree,
|
||||
}
|
||||
|
||||
impl MoneyTestHarness {
|
||||
@@ -185,10 +179,10 @@ impl MoneyTestHarness {
|
||||
];
|
||||
proving_keys.insert(money_contract_id.inner().to_repr(), pks);
|
||||
|
||||
let faucet_merkle_tree = BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(100);
|
||||
let alice_merkle_tree = BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(100);
|
||||
let bob_merkle_tree = BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(100);
|
||||
let charlie_merkle_tree = BridgeTree::<MerkleNode, MERKLE_DEPTH>::new(100);
|
||||
let faucet_merkle_tree = MerkleTree::new(100);
|
||||
let alice_merkle_tree = MerkleTree::new(100);
|
||||
let bob_merkle_tree = MerkleTree::new(100);
|
||||
let charlie_merkle_tree = MerkleTree::new(100);
|
||||
|
||||
Ok(Self {
|
||||
faucet_kp,
|
||||
|
||||
@@ -20,10 +20,11 @@ use std::{env, str::FromStr};
|
||||
|
||||
use darkfi::{tx::Transaction, Result};
|
||||
use darkfi_sdk::{
|
||||
crypto::{contract_id::MONEY_CONTRACT_ID, poseidon_hash, MerkleNode, Nullifier, TokenId},
|
||||
incrementalmerkletree::Tree,
|
||||
pasta::{group::ff::Field, pallas},
|
||||
tx::ContractCall,
|
||||
crypto::{
|
||||
merkle_prelude::*, pallas, pasta_prelude::*, poseidon_hash, MerkleNode, Nullifier, TokenId,
|
||||
MONEY_CONTRACT_ID,
|
||||
},
|
||||
ContractCall,
|
||||
};
|
||||
use darkfi_serial::Encodable;
|
||||
use log::info;
|
||||
|
||||
@@ -47,25 +47,45 @@ pub use coin::Coin;
|
||||
|
||||
/// Contract ID definitions and methods
|
||||
pub mod contract_id;
|
||||
pub use contract_id::ContractId;
|
||||
pub use contract_id::{ContractId, DAO_CONTRACT_ID, MONEY_CONTRACT_ID};
|
||||
|
||||
/// Token ID definitions and methods
|
||||
pub mod token_id;
|
||||
pub use token_id::TokenId;
|
||||
pub use token_id::{TokenId, DARK_TOKEN_ID};
|
||||
|
||||
/// Merkle node definitions
|
||||
pub mod merkle_node;
|
||||
pub use merkle_node::{MerkleNode, MerkleTree};
|
||||
|
||||
pub mod merkle_prelude {
|
||||
pub use incrementalmerkletree::{Hashable, Tree};
|
||||
}
|
||||
pub use incrementalmerkletree::Position as MerklePosition;
|
||||
|
||||
/// Nullifier definitions
|
||||
pub mod nullifier;
|
||||
pub use nullifier::Nullifier;
|
||||
|
||||
/// Pedersen commitment utilities
|
||||
pub mod pedersen;
|
||||
pub use pedersen::{pedersen_commitment_base, pedersen_commitment_u64, ValueBlind, ValueCommit};
|
||||
|
||||
/// Schnorr signature traits
|
||||
pub mod schnorr;
|
||||
|
||||
/// MiMC VDF
|
||||
pub mod mimc_vdf;
|
||||
|
||||
pub use incrementalmerkletree;
|
||||
pub use pasta_curves::{pallas, vesta};
|
||||
/// Convenience module to import all the pasta traits.
|
||||
/// You still have to import the curves.
|
||||
pub mod pasta_prelude {
|
||||
pub use pasta_curves::{
|
||||
arithmetic::CurveAffine,
|
||||
group::{
|
||||
ff::{Field, PrimeField},
|
||||
Curve, Group,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -36,9 +36,12 @@ pub mod crypto;
|
||||
|
||||
/// Merkle
|
||||
pub mod merkle;
|
||||
pub use merkle::merkle_add;
|
||||
|
||||
/// Transaction structure
|
||||
pub mod tx;
|
||||
pub use tx::ContractCall;
|
||||
|
||||
/// Utilities
|
||||
pub mod util;
|
||||
pub use util::set_return_data;
|
||||
|
||||
@@ -18,16 +18,20 @@
|
||||
|
||||
/// Halo2 zkas virtual machine
|
||||
pub mod vm;
|
||||
pub use vm::ZkCircuit;
|
||||
|
||||
pub mod vm_stack;
|
||||
pub use vm_stack::{empty_witnesses, Witness};
|
||||
|
||||
/// ZK gadget implementations
|
||||
pub mod gadget;
|
||||
|
||||
/// Proof creation API
|
||||
pub mod proof;
|
||||
pub use proof::Proof;
|
||||
pub use proof::{Proof, ProvingKey};
|
||||
|
||||
use halo2_proofs::{
|
||||
// I thought about putting this in a sub-module called halo2
|
||||
pub use halo2_proofs::{
|
||||
arithmetic::Field,
|
||||
circuit::{AssignedCell, Layouter, Value},
|
||||
plonk,
|
||||
|
||||
Reference in New Issue
Block a user