Closed schmijos closed 4 months ago
@schmijos Thanks for the suggestion. That is the next item in the roadmap. I want to use objects instead of strings for ids and signatures.
Regarding those methods, what should they take as arguments?
Naively I thought about something like this:
module Nostr
class Event
def valid_signature?
crypto = Crypto.new
crypto.valid_signature?(self)
end
end
end
A more powerful approach might be something like this:
event.valid?
=> false
event.errors
=> ["signature empty"]
@schmijos
Added in 0.6.0
:
crypto.valid_sig?(message, public_key, signature) # true or false
crypto.check_sig!(message, public_key, signature) # true or raise an exception
https://www.nostr-ruby.com/common-use-cases/signing-and-verifying-messages.html
event.verify_signature # => true or false
https://www.nostr-ruby.com/common-use-cases/signing-and-verifying-events.html
The
bip-schnorr
library you use to sign events can also be used to check signatures:valid_sig?
andcheck_sig!
I'd suggest you provide a facade inNostr::Crypto
and encourage library users to check for valid signatures in the docs.