forked from witnet/vrf-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ecvrf): add support for secp256k1 with Sha256
Co-authored-by: Gorka Irazoqui <[email protected]>
- Loading branch information
Showing
3 changed files
with
78 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
pub mod dummy; | ||
pub mod openssl; | ||
|
||
/// A trait for a Verifiable Random Functions (VRF) | ||
/// implementations. | ||
/// A trait for a Verifiable Random Functions (VRF) implementations. | ||
pub trait VRF<PublicKey, SecretKey> { | ||
type Error; | ||
|
||
/// Generate proof from key pair and message | ||
/// Generates proof from a secret key and message | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `x` - A secret key | ||
/// * `alpha` - A slice representing the message in octets | ||
/// | ||
/// # Returns | ||
/// | ||
/// * If successful, a vector of octets representing the proof of the VRF | ||
fn prove(&mut self, x: SecretKey, alpha: &[u8]) -> Result<Vec<u8>, Self::Error>; | ||
|
||
/// Verify proof given public key, proof and message | ||
/// Verifies the provided VRF proof and computes the VRF hash output | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `y` - A public key | ||
/// * `pi` - A slice of octets representing the VRF proof | ||
/// | ||
/// # Returns | ||
/// | ||
/// * If successful, a vector of octets with the VRF hash output | ||
fn verify(&mut self, y: PublicKey, pi: &[u8], alpha: &[u8]) -> Result<Vec<u8>, Self::Error>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters