primitives/hashing/
random_oracle.rs

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