// Copyright 2018 Yobicash Ltd. See the COPYRIGHT file at the top-level directory // of this distribution. // // Licensed under the MIT license // and the Apache 2.0 license . // This file may not be copied, modified, or distributed except according to those // terms. //! Yobicrypto `zkp` module tests. extern crate yobicrypto; use yobicrypto::{Random, Scalar, ZKPWitness, ZKPProof}; #[test] fn schnorr_protocol_verify_succ() { let instance = Scalar::random(); let witness = ZKPWitness::new(instance).unwrap(); let message = Random::bytes(64); let proof = ZKPProof::new(instance, &message).unwrap(); let verified = proof.verify(witness).unwrap(); assert!(verified) } #[test] fn schnorr_protocol_verify_fail() { let instance = Scalar::random(); let message = Random::bytes(64); let proof = ZKPProof::new(instance, &message).unwrap(); let faulty_instance = Scalar::random(); let faulty_witness = ZKPWitness::new(faulty_instance).unwrap(); let verified = proof.verify(faulty_witness).unwrap(); assert!(!verified) }