Class: Nostr::KeyPair

Inherits:
Object
  • Object
show all
Defined in:
lib/nostr/key_pair.rb

Overview

A pair of public and private keys

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(private_key:, public_key:) ⇒ KeyPair

Instantiates a key pair

Examples:

keypair = Nostr::KeyPair.new(
  private_key: '893c4cc8088924796b41dc788f7e2f746734497010b1a9f005c1faad7074b900',
  public_key: '2d7661527d573cc8e84f665fa971dd969ba51e2526df00c149ff8e40a58f9558',
)

Parameters:

  • private_key (String)

    32-bytes hex-encoded private key.

  • public_key (String)

    32-bytes hex-encoded public key.



41
42
43
44
# File 'lib/nostr/key_pair.rb', line 41

def initialize(private_key:, public_key:)
  @private_key = private_key
  @public_key = public_key
end

Instance Attribute Details

#private_keyString (readonly)

32-bytes hex-encoded private key

Examples:

keypair.private_key # => '893c4cc8088924796b41dc788f7e2f746734497010b1a9f005c1faad7074b900'

Returns:

  • (String)


15
16
17
# File 'lib/nostr/key_pair.rb', line 15

def private_key
  @private_key
end

#public_keyString (readonly)

32-bytes hex-encoded public key

Examples:

keypair.public_key # => '2d7661527d573cc8e84f665fa971dd969ba51e2526df00c149ff8e40a58f9558'

Returns:

  • (String)


26
27
28
# File 'lib/nostr/key_pair.rb', line 26

def public_key
  @public_key
end