arcium-primitives 0.4.2

Arcium primitives
Documentation
use crate::{
    algebra::elliptic_curve::{Curve, Point},
    hashing::hashing_utils,
};

pub struct TaggedRandomOracle<'ro> {
    tag: &'ro [u8],
}

impl<'ro> TaggedRandomOracle<'ro> {
    pub fn new(tag: &'ro [u8]) -> Self {
        Self { tag }
    }

    pub fn hash_x<C: Curve>(&self, input: &Point<C>, x: u8) -> Point<C> {
        let bytes = hashing_utils::flatten_slices(&[self.tag, &[x], input.to_bytes().as_ref()]);
        Point::new(C::hash_to_curve(&bytes))
    }
}