pub struct SessionNullifier { /* private fields */ }Expand description
A session nullifier for World ID Session proofs. It is analogous to a request nonce,
it does NOT guarantee uniqueness of a World ID as a Nullifier does.
This type is intended to be opaque for RPs. For an RP context, they should only
be concerned of this needing to be passthrough to the verifySession() contract function.
This type exists as an adaptation to be able to use the same ZK-circuit for both Uniqueness Proofs and Session Proofs, and it encompasses:
- the nullifier used as the proof output.
- a random action bound to the same proof.
The WorldIDVerifier.sol contract expects this as a uint256[2] array
use as_ethereum_representation() for conversion.
§Future
Note the session nullifier exists only to support the same ZK-circuit than for Uniqueness Proofs; as World ID evolves to a different proving system which won’t require circuit precompiles, a new circuit MUST be created which does not generate a nullifier at all, and the input randomized action will not be required either.
Implementations§
Source§impl SessionNullifier
impl SessionNullifier
Sourcepub const fn new(nullifier: FieldElement, action: FieldElement) -> Self
pub const fn new(nullifier: FieldElement, action: FieldElement) -> Self
Creates a new session nullifier.
Sourcepub const fn nullifier(&self) -> FieldElement
pub const fn nullifier(&self) -> FieldElement
Returns the nullifier value.
Sourcepub const fn action(&self) -> FieldElement
pub const fn action(&self) -> FieldElement
Returns the action value.
Sourcepub fn as_ethereum_representation(&self) -> [U256; 2]
pub fn as_ethereum_representation(&self) -> [U256; 2]
Returns the session nullifier as an Ethereum-compatible array for verifySession().
Format: [nullifier, action] matching the contract’s uint256[2] sessionNullifier.
Sourcepub fn from_ethereum_representation(value: [U256; 2]) -> Result<Self, String>
pub fn from_ethereum_representation(value: [U256; 2]) -> Result<Self, String>
Creates a session nullifier from an Ethereum representation.
§Errors
Returns an error if the U256 values are not valid field elements.
Sourcepub fn to_compressed_bytes(&self) -> [u8; 64]
pub fn to_compressed_bytes(&self) -> [u8; 64]
Returns the 64-byte big-endian representation (2 x 32-byte field elements).
Trait Implementations§
Source§impl Clone for SessionNullifier
impl Clone for SessionNullifier
Source§fn clone(&self) -> SessionNullifier
fn clone(&self) -> SessionNullifier
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionNullifier
impl Debug for SessionNullifier
Source§impl Default for SessionNullifier
impl Default for SessionNullifier
Source§impl<'de> Deserialize<'de> for SessionNullifier
impl<'de> Deserialize<'de> for SessionNullifier
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<(FieldElement, FieldElement)> for SessionNullifier
impl From<(FieldElement, FieldElement)> for SessionNullifier
Source§fn from((nullifier, action): (FieldElement, FieldElement)) -> Self
fn from((nullifier, action): (FieldElement, FieldElement)) -> Self
Source§impl From<SessionNullifier> for [U256; 2]
impl From<SessionNullifier> for [U256; 2]
Source§fn from(value: SessionNullifier) -> Self
fn from(value: SessionNullifier) -> Self
Source§impl Hash for SessionNullifier
impl Hash for SessionNullifier
Source§impl PartialEq for SessionNullifier
impl PartialEq for SessionNullifier
Source§impl Serialize for SessionNullifier
impl Serialize for SessionNullifier
impl Copy for SessionNullifier
impl Eq for SessionNullifier
impl StructuralPartialEq for SessionNullifier
Auto Trait Implementations§
impl Freeze for SessionNullifier
impl RefUnwindSafe for SessionNullifier
impl Send for SessionNullifier
impl Sync for SessionNullifier
impl Unpin for SessionNullifier
impl UnsafeUnpin for SessionNullifier
impl UnwindSafe for SessionNullifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more