Struct std::crypto::public_key::PublicKey
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
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
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
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, otherwisefalse
.
Examples
use std::crypto::PublicKey;
fn foo() -> {
let new_key = PublicKey::new();
assert(new_key.is_zero() == true);
}
Trait Implementations
impl AbiEncode for PublicKey
impl AbiEncode for PublicKey
pub fn abi_encode(self, buffer: Buffer) -> Buffer
impl AbiDecode for PublicKey
impl AbiDecode for PublicKey
pub fn abi_decode(refmut buffer: BufferReader) -> Self
impl Eq for PublicKey
impl Eq for PublicKey
pub fn eq(self, other: Self) -> bool
pub fn neq(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, otherwisefalse
.
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);
}