truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

Exception raised in `ecdsa` gem, not on `jruby-head` nor `ruby-head`

Open rickhull opened this issue 1 year ago • 2 comments

I noticed a discrepancy in behavior between ruby-head and jruby-head on the one hand, and truffleruby-head on the other, via Github Actions.

Here is the GHA that fails only on truffleruby-head: https://github.com/rickhull/nostrb/actions/runs/10637157995/job/29490471421 The outermost test that fails is rake test, which succeeds entirely on ruby-head and jruby-head.

relevant stack trace:

 /home/runner/.rubies/truffleruby-head/lib/gems/gems/ecdsa-1.2.0/lib/ecdsa/prime_field.rb:62:in `inverse': Inversion bug: remainder is not 1. (RuntimeError)
	from /home/runner/.rubies/truffleruby-head/lib/gems/gems/ecdsa-1.2.0/lib/ecdsa/point.rb:74:in `add_to_point'
	from /home/runner/.rubies/truffleruby-head/lib/gems/gems/ecdsa-1.2.0/lib/ecdsa/point.rb:122:in `multiply_by_scalar'
	from /home/runner/.rubies/truffleruby-head/lib/gems/gems/schnorr_sig-0.2.1.1/lib/schnorr_sig/pure.rb:149:in `verify?'
	from /home/runner/.rubies/truffleruby-head/lib/gems/gems/schnorr_sig-0.2.1.1/lib/schnorr_sig/pure.rb:97:in `sign'
	from /home/runner/work/nostrb/nostrb/lib/nostrb/event.rb:155:in `sign'

The failure is in the ecdsa gem, here: https://github.com/DavidEGrayson/ruby_ecdsa/blob/master/lib/ecdsa/prime_field.rb#L62

rickhull avatar Aug 30 '24 22:08 rickhull

Here is a more specific failure, this time from schnorr_sig gem directly, rather than nostrb via transitive dependency: https://github.com/rickhull/schnorr_sig/actions/runs/10640243873/job/29499643425

/home/runner/.rubies/truffleruby-head/lib/gems/gems/ecdsa-1.2.0/lib/ecdsa/prime_field.rb:62:in `inverse': Inversion bug: remainder is not 1. (RuntimeError)
	from /home/runner/.rubies/truffleruby-head/lib/gems/gems/ecdsa-1.2.0/lib/ecdsa/point.rb:74:in `add_to_point'
	from /home/runner/.rubies/truffleruby-head/lib/gems/gems/ecdsa-1.2.0/lib/ecdsa/point.rb:122:in `multiply_by_scalar'
	from /home/runner/work/schnorr_sig/schnorr_sig/lib/schnorr_sig/pure.rb:147:in `verify?'
	from /home/runner/work/schnorr_sig/schnorr_sig/test/vectors.rb:17:in `block in <top (required)>'

rickhull avatar Aug 30 '24 22:08 rickhull

Thank you for the report, we'll look into it.

andrykonchin avatar Sep 09 '24 10:09 andrykonchin