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.
-
#address ⇒ String
Return the address of the public key.
-
#initialize(bytes) ⇒ PublicKey
constructor
Initialize with a 32-byte array or string.
-
#to_base58 ⇒ String
Return the base58 representation of the public key.
-
#to_bytes ⇒ Array<Integer>
Return the public key as a byte array.
-
#to_s ⇒ String
String representation (base58).
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
110 111 112 |
# File 'lib/solace/public_key.rb', line 110 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 |
#address ⇒ String
Return the address of the public key
74 75 76 |
# File 'lib/solace/public_key.rb', line 74 def address to_base58 end |
#to_base58 ⇒ String
Return the base58 representation of the public key
54 55 56 |
# File 'lib/solace/public_key.rb', line 54 def to_base58 Solace::Utils::Codecs.bytes_to_base58(@bytes) end |
#to_bytes ⇒ Array<Integer>
Return the public key as a byte array
95 96 97 |
# File 'lib/solace/public_key.rb', line 95 def to_bytes @bytes.dup end |
#to_s ⇒ String
String representation (base58)
64 65 66 |
# File 'lib/solace/public_key.rb', line 64 def to_s to_base58 end |