Class: Solana::Ruby::Kit::Signers::KeyPairSigner
- Inherits:
-
Object
- Object
- Solana::Ruby::Kit::Signers::KeyPairSigner
- Extended by:
- T::Sig
- Defined in:
- lib/solana/ruby/kit/signers/keypair_signer.rb
Overview
A signer backed by an Ed25519 key pair, capable of signing both transaction messages and off-chain messages.
Mirrors TypeScript’s ‘KeyPairSigner<TAddress>`, which combines MessagePartialSigner and TransactionPartialSigner with a CryptoKeyPair reference.
In Ruby we keep it simple: the signer holds an RbNaCl::SigningKey (which contains the private key seed and can derive the public key) and exposes the signer’s address.
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#key_pair ⇒ Object
readonly
Returns the value of attribute key_pair.
Instance Method Summary collapse
-
#initialize(key_pair) ⇒ KeyPairSigner
constructor
A new instance of KeyPairSigner.
- #inspect ⇒ Object
- #sign(data) ⇒ Object
- #to_s ⇒ Object
- #verify(sig_bytes, data) ⇒ Object
Constructor Details
#initialize(key_pair) ⇒ KeyPairSigner
Returns a new instance of KeyPairSigner.
34 35 36 37 38 39 40 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 34 def initialize(key_pair) @key_pair = T.let(key_pair, Keys::KeyPair) @address = T.let( Addresses::Address.new(Addresses.encode_address(key_pair.verify_key.to_bytes)), Addresses::Address ) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
28 29 30 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 28 def address @address end |
#key_pair ⇒ Object (readonly)
Returns the value of attribute key_pair.
31 32 33 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 31 def key_pair @key_pair end |
Instance Method Details
#inspect ⇒ Object
46 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 46 def inspect = "#<KeyPairSigner address=#{@address}>" |
#sign(data) ⇒ Object
51 52 53 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 51 def sign(data) Keys.sign_bytes(@key_pair.signing_key, data) end |
#to_s ⇒ Object
43 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 43 def to_s = @address.to_s |
#verify(sig_bytes, data) ⇒ Object
57 58 59 |
# File 'lib/solana/ruby/kit/signers/keypair_signer.rb', line 57 def verify(sig_bytes, data) Keys.verify_signature(@key_pair.verify_key, sig_bytes, data) end |