rbsecp256k1 icon indicating copy to clipboard operation
rbsecp256k1 copied to clipboard

sign_schnorr(): Remove 32 byte restriction on the message to be signed

Open rickhull opened this issue 8 months ago • 1 comments

https://bips.xyz/340#changelog

  • 2022-08: Fix function signature of lift_x in reference code
  • 2023-04: Allow messages of arbitrary size
  • 2024-05: Update "Applications" section with more recent references

Allow messages of arbitrary size

Test case:

require 'rbsecp256k1'

context = Secp256k1::Context.create
kp = context.generate_key_pair

baby_bear = 'baby bear'
mama_bear = 'mama bear'.ljust(32, ' ')
papa_bear = 'papa bear' * 99

p context.sign_schnorr(kp, mama_bear)
p context.sign_schnorr(kp, baby_bear)
p context.sign_schnorr(kp, papa_bear)

Result:

#<Secp256k1::SchnorrSignature:0x00007f5fd41abd38>
/home/rwh/.local/share/gem/ruby/3.3.0/gems/rbsecp256k1-6.0.0/lib/rbsecp256k1/context.rb:33:in `sign_schnorr_custom': schnorr signing message must be 32-bytes in length (Secp256k1::Error)
        from /home/rwh/.local/share/gem/ruby/3.3.0/gems/rbsecp256k1-6.0.0/lib/rbsecp256k1/context.rb:33:in `sign_schnorr'
        from test_case.rb:11:in `<main>'

rickhull avatar May 25 '24 19:05 rickhull