mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
WIP: contract/consensus/client/proposal: verify coin value is less than slot target before creating proof
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
//! This API is crufty. Please rework it into something nice to read and nice to use.
|
||||
|
||||
use darkfi::{
|
||||
error::Error::CoinIsNotSlotProducer,
|
||||
zk::{halo2::Value, Proof, ProvingKey, Witness, ZkCircuit},
|
||||
zkas::ZkBinary,
|
||||
Result,
|
||||
@@ -250,6 +251,16 @@ fn create_proposal_proof(
|
||||
let mu_rho = poseidon_hash([MU_RHO_PREFIX, eta, pallas::Base::from(slot.id)]);
|
||||
let rho = poseidon_hash([seed, mu_rho]);
|
||||
|
||||
// Verify coin is the slot block producer
|
||||
let value_pallas = pallas::Base::from(input.note.value);
|
||||
let shifted_target =
|
||||
slot.sigma1 * value_pallas + slot.sigma2 * value_pallas * value_pallas + HEADSTART;
|
||||
// TODO: this check is true, while the proof can be created and is valid, when it shouldn't
|
||||
if y >= shifted_target {
|
||||
info!("1) What");
|
||||
//return Err(CoinIsNotSlotProducer)
|
||||
}
|
||||
|
||||
// Derive the input's nullifier
|
||||
let nullifier = Nullifier::from(poseidon_hash([input.secret.inner(), input.note.serial]));
|
||||
|
||||
|
||||
@@ -236,6 +236,9 @@ pub enum Error {
|
||||
#[error("Public inputs are invalid")]
|
||||
InvalidPublicInputsError,
|
||||
|
||||
#[error("Coin is not the slot block producer")]
|
||||
CoinIsNotSlotProducer,
|
||||
|
||||
#[error("Error during leader proof verification")]
|
||||
LeaderProofVerification,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user