|
|
@@ -28,17 +28,20 @@ use darkfi_money_contract::{
|
|
|
model::{ConsensusInput, ConsensusOutput, ConsensusUnstakeReqParamsV1},
|
|
|
};
|
|
|
use darkfi_sdk::{
|
|
|
- crypto::{note::AeadEncryptedNote, pasta_prelude::*, Keypair, MerkleTree, SecretKey, poseidon_hash},
|
|
|
+ crypto::{
|
|
|
+ note::AeadEncryptedNote, pasta_prelude::*, poseidon_hash, Keypair, MerkleTree, SecretKey,
|
|
|
+ },
|
|
|
pasta::pallas,
|
|
|
};
|
|
|
use log::{debug, info};
|
|
|
use rand::rngs::OsRng;
|
|
|
|
|
|
use crate::{
|
|
|
- client::common::{create_consensus_burn_proof, create_consensus_mint_proof, ConsensusBurnInputInfo, ConsensusMintOutputInfo},
|
|
|
- model::{
|
|
|
- SERIAL_PREFIX,
|
|
|
+ client::common::{
|
|
|
+ create_consensus_burn_proof, create_consensus_mint_proof, ConsensusBurnInputInfo,
|
|
|
+ ConsensusMintOutputInfo,
|
|
|
},
|
|
|
+ model::{SECRET_KEY_PREFIX, SERIAL_PREFIX},
|
|
|
};
|
|
|
|
|
|
pub struct ConsensusUnstakeRequestCallDebris {
|
|
|
@@ -87,11 +90,11 @@ impl ConsensusUnstakeRequestCallBuilder {
|
|
|
};
|
|
|
|
|
|
debug!("Building Consensus::UnstakeRequestV1 anonymous output");
|
|
|
- //let output_serial = pallas::Base::random(&mut OsRng);
|
|
|
- // derive output secret from old secret key.
|
|
|
- let output_secret = poseidon_hash([self.owncoin.secret.inner()]);
|
|
|
- let output_keypair = Keypair::new(SecretKey::from(output_secret));
|
|
|
- let output_serial = poseidon_hash([SERIAL_PREFIX, self.owncoin.secret.inner(), self.owncoin.note.serial]);
|
|
|
+ // The output's secret key is derived from the old secret key
|
|
|
+ let output_secret_key = poseidon_hash([SECRET_KEY_PREFIX, self.owncoin.secret.inner()]);
|
|
|
+ let output_keypair = Keypair::new(SecretKey::from(output_secret_key));
|
|
|
+ let output_serial =
|
|
|
+ poseidon_hash([SERIAL_PREFIX, self.owncoin.secret.inner(), self.owncoin.note.serial]);
|
|
|
let output_coin_blind = pallas::Base::random(&mut OsRng);
|
|
|
|
|
|
// We create a new random keypair for the output
|