1515// See the License for the specific language governing permissions and
1616// limitations under the License.
1717
18- //! Utilities related to VRF input, output and signatures.
18+ //! Utilities related to VRF input, pre- output and signatures.
1919
2020use crate :: { Randomness , TicketBody , TicketId } ;
2121use scale_codec:: Encode ;
@@ -24,7 +24,7 @@ use sp_std::vec::Vec;
2424
2525pub use sp_core:: bandersnatch:: {
2626 ring_vrf:: { RingProver , RingVerifier , RingVerifierData , RingVrfSignature } ,
27- vrf:: { VrfInput , VrfOutput , VrfSignData , VrfSignature } ,
27+ vrf:: { VrfInput , VrfPreOutput , VrfSignData , VrfSignature } ,
2828} ;
2929
3030/// Ring VRF domain size for Sassafras consensus.
@@ -90,21 +90,21 @@ pub fn ticket_body_sign_data(ticket_body: &TicketBody, ticket_id_input: VrfInput
9090 )
9191}
9292
93- /// Make ticket-id from the given VRF input and output.
93+ /// Make ticket-id from the given VRF input and pre- output.
9494///
9595/// Input should have been obtained via [`ticket_id_input`].
96- /// Output should have been obtained from the input directly using the vrf secret key
97- /// or from the vrf signature outputs.
98- pub fn make_ticket_id ( input : & VrfInput , output : & VrfOutput ) -> TicketId {
99- let bytes = output . make_bytes :: < 16 > ( b"ticket-id" , input) ;
96+ /// Pre-output should have been obtained from the input directly using the vrf
97+ /// secret key or from the vrf signature pre- outputs.
98+ pub fn make_ticket_id ( input : & VrfInput , pre_output : & VrfPreOutput ) -> TicketId {
99+ let bytes = pre_output . make_bytes :: < 16 > ( b"ticket-id" , input) ;
100100 u128:: from_le_bytes ( bytes)
101101}
102102
103- /// Make revealed key seed from a given VRF input and ouput.
103+ /// Make revealed key seed from a given VRF input and pre- ouput.
104104///
105105/// Input should have been obtained via [`revealed_key_input`].
106- /// Output should have been obtained from the input directly using the vrf secret key
107- /// or from the vrf signature outputs.
108- pub fn make_revealed_key_seed ( input : & VrfInput , output : & VrfOutput ) -> [ u8 ; 32 ] {
109- output . make_bytes :: < 32 > ( b"revealed-seed" , input)
106+ /// Pre-output should have been obtained from the input directly using the vrf
107+ /// secret key or from the vrf signature pre- outputs.
108+ pub fn make_revealed_key_seed ( input : & VrfInput , pre_output : & VrfPreOutput ) -> [ u8 ; 32 ] {
109+ pre_output . make_bytes :: < 32 > ( b"revealed-seed" , input)
110110}
0 commit comments