Implement NIP-19 bech32-encoded private and public keys

https://github.com/nostr-protocol/nips/blob/master/19.md
This commit is contained in:
Wilson Silva
2023-11-20 09:59:27 +07:00
parent 3fffcd1a4e
commit 3520cf8219
58 changed files with 1189 additions and 104 deletions

41
sig/vendor/bech32/nostr/entity.rbs vendored Normal file
View File

@@ -0,0 +1,41 @@
# Added only to satisfy the Steep requirements. Not 100% reliable.
module Bech32
module Nostr
class BareEntity
attr_reader hrp: untyped
attr_reader data: untyped
def initialize: (untyped hrp, untyped data) -> void
def encode: -> untyped
end
class TLVEntry
attr_reader type: (Float | Integer | String)?
attr_reader label: String?
attr_reader value: (Float | Integer | String)?
def initialize: ((Float | Integer | String)? `type`, (Float | Integer | String)? value, ?String? label) -> void
def to_payload: -> String
def to_s: -> String
private
def hex_string?: ((Float | Integer | String)? str) -> bool
end
class TLVEntity
TYPE_SPECIAL: Integer
TYPE_RELAY: Integer
TYPE_AUTHOR: Integer
TYPE_KIND: Integer
TYPES: [Integer, Integer, Integer, Integer]
attr_reader hrp: untyped
attr_reader entries: Array[TLVEntry]
def initialize: (untyped hrp, Array[TLVEntry] entries) -> void
def self.parse: (untyped hrp, untyped data) -> TLVEntity
def encode: -> untyped
end
end
end

20
sig/vendor/bech32/nostr/nip19.rbs vendored Normal file
View File

@@ -0,0 +1,20 @@
# Added only to satisfy the Steep requirements. Not 100% reliable.
module Bech32
module Nostr
module NIP19
HRP_PUBKEY: String
HRP_PRIVATE_KEY: String
HRP_NOTE_ID: String
HRP_PROFILE: String
HRP_EVENT: String
HRP_RELAY: String
HRP_EVENT_COORDINATE: String
BARE_PREFIXES: [String, String, String]
TLV_PREFIXES: [String, String, String, String]
ALL_PREFIXES: Array[String]
def decode: (untyped string) -> untyped
def self.decode: (untyped string) -> untyped
end
end
end

21
sig/vendor/bech32/segwit_addr.rbs vendored Normal file
View File

@@ -0,0 +1,21 @@
# Added only to satisfy the Steep requirements. Not 100% reliable.
module Bech32
class SegwitAddr
HRP_MAINNET: String
HRP_TESTNET: String
HRP_REGTEST: String
attr_accessor hrp: String
attr_accessor ver: (Float | Integer | String)?
attr_accessor prog: Array[(Float | Integer | String)?]
def initialize: (?nil addr) -> void
def to_script_pubkey: -> ((Float | Integer | String)?)
def script_pubkey=: (untyped script_pubkey) -> (Array[(Float | Integer | String)?])
def addr: -> untyped
private
def parse_addr: (untyped addr) -> nil
end
end