Pedersen

Struct Pedersen 

Source
pub struct Pedersen<F: PedersenParams<P>, P: CurveConfig>
where <P as CurveConfig>::BaseField: PrimeField, F::AffineRepr: AffineRepr<Config = P, BaseField = P::BaseField, ScalarField = P::ScalarField>,
{ /* private fields */ }
Expand description

Pedersen hash.

Implementations§

Source§

impl<F: PedersenParams<P>, P: CurveConfig> Pedersen<F, P>
where <P as CurveConfig>::BaseField: PrimeField, F::AffineRepr: AffineRepr<Config = P, BaseField = P::BaseField, ScalarField = P::ScalarField>,

Source

pub fn new() -> Self

Creates a new Pedersen hash instance.

Source

pub fn hash<T>(&self, x: T, y: T) -> Option<P::BaseField>
where T: Into<P::BaseField>,

Computes the Starkware version of the Pedersen hash of x and y.

The hash is defined by: PedersenParams::P_0 + x_low * PedersenParams::P_1 + x_high * PedersenParams::P_2 + y_low * PedersenParams::P_3 + y_high * PedersenParams::P_4

where x_low is the 248 low bits of x, x_high is the 4 high bits of x and similarly for y. PedersenParams::P_0, PedersenParams::P_1, PedersenParams::P_2, PedersenParams::P_3, PedersenParams::P_4 are constant points generated from the digits of pi.

§Arguments
  • &self - Pedersen hasher instance.
  • x - The x coordinate of the point to hash.
  • y - The y coordinate of the point to hash.

Trait Implementations§

Source§

impl<F: Clone + PedersenParams<P>, P: Clone + CurveConfig> Clone for Pedersen<F, P>
where <P as CurveConfig>::BaseField: PrimeField, F::AffineRepr: AffineRepr<Config = P, BaseField = P::BaseField, ScalarField = P::ScalarField>,

Source§

fn clone(&self) -> Pedersen<F, P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + PedersenParams<P>, P: Debug + CurveConfig> Debug for Pedersen<F, P>
where <P as CurveConfig>::BaseField: PrimeField, F::AffineRepr: AffineRepr<Config = P, BaseField = P::BaseField, ScalarField = P::ScalarField>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: PedersenParams<P>, P: CurveConfig> Default for Pedersen<F, P>
where <P as CurveConfig>::BaseField: PrimeField, F::AffineRepr: AffineRepr<Config = P, BaseField = P::BaseField, ScalarField = P::ScalarField>,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<F, P> Freeze for Pedersen<F, P>

§

impl<F, P> RefUnwindSafe for Pedersen<F, P>

§

impl<F, P> Send for Pedersen<F, P>
where <F as PedersenParams<P>>::AffineRepr: Sized, <P as CurveConfig>::BaseField: Sized, F: Send,

§

impl<F, P> Sync for Pedersen<F, P>
where <F as PedersenParams<P>>::AffineRepr: Sized, <P as CurveConfig>::BaseField: Sized, F: Sync,

§

impl<F, P> Unpin for Pedersen<F, P>
where <F as PedersenParams<P>>::AffineRepr: Sized, <P as CurveConfig>::BaseField: Sized, F: Unpin, P: Unpin,

§

impl<F, P> UnwindSafe for Pedersen<F, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.