Bitcoin Forum
December 13, 2024, 01:02:30 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: OpenSSL.Net Help  (Read 1357 times)
pmlyon (OP)
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile
July 03, 2013, 12:10:06 PM
 #1

Hi, does anyone here have any experience using OpenSSL.Net? I'm having a hard time figure out how to feed the information I have into its API in order to verify a transaction signature. At the moment I'm stuck on the error "error:100A706A:elliptic curve routines:ec_GFp_simple_point_get_affine_coordinates:point at infinity" where I'm trying to use my x & y to get the public key.

Here's a snippet of code showing where I'm stuck, thanks for any help!

Code:
using OpenSSL.Core;
using OpenSSL.Crypto.EC;
using System.Linq;

namespace OpenSSL
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // curve: secp256k1
            var secp256k1 = BuiltinCurve.Get().Single(q => q.Object.ShortName == "secp256k1").Object;

            // public key: x & y
            var pubKey = new byte[] { 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, 0x2e, 0x97, 0xb1, 0x48, 0x2e, 0xca, 0xd7, 0xb1, 0x48, 0xa6, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3 };
            var x = BigNumber.FromDecimalString("08077278579061990400249759952135267692351268034085864289451880299432711854684");
            var y = BigNumber.FromDecimalString("80909081783613153892905690721223288132374970267791400411164949654933991592611");

            // signature: digest, r & s
            var sig = new byte[] { 0x30, 0x44, 0x02, 0x20, 0x4e, 0x45, 0xe1, 0x69, 0x32, 0xb8, 0xaf, 0x51, 0x49, 0x61, 0xa1, 0xd3, 0xa1, 0xa2, 0x5f, 0xdf, 0x3f, 0x4f, 0x77, 0x32, 0xe9, 0xd6, 0x24, 0xc6, 0xc6, 0x15, 0x48, 0xab, 0x5f, 0xb8, 0xcd, 0x41, 0x02, 0x20, 0x18, 0x15, 0x22, 0xec, 0x8e, 0xca, 0x07, 0xde, 0x48, 0x60, 0xa4, 0xac, 0xdd, 0x12, 0x90, 0x9d, 0x83, 0x1c, 0xc5, 0x6c, 0xbb, 0xac, 0x46, 0x22, 0x08, 0x22, 0x21, 0xa8, 0x76, 0x8d, 0x1d, 0x09 };
            var r = BigNumber.FromDecimalString("35403870366028504256996810077444802381610204463951253825639898172590680231233");
            var s = BigNumber.FromDecimalString("10892853191319399759538221348851038436710718244456294856259711618427711724809");
            var digest = new byte[] { 0x7a, 0x05, 0xc6, 0x14, 0x5f, 0x10, 0x10, 0x1e, 0x9d, 0x63, 0x25, 0x49, 0x42, 0x45, 0xad, 0xf1, 0x29, 0x7d, 0x80, 0xf8, 0xf3, 0x8d, 0x4d, 0x57, 0x6d, 0x57, 0xcd, 0xba, 0x22, 0x0b, 0xcb, 0x19 };

            var group = Group.FromCurveName(secp256k1);
            var point = new Point(group);
            var key = Key.FromCurveName(secp256k1);
            key.Group = group;

            var ctx = new BigNumber.Context();
            // error:100A706A:elliptic curve routines:ec_GFp_simple_point_get_affine_coordinates:point at infinity
            point.GetAffineCoordinatesGF2m(x, y, ctx);
        }
    }
}

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
pmlyon (OP)
Member
**
Offline Offline

Activity: 72
Merit: 10


View Profile
July 03, 2013, 12:11:52 PM
 #2

I should add that I know I'll need to dispose these objects when I get the code working, I've omitted that just to keep things simpler looking. Smiley

Author of BitSharp, a C# Bitcoin node
https://github.com/pmlyon/BitSharp/wiki
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!