By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,417 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,417 IT Pros & Developers. It's quick & easy.

BigInteger.probablePrime in C#.Net???

P: n/a
Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.probablePrime()". 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.probablePrime(). 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.
Jul 10 '08 #1
Share this Question
Share on Google+
11 Replies


P: n/a
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.probablePrime()". 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.probablePrime(). 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?
Jul 10 '08 #2

P: n/a
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.probablePrime()". 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.probablePrime(). 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.
Jul 10 '08 #3

P: n/a
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" <im******@gmail.comwrote in message
news:17**********************************@59g2000h sb.googlegroups.com...
Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.probablePrime()". 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.probablePrime(). 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.

Jul 10 '08 #4

P: n/a
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.probablePrime()". 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.probablePrime(). 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
Jul 10 '08 #5

P: n/a
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("12345");
Console.WriteLine(bi.isProbablePrime(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
Jul 10 '08 #6

P: n/a
But that isn't available in VS 2008, is it?

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@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("12345");
Console.WriteLine(bi.isProbablePrime(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

Jul 11 '08 #7

P: n/a
Family Tree Mike wrote:
"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@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("12345");
Console.WriteLine(bi.isProbablePrime(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
Jul 11 '08 #8

P: n/a
On Thu, 10 Jul 2008 03:10:50 -0700 (PDT), imranisb
<im******@gmail.comwrote:
>Hi,

Im developing RSA cryptography based application in VC#.Net 2.0 and
need to use "BigInteger.probablePrime()". 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.probablePrime(). 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

Jul 11 '08 #9

P: n/a
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" <ar**@vajhoej.dkwrote in message
news:48***********************@news.sunsite.dk...
Family Tree Mike wrote:
>"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@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("12345");
Console.WriteLine(bi.isProbablePrime(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
Jul 11 '08 #10

P: n/a
Family Tree Mike wrote:
"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@news.sunsite.dk...
>Family Tree Mike wrote:
>>"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@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("12345");
Console.WriteLine(bi.isProbablePrime(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
Jul 11 '08 #11

P: n/a
Thanks guys for your healthy suggestions.
Jul 12 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.