1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::VRF;
use failure::Error;
pub struct DummyVRF;
pub const SECRET_KEY_SIZE: usize = 32;
pub const PUBLIC_KEY_SIZE: usize = 33;
pub type SecretKey<'a> = &'a [u8; SECRET_KEY_SIZE];
pub type PublicKey<'a> = &'a [u8; PUBLIC_KEY_SIZE];
impl<'a> VRF<PublicKey<'a>, SecretKey<'a>> for DummyVRF {
type Error = Error;
fn prove(&mut self, _x: SecretKey, _alpha: &[u8]) -> Result<Vec<u8>, Self::Error> {
Ok(vec![])
}
fn verify(&mut self, _y: PublicKey, _pi: &[u8], _alpha: &[u8]) -> Result<Vec<u8>, Self::Error> {
Ok(vec![])
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_prove() {
let x = [0; 32];
let alpha = [0, 0, 0];
let proof = DummyVRF.prove(&x, &alpha);
assert_eq!(proof.unwrap(), vec![]);
}
#[test]
fn test_verify() {
let y = [0; 33];
let pi = [0];
let alpha = [0, 0, 0];
assert_eq!(DummyVRF.verify(&y, &pi, &alpha).unwrap(), vec![]);
}
}