#![allow(non_snake_case)] use curve25519_dalek::ristretto::RistrettoPoint as G; use group::ff::PrimeField; use group::Group; use sigma_compiler::*; fn pubstatements_with_a(a_val: u128) -> Result<(), Box> { sigma_compiler! { proof, (x, pub a), (C, D, const cind B), C = a*x*B, D = a*B, } type Scalar = ::Scalar; let mut rng = rand::thread_rng(); let B = G::generator(); let x = Scalar::from_u128(5); let a = Scalar::from_u128(a_val); let C = a * x * B; let D = a * B; let instance = proof::Instance { C, D, B, a }; let witness = proof::Witness { x }; let proof = proof::prove(&instance, &witness, b"pubstatements_test", &mut rng)?; Ok(proof::verify(&instance, &proof, b"pubstatements_test")?) } #[test] fn pubstatements_test() -> Result<(), Box> { // a = 0 sends both images to the identity, and sigma-proofs refuses an // instance that carries an identity group element. assert!(pubstatements_with_a(0).is_err()); pubstatements_with_a(7) }