|
|
@@ -105,49 +105,3 @@ impl Proof {
|
|
|
Proof(bytes)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-#[cfg(test)]
|
|
|
-mod tests {
|
|
|
- use super::*;
|
|
|
- use crate::{crypto::mint_proof::create_mint_proof, zk::circuit::MintContract, Result};
|
|
|
- use darkfi_sdk::{
|
|
|
- crypto::{PublicKey, SecretKey, TokenId},
|
|
|
- pasta::{group::ff::Field, pallas},
|
|
|
- };
|
|
|
- use darkfi_serial::{Decodable, Encodable};
|
|
|
- use rand::rngs::OsRng;
|
|
|
-
|
|
|
- #[test]
|
|
|
- fn test_proof_serialization() -> Result<()> {
|
|
|
- let value = 110_u64;
|
|
|
- let token_id = TokenId::from(pallas::Base::random(&mut OsRng));
|
|
|
- let value_blind = ValueBlind::random(&mut OsRng);
|
|
|
- let token_blind = ValueBlind::random(&mut OsRng);
|
|
|
- let serial = pallas::Base::random(&mut OsRng);
|
|
|
- let spend_hook = pallas::Base::random(&mut OsRng);
|
|
|
- let user_data = pallas::Base::random(&mut OsRng);
|
|
|
- let coin_blind = pallas::Base::random(&mut OsRng);
|
|
|
- let public_key = PublicKey::from_secret(SecretKey::random(&mut OsRng));
|
|
|
-
|
|
|
- let pk = ProvingKey::build(11, &MintContract::default());
|
|
|
- let (proof, _) = create_mint_proof(
|
|
|
- &pk,
|
|
|
- value,
|
|
|
- token_id,
|
|
|
- value_blind,
|
|
|
- token_blind,
|
|
|
- serial,
|
|
|
- spend_hook,
|
|
|
- user_data,
|
|
|
- coin_blind,
|
|
|
- public_key,
|
|
|
- )?;
|
|
|
-
|
|
|
- let mut buf = vec![];
|
|
|
- proof.encode(&mut buf)?;
|
|
|
- let deserialized_proof: Proof = Decodable::decode(&mut buf.as_slice())?;
|
|
|
- assert_eq!(proof.as_ref(), deserialized_proof.as_ref());
|
|
|
-
|
|
|
- Ok(())
|
|
|
- }
|
|
|
-}
|