1
1
//! Traits for handling hash to curve.
2
2
3
3
use 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 } ;
6
5
7
6
/// Hash arbitrary byte sequences to a valid group element.
8
7
pub trait GroupDigest : MapToCurve {
@@ -22,17 +21,17 @@ pub trait GroupDigest: MapToCurve {
22
21
/// > oracle returning points in G assuming a cryptographically secure
23
22
/// > hash function is used.
24
23
///
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
+ ///
25
27
/// # Errors
26
- /// - `len_in_bytes > u16::MAX`
27
- /// - See implementors of [`ExpandMsg`] for additional errors:
28
- /// - [`ExpandMsgXmd`]
29
- /// - [`ExpandMsgXof`]
30
28
///
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.
32
31
///
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 >
36
35
where
37
36
X : ExpandMsg < Self :: K > ,
38
37
{
@@ -52,17 +51,17 @@ pub trait GroupDigest: MapToCurve {
52
51
/// > encode_to_curve is only a fraction of the points in G, and some
53
52
/// > points in this set are more likely to be output than others.
54
53
///
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
+ ///
55
57
/// # Errors
56
- /// - `len_in_bytes > u16::MAX`
57
- /// - See implementors of [`ExpandMsg`] for additional errors:
58
- /// - [`ExpandMsgXmd`]
59
- /// - [`ExpandMsgXof`]
60
58
///
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.
62
61
///
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 >
66
65
where
67
66
X : ExpandMsg < Self :: K > ,
68
67
{
@@ -74,18 +73,18 @@ pub trait GroupDigest: MapToCurve {
74
73
/// Computes the hash to field routine according to
75
74
/// <https://www.rfc-editor.org/rfc/rfc9380.html#section-5-4>
76
75
/// 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.
77
79
///
78
80
/// # Errors
79
- /// - `len_in_bytes > u16::MAX`
80
- /// - See implementors of [`ExpandMsg`] for additional errors:
81
- /// - [`ExpandMsgXmd`]
82
- /// - [`ExpandMsgXof`]
83
81
///
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.
85
84
///
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 >
89
88
where
90
89
X : ExpandMsg < Self :: K > ,
91
90
{
0 commit comments