BigInteger.probablePrime in C#.Net???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • imranisb

    BigInteger.probablePrime in C#.Net???

    Hi,

    Im developing RSA cryptography based application in VC#.Net 2.0 and
    need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
    doesn't have the BigInteger class but found that one buddy created
    BigInteger class but it is missing some overloading function like
    BigInteger.prob ablePrime(). The code of the BigInteger class developed
    in the C#.Net can be found here:


    Quick suggestions are always welcome.
    Thanks in advance.
  • Pavel Minaev

    #2
    Re: BigInteger.prob ablePrime in C#.Net???

    On Jul 10, 2:10 pm, imranisb <imran...@gmail .comwrote:
    Hi,
    >
    Im developing RSA cryptography based application in VC#.Net 2.0 and
    need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
    doesn't have the BigInteger class but found that one buddy created
    BigInteger class but it is missing some overloading function like
    BigInteger.prob ablePrime(). The code of the BigInteger class developed
    in the C#.Net can be found here:http://www.codeproject.com/KB/cs/biginteger.aspx
    What, exactly, should such a method do?

    Comment

    • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

      #3
      RE: BigInteger.prob ablePrime in C#.Net???

      If you mean the Java BigInteger class and method by that name, then I think
      the easiest thing is just wrap that method in a java console app and run it
      from c#. I suspect implimenting that method in c# is fairly involved...

      "imranisb" wrote:
      Hi,
      >
      Im developing RSA cryptography based application in VC#.Net 2.0 and
      need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
      doesn't have the BigInteger class but found that one buddy created
      BigInteger class but it is missing some overloading function like
      BigInteger.prob ablePrime(). The code of the BigInteger class developed
      in the C#.Net can be found here:

      >
      Quick suggestions are always welcome.
      Thanks in advance.
      >

      Comment

      • Fred Mellender

        #4
        Re: BigInteger.prob ablePrime in C#.Net???

        I wrote a C# interface to GNU GMP (big Number) project. It includes an
        interface to "isPrime", which does the probablistic Miller/Rabin test. You
        can find it at http://sites.google.com/site/fredm/H...terface-to-gmp.
        It uses C++ (dotNet) to make the classes which are then accessible via C#.

        If you don't want to use that, I can supply native C# code that does the
        test; it uses C# native type (ulong, which is 64 bits -- might not be "big"
        enough for your purposes). That code is only about 80 lines long.

        If you want to write your own function, look up Miller-Rabin on the net to
        see how it works.


        "imranisb" <imranisb@gmail .comwrote in message
        news:1779aff3-6ba4-492c-9bc1-8f81b72ad6cf@59 g2000hsb.google groups.com...
        Hi,
        >
        Im developing RSA cryptography based application in VC#.Net 2.0 and
        need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
        doesn't have the BigInteger class but found that one buddy created
        BigInteger class but it is missing some overloading function like
        BigInteger.prob ablePrime(). The code of the BigInteger class developed
        in the C#.Net can be found here:

        >
        Quick suggestions are always welcome.
        Thanks in advance.

        Comment

        • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

          #5
          Re: BigInteger.prob ablePrime in C#.Net???

          Pavel Minaev wrote:
          On Jul 10, 2:10 pm, imranisb <imran...@gmail .comwrote:
          >Im developing RSA cryptography based application in VC#.Net 2.0 and
          >need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
          >doesn't have the BigInteger class but found that one buddy created
          >BigInteger class but it is missing some overloading function like
          >BigInteger.pro bablePrime(). The code of the BigInteger class developed
          >in the C#.Net can be found here:http://www.codeproject.com/KB/cs/biginteger.aspx
          >
          What, exactly, should such a method do?
          http://java.sun.com/javase/6/docs/ap...bablePrime(int)

          would be a good guess.

          Arne

          Comment

          • =?UTF-8?B?QXJuZSBWYWpow7hq?=

            #6
            Re: BigInteger.prob ablePrime in C#.Net???

            Family Tree Mike wrote:
            If you mean the Java BigInteger class and method by that name, then I think
            the easiest thing is just wrap that method in a java console app and run it
            from c#. I suspect implimenting that method in c# is fairly involved...
            The easiest would be to do:

            using System;

            using java.math;

            namespace E
            {
            public class Program
            {
            public static void Main(string[] args)
            {
            BigInteger bi = new BigInteger("123 45");
            Console.WriteLi ne(bi.isProbabl ePrime(10));
            }
            }
            }

            since BigInteger was part of Java 1.1 and therefore exist
            in J#.

            There is just one problem: the implementation !

            It is horrible slow.

            Arne


            Comment

            • Family Tree Mike

              #7
              Re: BigInteger.prob ablePrime in C#.Net???

              But that isn't available in VS 2008, is it?

              "Arne Vajhøj" <arne@vajhoej.d kwrote in message
              news:48768c28$0 $90265$14726298 @news.sunsite.d k...
              Family Tree Mike wrote:
              >If you mean the Java BigInteger class and method by that name, then I
              >think the easiest thing is just wrap that method in a java console app
              >and run it from c#. I suspect implimenting that method in c# is fairly
              >involved...
              >
              The easiest would be to do:
              >
              using System;
              >
              using java.math;
              >
              namespace E
              {
              public class Program
              {
              public static void Main(string[] args)
              {
              BigInteger bi = new BigInteger("123 45");
              Console.WriteLi ne(bi.isProbabl ePrime(10));
              }
              }
              }
              >
              since BigInteger was part of Java 1.1 and therefore exist
              in J#.
              >
              There is just one problem: the implementation !
              >
              It is horrible slow.
              >
              Arne
              >
              >

              Comment

              • =?UTF-8?B?QXJuZSBWYWpow7hq?=

                #8
                Re: BigInteger.prob ablePrime in C#.Net???

                Family Tree Mike wrote:
                "Arne Vajhøj" <arne@vajhoej.d kwrote in message
                news:48768c28$0 $90265$14726298 @news.sunsite.d k...
                >Family Tree Mike wrote:
                >>If you mean the Java BigInteger class and method by that name, then I
                >>think the easiest thing is just wrap that method in a java console
                >>app and run it from c#. I suspect implimenting that method in c# is
                >>fairly involved...
                >>
                >The easiest would be to do:
                >>
                >using System;
                >>
                >using java.math;
                >>
                >namespace E
                >{
                > public class Program
                > {
                > public static void Main(string[] args)
                > {
                > BigInteger bi = new BigInteger("123 45");
                > Console.WriteLi ne(bi.isProbabl ePrime(10));
                > }
                > }
                >}
                >>
                >since BigInteger was part of Java 1.1 and therefore exist
                >in J#.
                >>
                >There is just one problem: the implementation !
                >>
                >It is horrible slow.
                But that isn't available in VS 2008, is it?
                VS 2008 comes with .NET 3.5, .NET 3.5 uses .NET 2.0 CLR, J# runtime
                is available for .NET 2.0.

                Why should it not be possible to make a ref to vjslib.dll in VS 2008 ?

                Arne

                Comment

                • rossum

                  #9
                  Re: BigInteger.prob ablePrime in C#.Net???

                  On Thu, 10 Jul 2008 03:10:50 -0700 (PDT), imranisb
                  <imranisb@gmail .comwrote:
                  >Hi,
                  >
                  >Im developing RSA cryptography based application in VC#.Net 2.0 and
                  >need to use "BigInteger.pro bablePrime()". I know that VC#.Net 2.0
                  >doesn't have the BigInteger class but found that one buddy created
                  >BigInteger class but it is missing some overloading function like
                  >BigInteger.pro bablePrime(). The code of the BigInteger class developed
                  >in the C#.Net can be found here:
                  >http://www.codeproject.com/KB/cs/biginteger.aspx
                  >
                  >Quick suggestions are always welcome.
                  >Thanks in advance.
                  If you have, or can obtain, a copy of "Practical Cryptography" by
                  Ferguson and Schneier they give an algorithm in section 11.4

                  The algorithm is basically very simple:

                  repeat
                  pick a random BigInteger in the right range
                  until (the number you picked is prime)

                  For reasonably sized numbers you will need a probabilistic prime text,
                  such as Miller-Rabin and some sort of level of confidence parameter so
                  you can be sure that your number is prime to better than say 1 in
                  2^128

                  Alternatively have a look at the Java source code for ideas, you can
                  download the Java source from Sun.

                  rossum

                  Comment

                  • Family Tree Mike

                    #10
                    Re: BigInteger.prob ablePrime in C#.Net???

                    I cannot find such a dll on my system. I'm running VS 2008 pro. I found a
                    link that says it needs to be separately installed from this link:
                    http://msdn.microsoft.com/en-us/vjsharp/bb188598.aspx. It isn't clear to me
                    what version you need to target. In other words, would you need to target
                    2.0 and lose LINQ to get this?



                    "Arne Vajhøj" <arne@vajhoej.d kwrote in message
                    news:4876a91d$0 $90275$14726298 @news.sunsite.d k...
                    Family Tree Mike wrote:
                    >"Arne Vajhøj" <arne@vajhoej.d kwrote in message
                    >news:48768c28$ 0$90265$1472629 8@news.sunsite. dk...
                    >>Family Tree Mike wrote:
                    >>>If you mean the Java BigInteger class and method by that name, then I
                    >>>think the easiest thing is just wrap that method in a java console app
                    >>>and run it from c#. I suspect implimenting that method in c# is fairly
                    >>>involved.. .
                    >>>
                    >>The easiest would be to do:
                    >>>
                    >>using System;
                    >>>
                    >>using java.math;
                    >>>
                    >>namespace E
                    >>{
                    >> public class Program
                    >> {
                    >> public static void Main(string[] args)
                    >> {
                    >> BigInteger bi = new BigInteger("123 45");
                    >> Console.WriteLi ne(bi.isProbabl ePrime(10));
                    >> }
                    >> }
                    >>}
                    >>>
                    >>since BigInteger was part of Java 1.1 and therefore exist
                    >>in J#.
                    >>>
                    >>There is just one problem: the implementation !
                    >>>
                    >>It is horrible slow.
                    >
                    But that isn't available in VS 2008, is it?
                    >
                    VS 2008 comes with .NET 3.5, .NET 3.5 uses .NET 2.0 CLR, J# runtime
                    is available for .NET 2.0.
                    >
                    Why should it not be possible to make a ref to vjslib.dll in VS 2008 ?
                    >
                    Arne

                    Comment

                    • =?UTF-8?B?QXJuZSBWYWpow7hq?=

                      #11
                      Re: BigInteger.prob ablePrime in C#.Net???

                      Family Tree Mike wrote:
                      "Arne Vajhøj" <arne@vajhoej.d kwrote in message
                      news:4876a91d$0 $90275$14726298 @news.sunsite.d k...
                      >Family Tree Mike wrote:
                      >>"Arne Vajhøj" <arne@vajhoej.d kwrote in message
                      >>news:48768c28 $0$90265$147262 98@news.sunsite .dk...
                      >>>Family Tree Mike wrote:
                      >>>>If you mean the Java BigInteger class and method by that name, then
                      >>>>I think the easiest thing is just wrap that method in a java
                      >>>>console app and run it from c#. I suspect implimenting that method
                      >>>>in c# is fairly involved...
                      >>>>
                      >>>The easiest would be to do:
                      >>>>
                      >>>using System;
                      >>>>
                      >>>using java.math;
                      >>>>
                      >>>namespace E
                      >>>{
                      >>> public class Program
                      >>> {
                      >>> public static void Main(string[] args)
                      >>> {
                      >>> BigInteger bi = new BigInteger("123 45");
                      >>> Console.WriteLi ne(bi.isProbabl ePrime(10));
                      >>> }
                      >>> }
                      >>>}
                      >>>>
                      >>>since BigInteger was part of Java 1.1 and therefore exist
                      >>>in J#.
                      >>>>
                      >>>There is just one problem: the implementation !
                      >>>>
                      >>>It is horrible slow.
                      >>
                      But that isn't available in VS 2008, is it?
                      >>
                      >VS 2008 comes with .NET 3.5, .NET 3.5 uses .NET 2.0 CLR, J# runtime
                      >is available for .NET 2.0.
                      >>
                      >Why should it not be possible to make a ref to vjslib.dll in VS 2008 ?
                      I cannot find such a dll on my system. I'm running VS 2008 pro. I
                      found a link that says it needs to be separately installed from this
                      link: http://msdn.microsoft.com/en-us/vjsharp/bb188598.aspx. It isn't
                      clear to me what version you need to target. In other words, would you
                      need to target 2.0 and lose LINQ to get this?
                      I think that is the kit.

                      No - I can not see any reason to target 2.0 unless the target
                      system only has 2.0 !

                      Arne

                      Comment

                      • imranisb

                        #12
                        Re: BigInteger.prob ablePrime in C#.Net???

                        Thanks guys for your healthy suggestions.

                        Comment

                        Working...