rbsecp256k1
rbsecp256k1 copied to clipboard
sign_schnorr(): Remove 32 byte restriction on the message to be signed
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>'