Skip to main content

Class PublicKey

About 1 min

Class PublicKey

Declared in packages/common/keys/dist/types/src/public-key.d.ts:16

The purpose of this class is to assure consistent use of keys throughout the project. Keys should be maintained as buffers in objects and proto definitions, and converted to hex strings as late as possible (eg, to log/display).

Constructors

constructor(_value)

Returns: PublicKey

Arguments:

_value: Uint8Array

Properties

[devtoolsFormatter]

Type: DevtoolsFormatter

length

Type: number

Methods

[custom](depth, options)

Used by Node.js to get textual representation of this object when it's printed with a console.log statement.

Returns: string

Arguments:

depth: number

options: InspectOptionsStylized

[equalsSymbol](other)

Returns: boolean

Arguments:

other: any

asBuffer()

Returns: Buffer

Arguments: none

asUint8Array()

Returns: Uint8Array

Arguments: none

equals(other)

Test this key for equality with some other key.

Returns: boolean

Arguments:

other: PublicKeyLike

getInsecureHash(modulo)

Returns: number

Arguments:

modulo: number

toHex()

Returns: string

Arguments: none

toJSON()

Returns: string

Arguments: none

toString()

Returns: string

Arguments: none

truncate([length])

Returns: string

Arguments:

length: undefined

assertValidPublicKey(value)

Asserts that provided values is an instance of PublicKey.

Returns: asserts value is PublicKey

Arguments:

value: any

bufferize(str)

Returns: Buffer

Arguments:

str: string

equals(left, right)

Tests two keys for equality.

Returns: boolean

Arguments:

left: PublicKeyLike

right: PublicKeyLike

from(source)

Creates new instance of PublicKey automatically determining the input format.

Returns: PublicKey

Arguments:

source: PublicKeyLike

fromHex(hex)

Creates new instance of PublicKey from hex string.

Returns: PublicKey

Arguments:

hex: string

hash(key)

To be used with ComplexMap and ComplexSet. Returns a scalar representation for this key.

Returns: string

Arguments:

key: PublicKey

isPublicKey(value)

Tests if provided values is an instance of PublicKey.

Returns: value is PublicKey

Arguments:

value: any

random()

Creates a new key.

Returns: PublicKey

Arguments: none

randomSequence()

Returns: Generator<PublicKey, any, unknown>

Arguments: none

safeFrom([source])

Same as PublicKey.from but does not throw and instead returns a { key: PublicKey } or { error: Error }

Returns: undefined | PublicKey

Arguments:

source: PublicKeyLike

stringify(key)

Returns: string

Arguments:

key: Uint8Array | ArrayBuffer | Buffer