Skip to content

Instantly share code, notes, and snippets.

@NicolasDorier
Created June 28, 2014 17:52
Show Gist options
  • Save NicolasDorier/91fe666992d61015831f to your computer and use it in GitHub Desktop.
Save NicolasDorier/91fe666992d61015831f to your computer and use it in GitHub Desktop.
Repro
[Fact]
public void SumOfMultipliesBug()
{
var curve = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp256k1");
var a = new Org.BouncyCastle.Math.BigInteger("69382933896972716708744287348684382108685473997297686356748931369614199359285");
var o = X9IntegerConverter.IntegerToBytes
(new Org.BouncyCastle.Math.BigInteger("27188564572527577826207139682381325092978633561404879297236674360940833429317"),
0x21);
o[0] = (byte)0x02;
var q = curve.Curve.DecodePoint(o);
var b = new Org.BouncyCastle.Math.BigInteger("100771008261047044268288327751827424543746424910943046077177469841741341064373");
var r1 = ECAlgorithms.SumOfTwoMultiplies(curve.G, a, q, b);
var r2 = ECAlgorithms.SumOfTwoMultiplies2(curve.G, a, q, b);
Assert.Equal(r1.X, r2.X);
Assert.Equal(r1.Y, r2.Y); //Crash here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment