primitives/hashing/
random_oracle.rs1use crate::{
2 algebra::elliptic_curve::{Curve, Point},
3 hashing::hashing_utils,
4 utils::InPlaceCodec,
5};
6
7pub struct TaggedRandomOracle<'ro> {
8 tag: &'ro [u8],
9}
10
11impl<'ro> TaggedRandomOracle<'ro> {
12 pub fn new(tag: &'ro [u8]) -> Self {
13 Self { tag }
14 }
15
16 pub fn hash_x<C: Curve>(&self, input: &Point<C>, x: u8) -> Point<C> {
17 let bytes =
18 hashing_utils::flatten_slices(&[self.tag, &[x], input.to_inplace_bytes().as_ref()]);
19 Point::new(C::hash_to_curve(&bytes))
20 }
21}