Class: Nostr::Signature

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

Overview

64-bytes lowercase hex of the signature of the sha256 hash of the serialized event data, which is the same as the “id” field

Constant Summary collapse

FORMAT =

The regular expression for hexadecimal lowercase characters

Returns:

  • (Regexp)

    The regular expression for hexadecimal lowercase characters

/^[a-f0-9]+$/
LENGTH =

The length of the signature in hex format

Returns:

  • (Integer)

    The length of the signature in hex format

128

Instance Method Summary collapse

Constructor Details

#initialize(hex_value) ⇒ Signature

Instantiates a new Signature

Examples:

Instantiating a new signature

Nostr::Signature.new(
  'f418c97b50cc68227e82f4f3a79d79eb2b7a0fa517859c86e1a8fa91e3741b7f' \
  '06e070c44129227b83fcbe93cecb02a346804a4080ce47685ecad60ab4f5f128'
)

Parameters:

  • hex_value (String)

    Hex-encoded value of the signature

Raises:



33
34
35
36
37
# File 'lib/nostr/signature.rb', line 33

def initialize(hex_value)
  validate(hex_value)

  super(hex_value)
end