From b488355e1373ea3027c12f58b7454d79d7e0d485 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Tue, 2 Feb 2021 12:39:58 -0700 Subject: [PATCH] Add example to hash_to_curve doc comment. --- src/arithmetic/curves.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/arithmetic/curves.rs b/src/arithmetic/curves.rs index 07d5320..35dce17 100644 --- a/src/arithmetic/curves.rs +++ b/src/arithmetic/curves.rs @@ -80,9 +80,21 @@ pub trait Curve: fn jacobian_coordinates(&self) -> (Self::Base, Self::Base, Self::Base); /// Requests a hasher that accepts messages and returns near-uniformly - /// distributed elements in the group, given domain prefix `hasher`. + /// distributed elements in the group, given domain prefix `domain_prefix`. /// /// This method is suitable for use as a random oracle. + /// + /// # Example + /// + /// ``` + /// use halo2::arithmetic::{Curve, CurveAffine}; + /// fn pedersen_commitment(x: C::Scalar, r: C::Scalar) -> C { + /// let hasher = C::Projective::hash_to_curve("z.cash:example_pedersen_commitment"); + /// let g = hasher(b"g"); + /// let h = hasher(b"h"); + /// (g * x + h * r).to_affine() + /// } + /// ``` fn hash_to_curve(domain_prefix: &str) -> Box Self + 'static>; /// Returns whether or not this element is on the curve; should