Class: Solace::PublicKey
- Inherits:
-
Object
- Object
- Solace::PublicKey
- Includes:
- Utils::PDA
- Defined in:
- lib/solace/public_key.rb
Overview
Class representing a Solana Ed25519 Public Key
This class provides utility methods for encoding, decoding, and validating public keys.
Constant Summary collapse
- LENGTH =
The length of a Solana public key in bytes
32- MAX_BUMP_SEED =
The maximum seed value for a Program Derived Address
255- PDA_MARKER =
The marker for a Program Derived Address
'ProgramDerivedAddress'
Instance Attribute Summary collapse
-
#bytes ⇒ Array<u8>
readonly
The bytes of the public key.
Class Method Summary collapse
-
.from_address(address) ⇒ PublicKey
Create a public key instance from a base58 address.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare two public keys for equality.
-
#initialize(bytes) ⇒ PublicKey
constructor
Initialize with a 32-byte array or string.
-
#to_base58 ⇒ String
(also: #to_s, #address)
Return the base58 representation of the public key.
-
#to_bytes ⇒ Array<Integer>
Return the public key as a byte array.
Methods included from Utils::PDA
create_program_address, find_program_address, looks_like_base58_address?, seed_to_bytes
Constructor Details
Instance Attribute Details
#bytes ⇒ Array<u8> (readonly)
The bytes of the public key
32 33 34 |
# File 'lib/solace/public_key.rb', line 32 def bytes @bytes end |
Class Method Details
.from_address(address) ⇒ PublicKey
Create a public key instance from a base58 address
111 112 113 |
# File 'lib/solace/public_key.rb', line 111 def from_address(address) new(Solace::Utils::Codecs.base58_to_bytes(address)) end |
Instance Method Details
#==(other) ⇒ Boolean
Compare two public keys for equality
85 86 87 |
# File 'lib/solace/public_key.rb', line 85 def ==(other) other.is_a?(Solace::PublicKey) && other.bytes == bytes end |
#to_base58 ⇒ String Also known as: to_s, address
Return the base58 representation of the public key
55 56 57 |
# File 'lib/solace/public_key.rb', line 55 def to_base58 Solace::Utils::Codecs.bytes_to_base58(@bytes) end |
#to_bytes ⇒ Array<Integer>
Return the public key as a byte array
96 97 98 |
# File 'lib/solace/public_key.rb', line 96 def to_bytes @bytes.dup end |