pub struct ZkLoginPublicIdentifier { /* private fields */ }Expand description
Public Key equivalent for Zklogin authenticators
A ZkLoginPublicIdentifier is the equivalent of a public key for other account authenticators,
and contains the information required to derive the onchain account Address for a Zklogin
authenticator.
§Note
Due to a historical bug that was introduced in the Sui Typescript SDK when the zklogin
authenticator was first introduced, there are now possibly two “valid” addresses for each
zklogin authenticator depending on the bit-pattern of the address_seed value.
The original bug incorrectly derived a zklogin’s address by stripping any leading
zero-bytes that could have been present in the 32-byte length address_seed value prior to
hashing, leading to a different derived address. This incorrectly derived address was
presented to users of various wallets, leading them to sending funds to these addresses
that they couldn’t access. Instead of letting these users lose any assets that were sent to
these addresses, the Sui network decided to change the protocol to allow for a zklogin
authenticator who’s address_seed value had leading zero-bytes be authorized to sign for
both the addresses derived from both the unpadded and padded address_seed value.
§BCS
The BCS serialized form for this type is defined by the following ABNF:
zklogin-public-identifier-bcs = bytes ; where the contents are defined by
; <zklogin-public-identifier>
zklogin-public-identifier = zklogin-public-identifier-iss
address-seed
zklogin-public-identifier-unpadded = zklogin-public-identifier-iss
address-seed-unpadded
; The iss, or issuer, is a utf8 string that is less than 255 bytes long
; and is serialized with the iss's length in bytes as a u8 followed by
; the bytes of the iss
zklogin-public-identifier-iss = u8 *255(OCTET)
; A Bn254FieldElement serialized as a 32-byte big-endian value
address-seed = 32(OCTET)
; A Bn254FieldElement serialized as a 32-byte big-endian value
; with any leading zero bytes stripped
address-seed-unpadded = %x00 / %x01-ff *31(OCTET)Implementations§
Source§impl ZkLoginPublicIdentifier
impl ZkLoginPublicIdentifier
Sourcepub fn scheme(&self) -> SignatureScheme
pub fn scheme(&self) -> SignatureScheme
Return the flag for this signature scheme
Source§impl ZkLoginPublicIdentifier
impl ZkLoginPublicIdentifier
pub fn new(iss: String, address_seed: Bn254FieldElement) -> Option<Self>
pub fn iss(&self) -> &str
pub fn address_seed(&self) -> &Bn254FieldElement
Source§impl ZkLoginPublicIdentifier
impl ZkLoginPublicIdentifier
Sourcepub fn derive_address_padded(&self) -> Address
Available on crate feature hash only.
pub fn derive_address_padded(&self) -> Address
hash only.Derive an Address from this ZkLoginPublicIdentifier by hashing the byte length of the
iss followed by the iss bytes themselves and the full 32 byte address_seed value, all
prefixed with the zklogin SignatureScheme flag (0x05).
hash( 0x05 || iss_bytes_len || iss_bytes || 32_byte_address_seed )
Sourcepub fn derive_address_unpadded(&self) -> Address
Available on crate feature hash only.
pub fn derive_address_unpadded(&self) -> Address
hash only.Derive an Address from this ZkLoginPublicIdentifier by hashing the byte length of the
iss followed by the iss bytes themselves and the address_seed bytes with any leading
zero-bytes stripped, all prefixed with the zklogin SignatureScheme flag (0x05).
hash( 0x05 || iss_bytes_len || iss_bytes || unpadded_32_byte_address_seed )
Sourcepub fn derive_address(&self) -> impl ExactSizeIterator<Item = Address>
Available on crate feature hash only.
pub fn derive_address(&self) -> impl ExactSizeIterator<Item = Address>
hash only.Provides an iterator over the addresses that correspond to this zklogin authenticator.
In the majority of instances this will only yield a single address, except for the
instances where the address_seed value has a leading zero-byte, in such cases the
returned iterator will yield two addresses.
Trait Implementations§
Source§impl Arbitrary for ZkLoginPublicIdentifier
impl Arbitrary for ZkLoginPublicIdentifier
Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<ZkLoginPublicIdentifier>
type Strategy = BoxedStrategy<ZkLoginPublicIdentifier>
Strategy used to generate values of type Self.Source§fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
Source§impl Clone for ZkLoginPublicIdentifier
impl Clone for ZkLoginPublicIdentifier
Source§fn clone(&self) -> ZkLoginPublicIdentifier
fn clone(&self) -> ZkLoginPublicIdentifier
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ZkLoginPublicIdentifier
impl Debug for ZkLoginPublicIdentifier
Source§impl<'de> Deserialize<'de> for ZkLoginPublicIdentifier
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ZkLoginPublicIdentifier
serde only.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 PartialEq for ZkLoginPublicIdentifier
impl PartialEq for ZkLoginPublicIdentifier
Source§impl Serialize for ZkLoginPublicIdentifier
Available on crate feature serde only.
impl Serialize for ZkLoginPublicIdentifier
serde only.impl Eq for ZkLoginPublicIdentifier
impl StructuralPartialEq for ZkLoginPublicIdentifier
Auto Trait Implementations§
impl Freeze for ZkLoginPublicIdentifier
impl RefUnwindSafe for ZkLoginPublicIdentifier
impl Send for ZkLoginPublicIdentifier
impl Sync for ZkLoginPublicIdentifier
impl Unpin for ZkLoginPublicIdentifier
impl UnwindSafe for ZkLoginPublicIdentifier
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
Source§fn from_bcs<'de>(bytes: &'de [u8]) -> Result<Self, Error>where
Self: Deserialize<'de>,
fn from_bcs<'de>(bytes: &'de [u8]) -> Result<Self, Error>where
Self: Deserialize<'de>,
serde only.Source§fn from_bcs_base64(base64: &str) -> Result<Self, Error>where
Self: DeserializeOwned,
fn from_bcs_base64(base64: &str) -> Result<Self, Error>where
Self: DeserializeOwned,
serde only.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