|
| 1 | +#![no_std] |
| 2 | +#![doc = include_str!("../README.md")] |
| 3 | +#![doc( |
| 4 | + html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", |
| 5 | + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg" |
| 6 | +)] |
| 7 | +#![cfg_attr(docsrs, feature(doc_auto_cfg))] |
| 8 | +#![forbid(unsafe_code)] |
| 9 | +#![warn( |
| 10 | + clippy::mod_module_files, |
| 11 | + clippy::unwrap_used, |
| 12 | + missing_docs, |
| 13 | + rust_2018_idioms, |
| 14 | + unused_lifetimes, |
| 15 | + missing_debug_implementations, |
| 16 | + unused_qualifications |
| 17 | +)] |
| 18 | + |
| 19 | +//! # Design |
| 20 | +//! |
| 21 | +//! Traits are defined to match the functionality of verifiable random functions in |
| 22 | +//! [RFC9381](https://www.rfc-editor.org/rfc/rfc9381.pdf). |
| 23 | +//! |
| 24 | +//! ## Verifying Proofs |
| 25 | +//! |
| 26 | +//! Trait based proof verification is delegated to the [`signature::Verifier`] trait, defined in |
| 27 | +//! the `signature` crate and re-exported here. The message corresponds to the `alpha` or |
| 28 | +//! `alpha_string` in RFC9381 (see section 1.2), and the signature corresponds to the [`Proof`]. |
| 29 | +
|
1 | 30 | use digest::{Output, OutputSizeUser};
|
2 | 31 |
|
3 | 32 | pub use signature::Verifier;
|
4 | 33 |
|
| 34 | + |
| 35 | +/// A VRF Proof, denoted `pi` or `pi_string` in RFC9381. See RFC9381 section 1.2 for details. |
5 | 36 | pub trait Proof<H>
|
6 | 37 | where
|
7 | 38 | H: OutputSizeUser,
|
8 | 39 | {
|
| 40 | + /// Get the hash of the VRF proof. |
| 41 | + /// |
| 42 | + /// Defined as `VRF_proof_to_hash` in RFC9381 section 2. |
9 | 43 | fn to_hash(&self) -> Output<H>;
|
10 | 44 | }
|
11 | 45 |
|
| 46 | +/// A cryptographic key that has the capability to generate VRF proofs. |
12 | 47 | pub trait Prover<H>
|
13 | 48 | where
|
14 | 49 | H: OutputSizeUser,
|
15 | 50 | {
|
| 51 | + /// Proofs generated by this algorithm. |
16 | 52 | type Proof: Proof<H>;
|
17 | 53 |
|
| 54 | + /// Generate a proof from the given alpha value. |
| 55 | + /// |
| 56 | + /// defined as `VRF_proof` in RFC9381 section 2. |
18 | 57 | fn prove(&self, alpha: &[u8]) -> Self::Proof;
|
19 | 58 | }
|
0 commit comments