pub struct PublicKey {
    /// The underlying raw data of the public key.
    bytes: Bytes,
}
Expand description

Asymmetric public key, i.e. verifying key, in uncompressed form.

Additional Information

It should be noted that while Secp256k1 and Secp256r1 uses 64 byte public keys, Ed25519 uses 32 byte public keys.

Fields

bytes: Bytes

The underlying raw data of the public key.

Implementations

pub fn new() -> Self

Creates a new instance of a PublicKey signature.

Returns

[PublicKey] - A public key.

Examples

use std::crypto::PublicKey;

fn foo() {
    let new_key = PublicKey::new();
    assert(new_key.bytes().len() == 0);
}

pub fn bytes(self) -> Bytes

Returns the underlying raw Bytes data of the public key.

Returns

  • [Bytes] - The raw data of the public key.

Examples

use std::crypto::PublicKey;

fn foo() -> {
    let new_key = PublicKey::new();
    assert(new_key.bytes().len() == 64);
}

pub fn is_zero(self) -> bool

Returns whether the public key is the zero public key.

Returns

  • [bool] - true if the public key is zero, otherwise false.

Examples

use std::crypto::PublicKey;

fn foo() -> {
    let new_key = PublicKey::new();
    assert(new_key.is_zero() == true);
}

Trait Implementations

pub fn abi_encode(self, buffer: Buffer) -> Buffer

pub fn abi_decode(refmut buffer: BufferReader) -> Self

pub fn from(bits: B512) -> Self

pub fn from(components: (b256, b256)) -> Self

pub fn from(bits: b256) -> Self

pub fn try_from(bytes: Bytes) -> Option<Self>

pub fn try_into(self) -> Option<(b256, b256)>

pub fn try_into(self) -> Option<B512>

pub fn try_into(self) -> Option<b256>

pub fn eq(self, other: Self) -> bool

pub fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

Additional Information

This function is inherited when eq() is implemented.

Arguments

  • other: [Self] - The value of the same type.

Returns

  • [bool] - true if the two values are not equal, otherwise false.

Examples

struct MyStruct {
    val: u64,
}

impl Eq for MyStruct {
    fn eq(self, other: Self) -> bool {
         self.val == other.val
    }
}

fn foo() {
    let struct1 = MyStruct { val: 10 };
    let struct2 = MyStruct { val: 2 };
    let result = struct1 != struct2;
    assert(result);
}

pub fn hash(
self,
refmut state: Hasher,
)