File tree 1 file changed +32
-0
lines changed
core/src/consensus/sortition
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 17
17
mod binom_cdf;
18
18
mod lot;
19
19
mod vrf_sortition;
20
+
21
+ use std:: sync:: Arc ;
22
+
23
+ use ckey:: Public ;
24
+ use primitives:: H256 ;
25
+ use vrf:: openssl:: Error as VrfError ;
26
+
27
+ use self :: vrf_sortition:: { PriorityInfo , VRFSortition } ;
28
+
29
+ pub struct PriorityMessage {
30
+ pub seed : H256 ,
31
+ pub info : PriorityInfo ,
32
+ pub signer_index : usize ,
33
+ }
34
+
35
+ impl PriorityMessage {
36
+ pub fn signer_index ( & self ) -> usize {
37
+ self . signer_index
38
+ }
39
+
40
+ pub fn verify (
41
+ & self ,
42
+ signer_public : & Public ,
43
+ voting_power : u64 ,
44
+ sortition_scheme : & VRFSortition ,
45
+ ) -> Result < bool , VrfError > {
46
+ // fast verification first
47
+ Ok ( self . info . verify_sub_user_idx ( voting_power, sortition_scheme. total_power , sortition_scheme. expectation )
48
+ && self . info . verify_priority ( )
49
+ && self . info . verify_vrf_hash ( signer_public, & self . seed , Arc :: clone ( & sortition_scheme. vrf_inst ) ) ?)
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments