mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
Get contract/dao to compile.
This commit is contained in:
@@ -51,8 +51,7 @@ pub struct DaoProposeNote {
|
||||
|
||||
pub struct DaoProposeStakeInput {
|
||||
pub secret: SecretKey,
|
||||
//pub note: money::transfer::wallet::Note,
|
||||
pub note: darkfi_money_contract::client::Note,
|
||||
pub note: darkfi_money_contract::client::MoneyNote,
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub signature_secret: SecretKey,
|
||||
|
||||
@@ -47,8 +47,7 @@ pub struct DaoVoteNote {
|
||||
|
||||
pub struct DaoVoteInput {
|
||||
pub secret: SecretKey,
|
||||
//pub note: money::transfer::wallet::Note,
|
||||
pub note: darkfi_money_contract::client::Note,
|
||||
pub note: darkfi_money_contract::client::MoneyNote,
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub signature_secret: SecretKey,
|
||||
|
||||
@@ -16,20 +16,30 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! TODO: This file should be deleted and the API from money::client
|
||||
//! should be used directly.
|
||||
|
||||
use darkfi::{
|
||||
zk::{Proof, ProvingKey},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
};
|
||||
use darkfi_sdk::crypto::{
|
||||
pallas, pasta_prelude::*, MerkleNode, MerklePosition, PublicKey, SecretKey, TokenId, ValueBlind,
|
||||
note::AeadEncryptedNote, pallas, pasta_prelude::*, MerkleNode, MerklePosition, PublicKey,
|
||||
SecretKey, TokenId, ValueBlind,
|
||||
};
|
||||
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
use darkfi_money_contract::{
|
||||
client::{create_transfer_burn_proof, create_transfer_mint_proof, Note},
|
||||
model::{ClearInput, Input, MoneyTransferParams, Output},
|
||||
client::{
|
||||
transfer_v1::{
|
||||
create_transfer_burn_proof, create_transfer_mint_proof, TransactionBuilderInputInfo,
|
||||
TransactionBuilderOutputInfo,
|
||||
},
|
||||
MoneyNote,
|
||||
},
|
||||
model::{ClearInput, Input, MoneyTransferParamsV1, Output},
|
||||
};
|
||||
|
||||
pub struct TransferCall {
|
||||
@@ -48,7 +58,7 @@ pub struct TransferInput {
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub secret: SecretKey,
|
||||
pub note: Note,
|
||||
pub note: MoneyNote,
|
||||
pub user_data_blind: pallas::Base,
|
||||
pub value_blind: ValueBlind,
|
||||
pub signature_secret: SecretKey,
|
||||
@@ -93,7 +103,7 @@ impl TransferCall {
|
||||
mint_pk: &ProvingKey,
|
||||
burn_zkbin: &ZkBinary,
|
||||
burn_pk: &ProvingKey,
|
||||
) -> Result<(MoneyTransferParams, Vec<Proof>)> {
|
||||
) -> Result<(MoneyTransferParamsV1, Vec<Proof>)> {
|
||||
assert!(self.clear_inputs.len() + self.inputs.len() > 0);
|
||||
|
||||
let mut clear_inputs = vec![];
|
||||
@@ -120,24 +130,21 @@ impl TransferCall {
|
||||
let value_blind = input.value_blind;
|
||||
input_blinds.push(value_blind);
|
||||
|
||||
// Note from the previous output
|
||||
let note = input.note.clone();
|
||||
// FIXME: Just an API hack
|
||||
let _input = TransactionBuilderInputInfo {
|
||||
leaf_position: input.leaf_position,
|
||||
merkle_path: input.merkle_path,
|
||||
secret: input.secret,
|
||||
note: input.note,
|
||||
};
|
||||
|
||||
let (proof, revealed) = create_transfer_burn_proof(
|
||||
burn_zkbin,
|
||||
burn_pk,
|
||||
note.value,
|
||||
note.token_id,
|
||||
&_input,
|
||||
value_blind,
|
||||
token_blind,
|
||||
note.serial,
|
||||
note.spend_hook,
|
||||
note.user_data,
|
||||
input.user_data_blind,
|
||||
note.coin_blind,
|
||||
input.secret,
|
||||
input.leaf_position,
|
||||
input.merkle_path.clone(),
|
||||
input.signature_secret,
|
||||
)?;
|
||||
|
||||
@@ -171,23 +178,28 @@ impl TransferCall {
|
||||
let serial = output.serial;
|
||||
let coin_blind = output.coin_blind;
|
||||
|
||||
// FIXME: This is a hack between the two APIs
|
||||
let _output = TransactionBuilderOutputInfo {
|
||||
value: output.value,
|
||||
token_id: output.token_id,
|
||||
public_key: output.public,
|
||||
};
|
||||
|
||||
let (proof, revealed) = create_transfer_mint_proof(
|
||||
mint_zkbin,
|
||||
mint_pk,
|
||||
output.value,
|
||||
output.token_id,
|
||||
&_output,
|
||||
value_blind,
|
||||
token_blind,
|
||||
serial,
|
||||
output.spend_hook,
|
||||
output.user_data,
|
||||
coin_blind,
|
||||
output.public,
|
||||
)?;
|
||||
|
||||
proofs.push(proof);
|
||||
|
||||
let note = Note {
|
||||
let note = MoneyNote {
|
||||
serial,
|
||||
value: output.value,
|
||||
token_id: output.token_id,
|
||||
@@ -199,18 +211,17 @@ impl TransferCall {
|
||||
memo: Vec::new(),
|
||||
};
|
||||
|
||||
let encrypted_note = note.encrypt(&output.public)?;
|
||||
let encrypted_note = AeadEncryptedNote::encrypt(¬e, &output.public, &mut OsRng)?;
|
||||
|
||||
let output = Output {
|
||||
value_commit: revealed.value_commit,
|
||||
token_commit: revealed.token_commit,
|
||||
coin: revealed.coin.inner(),
|
||||
ciphertext: encrypted_note.ciphertext,
|
||||
ephem_public: encrypted_note.ephem_public,
|
||||
coin: revealed.coin,
|
||||
note: encrypted_note,
|
||||
};
|
||||
outputs.push(output);
|
||||
}
|
||||
|
||||
Ok((MoneyTransferParams { clear_inputs, inputs, outputs }, proofs))
|
||||
Ok((MoneyTransferParamsV1 { clear_inputs, inputs, outputs }, proofs))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
*/
|
||||
|
||||
use darkfi_sdk::crypto::{
|
||||
merkle_prelude::*, Coin, MerkleNode, MerklePosition, MerkleTree, SecretKey,
|
||||
merkle_prelude::*, note::AeadEncryptedNote, Coin, MerkleNode, MerklePosition, MerkleTree,
|
||||
SecretKey,
|
||||
};
|
||||
|
||||
use darkfi_money_contract::client::{EncryptedNote, Note};
|
||||
use darkfi_money_contract::client::MoneyNote;
|
||||
|
||||
pub struct OwnCoin {
|
||||
pub coin: Coin,
|
||||
pub note: Note,
|
||||
pub note: MoneyNote,
|
||||
pub leaf_position: MerklePosition,
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ impl WalletCache {
|
||||
panic!("you forget to track() this secret!");
|
||||
}
|
||||
|
||||
pub fn try_decrypt_note(&mut self, coin: Coin, ciphertext: &EncryptedNote) {
|
||||
pub fn try_decrypt_note(&mut self, coin: Coin, ciphertext: &AeadEncryptedNote) {
|
||||
// Add the new coins to the Merkle tree
|
||||
let node = MerkleNode::from(coin.inner());
|
||||
self.tree.append(&node);
|
||||
|
||||
@@ -168,7 +168,7 @@ impl MintCallBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_token_mint_proof(
|
||||
pub fn create_token_mint_proof(
|
||||
zkbin: &ZkBinary,
|
||||
pk: &ProvingKey,
|
||||
output: &TransactionBuilderOutputInfo,
|
||||
|
||||
@@ -103,20 +103,20 @@ impl TransferBurnRevealed {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct TransactionBuilderClearInputInfo {
|
||||
pub struct TransactionBuilderClearInputInfo {
|
||||
pub value: u64,
|
||||
pub token_id: TokenId,
|
||||
pub signature_secret: SecretKey,
|
||||
}
|
||||
|
||||
pub(crate) struct TransactionBuilderInputInfo {
|
||||
pub struct TransactionBuilderInputInfo {
|
||||
pub leaf_position: MerklePosition,
|
||||
pub merkle_path: Vec<MerkleNode>,
|
||||
pub secret: SecretKey,
|
||||
pub note: MoneyNote,
|
||||
}
|
||||
|
||||
pub(crate) struct TransactionBuilderOutputInfo {
|
||||
pub struct TransactionBuilderOutputInfo {
|
||||
pub value: u64,
|
||||
pub token_id: TokenId,
|
||||
pub public_key: PublicKey,
|
||||
@@ -363,7 +363,7 @@ impl TransferCallBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_transfer_burn_proof(
|
||||
pub fn create_transfer_burn_proof(
|
||||
zkbin: &ZkBinary,
|
||||
pk: &ProvingKey,
|
||||
input: &TransactionBuilderInputInfo,
|
||||
@@ -439,7 +439,7 @@ pub(crate) fn create_transfer_burn_proof(
|
||||
Ok((proof, public_inputs))
|
||||
}
|
||||
|
||||
pub(crate) fn create_transfer_mint_proof(
|
||||
pub fn create_transfer_mint_proof(
|
||||
zkbin: &ZkBinary,
|
||||
pk: &ProvingKey,
|
||||
output: &TransactionBuilderOutputInfo,
|
||||
|
||||
Reference in New Issue
Block a user