11//! Traits for handling hash to curve.
22
33use super :: { ExpandMsg , MapToCurve , hash_to_field} ;
4- use elliptic_curve:: array:: typenum:: Unsigned ;
5- use elliptic_curve:: { ProjectivePoint , Result } ;
4+ use elliptic_curve:: { ProjectivePoint , array:: typenum:: Unsigned } ;
65
76/// Hash arbitrary byte sequences to a valid group element.
87pub trait GroupDigest : MapToCurve {
@@ -22,17 +21,17 @@ pub trait GroupDigest: MapToCurve {
2221 /// > oracle returning points in G assuming a cryptographically secure
2322 /// > hash function is used.
2423 ///
24+ /// For the `expand_message` call, `len_in_bytes = <Self::FieldElement as FromOkm>::Length * 2`.
25+ /// This value must be less than `u16::MAX` or otherwise a compiler error will occur.
26+ ///
2527 /// # Errors
26- /// - `len_in_bytes > u16::MAX`
27- /// - See implementors of [`ExpandMsg`] for additional errors:
28- /// - [`ExpandMsgXmd`]
29- /// - [`ExpandMsgXof`]
3028 ///
31- /// `len_in_bytes = <Self::FieldElement as FromOkm>::Length * 2`
29+ /// When the chosen [`ExpandMsg`] implementation returns an error. See [`ExpandMsgXmdError`]
30+ /// and [`ExpandMsgXofError`] for examples.
3231 ///
33- /// [`ExpandMsgXmd `]: crate::ExpandMsgXmd
34- /// [`ExpandMsgXof `]: crate::ExpandMsgXof
35- fn hash_from_bytes < X > ( msg : & [ & [ u8 ] ] , dst : & [ & [ u8 ] ] ) -> Result < ProjectivePoint < Self > >
32+ /// [`ExpandMsgXmdError `]: crate::ExpandMsgXmdError
33+ /// [`ExpandMsgXofError `]: crate::ExpandMsgXofError
34+ fn hash_from_bytes < X > ( msg : & [ & [ u8 ] ] , dst : & [ & [ u8 ] ] ) -> Result < ProjectivePoint < Self > , X :: Error >
3635 where
3736 X : ExpandMsg < Self :: K > ,
3837 {
@@ -52,17 +51,17 @@ pub trait GroupDigest: MapToCurve {
5251 /// > encode_to_curve is only a fraction of the points in G, and some
5352 /// > points in this set are more likely to be output than others.
5453 ///
54+ /// For the `expand_message` call, `len_in_bytes = <Self::FieldElement as FromOkm>::Length`.
55+ /// This value must be less than `u16::MAX` or otherwise a compiler error will occur.
56+ ///
5557 /// # Errors
56- /// - `len_in_bytes > u16::MAX`
57- /// - See implementors of [`ExpandMsg`] for additional errors:
58- /// - [`ExpandMsgXmd`]
59- /// - [`ExpandMsgXof`]
6058 ///
61- /// `len_in_bytes = <Self::FieldElement as FromOkm>::Length`
59+ /// When the chosen [`ExpandMsg`] implementation returns an error. See [`ExpandMsgXmdError`]
60+ /// and [`ExpandMsgXofError`] for examples.
6261 ///
63- /// [`ExpandMsgXmd `]: crate::ExpandMsgXmd
64- /// [`ExpandMsgXof `]: crate::ExpandMsgXof
65- fn encode_from_bytes < X > ( msg : & [ & [ u8 ] ] , dst : & [ & [ u8 ] ] ) -> Result < ProjectivePoint < Self > >
62+ /// [`ExpandMsgXmdError `]: crate::ExpandMsgXmdError
63+ /// [`ExpandMsgXofError `]: crate::ExpandMsgXofError
64+ fn encode_from_bytes < X > ( msg : & [ & [ u8 ] ] , dst : & [ & [ u8 ] ] ) -> Result < ProjectivePoint < Self > , X :: Error >
6665 where
6766 X : ExpandMsg < Self :: K > ,
6867 {
@@ -74,18 +73,18 @@ pub trait GroupDigest: MapToCurve {
7473 /// Computes the hash to field routine according to
7574 /// <https://www.rfc-editor.org/rfc/rfc9380.html#section-5-4>
7675 /// and returns a scalar.
76+ ///
77+ /// For the `expand_message` call, `len_in_bytes = <Self::FieldElement as FromOkm>::Length`.
78+ /// This value must be less than `u16::MAX` or otherwise a compiler error will occur.
7779 ///
7880 /// # Errors
79- /// - `len_in_bytes > u16::MAX`
80- /// - See implementors of [`ExpandMsg`] for additional errors:
81- /// - [`ExpandMsgXmd`]
82- /// - [`ExpandMsgXof`]
8381 ///
84- /// `len_in_bytes = <Self::Scalar as FromOkm>::Length`
82+ /// When the chosen [`ExpandMsg`] implementation returns an error. See [`ExpandMsgXmdError`]
83+ /// and [`ExpandMsgXofError`] for examples.
8584 ///
86- /// [`ExpandMsgXmd `]: crate::ExpandMsgXmd
87- /// [`ExpandMsgXof `]: crate::ExpandMsgXof
88- fn hash_to_scalar < X > ( msg : & [ & [ u8 ] ] , dst : & [ & [ u8 ] ] ) -> Result < Self :: Scalar >
85+ /// [`ExpandMsgXmdError `]: crate::ExpandMsgXmdError
86+ /// [`ExpandMsgXofError `]: crate::ExpandMsgXofError
87+ fn hash_to_scalar < X > ( msg : & [ & [ u8 ] ] , dst : & [ & [ u8 ] ] ) -> Result < Self :: Scalar , X :: Error >
8988 where
9089 X : ExpandMsg < Self :: K > ,
9190 {
0 commit comments