472,958 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

BigInteger.probablePrime in C#.Net???

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
11 10293
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
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
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
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
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
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
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
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
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
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
Thanks guys for your healthy suggestions.
Jul 12 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jerry | last post by:
Hi, I am writing a Java Chatroom application that will implement encryption of messages using the RSA algorithm using the BigInteger class. It uses socket connections to exchange messages. I...
0
by: Krzysztof Adamski | last post by:
Hi, Is it possible in jython to map an PyLong object to other class than BigInteger (i.e. java.lang.Long) ? Thanks for you help, Krzysztof Adamski
4
by: adrin | last post by:
I have to create a c++ class similar to BigInteger from java... but i have no idea, how can i implement big numbers at all(mabye store every digit in list element? :)) how is it properly done? ...
8
by: Nafai | last post by:
Hello I would like you guys to give me the best solution for this problem: class bigInteger { private: vector<char> digits; public: ... bigInteger& operator+=(const bigInteger& x)
0
by: hitler123 | last post by:
can anyone say me how to define BigInteger as a datatype in an xsd. this xsd i am uising in the xmlbeans.
19
by: shana07 | last post by:
I don't understand about this program is doing. Could someone please tell me what it is about. Because I have gcd function in one program that calls this function. Thanks a lot switch (opcode) {...
2
by: gemacjr1201 | last post by:
I am creating a GUI for class and need help with my program. My program takes 2 big integers and adds them together. First how do I declare my 2 Big Integers and then add them together? I have read...
2
by: jehugaleahsa | last post by:
Hello: I am currently working on a some simple (not really) classes called BigInteger and BigRational. They are pretty much identical to Java's BigInteger and BigDecimal classes, respectfully. ...
6
by: mearvk | last post by:
Does C++ or C have something roughly equivalent to this: http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html What I need is a way to quickly convert between decimal and binary and...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.