Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: An implementation gotcha with "split" keys
by
garlonicon
on 02/07/2022, 15:52:03 UTC
⭐ Merited by PowerGlove (1)
Quote
I was adding a test-case to my code to check that the above relationship is always true and instead found that it was only true about 50% of the time. That is, if I generated pairs of private keys at random only about half of them would pass this test.
It is always true. Only half keys passed, because you probably skipped modulo "n". All operations are always modulo "n".
Code:
n=fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
d1=8b53639f152c8fc6ef30802fde462ba0be9cf085f7580dc69efd72e002abbb35
d2=e788103ee15318fcd2af9b73b4ebbb33a903b020de7b307d71f5fed0f433e548
Q1=02ECF185F85115C2BCD36D128B40B0576EF507890DA40D98C87FFD75EA9E4FF403
Q2=02A4D26294D355931C62B6144689FBF74E5FFCF5E3415821A89D4B71BFFAD043DC
Q1+Q2=0301FA88EADC1AC8D68A0C3141E48C6066F3BF26F28FBE1235F85BBD21742E0EE4
d1+d2=8b53639f152c8fc6ef30802fde462ba0be9cf085f7580dc69efd72e002abbb35+e788103ee15318fcd2af9b73b4ebbb33a903b020de7b307d71f5fed0f433e548
d1+d2=172db73ddf67fa8c3c1e01ba39331e6d467a0a0a6d5d33e4410f371b0f6dfa07d
d1+d2=72db73ddf67fa8c3c1e01ba39331e6d5acf1c3c0268a9e085121132426a95f3c