how to return those values using structure or by declaring class
Manoj7390
Posts
-
How to retrieve the user defined data type into main function -
How to retrieve the user defined data type into main functionThe code is working fine. I need to return those three variables i.e. {Pa,c1,c2} from that program to another main program. What should i have to do. I have used structure for that but its not working. Please tell how to return a three user defined data type to the main function
-
Problem in returning the used defined data type using structurehi everyone.. I have written a program where I want to return three user defined data types to the another main() function (here i have not mentioned that main). I want to return {Pa,c1,c2} from this program. Please help me out.
#include <cstdlib>
#include <iostream>
#include <vector>
using std:: cout;
using std:: cin;
using std:: endl;
using namespace std;
#include <math.h>
#include "FiniteFieldElement.hpp"namespace Cryptography
{
template<int P>
class EllipticCurve
{
public:typedef FiniteFieldElement<P> ffe\_t; class Point { friend class EllipticCurve<P>; typedef FiniteFieldElement<P> ffe\_t; ffe\_t x\_; ffe\_t y\_; EllipticCurve \*ec\_; void addDouble(int m, Point& acc) { if ( m > 0 ) { Point r = acc; for ( int n=0; n < m; ++n ) { r += r; // doubling step } acc = r; } } Point scalarMultiply(int k, const Point& a) { Point acc = a; Point res = Point(0,0,\*ec\_); int i = 0, j = 0; int b = k; while( b ) { if ( b & 1 ) { addDouble(i-j,acc); res += acc; j = i; } b >>= 1; ++i; } return res; } void add(ffe\_t x1, ffe\_t y1, ffe\_t x2, ffe\_t y2, ffe\_t & xR, ffe\_t & yR) const { if ( x1 == 0 && y1 ==
-
Problem in returning the used defined data type using structurehi everyone.. I have written a program where I want to return three user defined data types to the another main() function (here i have not mentioned that main). I want to return {Pa,c1,c2} from this program. Please help me out.
#include <cstdlib>
#include <iostream>
#include <vector>
using std:: cout;
using std:: cin;
using std:: endl;
using namespace std;
#include <math.h>
#include "FiniteFieldElement.hpp"namespace Cryptography
{
template<int P>
class EllipticCurve
{
public:typedef FiniteFieldElement<P> ffe\_t; class Point { friend class EllipticCurve<P>; typedef FiniteFieldElement<P> ffe\_t; ffe\_t x\_; ffe\_t y\_; EllipticCurve \*ec\_; void addDouble(int m, Point& acc) { if ( m > 0 ) { Point r = acc; for ( int n=0; n < m; ++n ) { r += r; // doubling step } acc = r; } } Point scalarMultiply(int k, const Point& a) { Point acc = a; Point res = Point(0,0,\*ec\_); int i = 0, j = 0; int b = k; while( b ) { if ( b & 1 ) { addDouble(i-j,acc); res += acc; j = i; } b >>= 1; ++i; } return res; } void add(ffe\_t x1, ffe\_t y1, ffe\_t x2, ffe\_t y2, ffe\_t & xR, ffe\_t & yR) const { if ( x1 == 0 && y
-
How to retrieve the user defined data type into main functionIf I delete template parameter, then it is giving so many errors. I will post the full program to you please fix it. I want to return {Pa,c1,c2} from this program to another main() function. Please help me out.
#include <cstdlib>
#include <iostream>
#include <vector>
using std:: cout;
using std:: cin;
using std:: endl;
using namespace std;
#include <math.h>
#include "FiniteFieldElement.hpp"namespace Cryptography
{
template<int P>
class EllipticCurve
{
public:typedef FiniteFieldElement<P> ffe\_t; class Point { friend class EllipticCurve<P>; typedef FiniteFieldElement<P> ffe\_t; ffe\_t x\_; ffe\_t y\_; EllipticCurve \*ec\_; void addDouble(int m, Point& acc) { if ( m > 0 ) { Point r = acc; for ( int n=0; n < m; ++n ) { r += r; // doubling step } acc = r; } } Point scalarMultiply(int k, const Point& a) { Point acc = a; Point res = Point(0,0,\*ec\_); int i = 0, j = 0; int b = k; while( b ) { if ( b & 1 ) { addDouble(i-j,acc); res += acc; j = i; } b >>= 1; ++i; } return res; } void add(ffe\_t x1, ffe\_t y1, ffe\_t x2, ffe\_t y2, ffe\_t & xR, ffe\_t & yR) const { if ( x1 == 0 && y1 == 0
-
How to retrieve the user defined data type into main functionThese are the errors i am getting for the program Manoj1.cc:25:17: error: template class without a name Manoj1.cc:25:9: error: template declaration of ‘typedef’ Manoj1.cc:39:44: error: ‘P’ was not declared in this scope Manoj1.cc:39:45: error: template argument 1 is invalid Manoj1.cc:47:37: error: ‘EllipticCurve’ is not a template Manoj1.cc:47:51: error: ‘P’ was not declared in this scope Manoj1.cc:49:48: error: ‘P’ was not declared in this scope Manoj1.cc:49:49: error: template argument 1 is invalid Manoj1.cc:231:41: error: ‘Cryptography::EllipticCurve’ is not a template Manoj1.cc:231:55: error: ‘P’ was not declared in this scope Manoj1.cc:243:59: error: ‘Cryptography::EllipticCurve’ is not a template Manoj1.cc:243:73: error: ‘P’ was not declared in this scope Manoj1.cc:418:25: error: ‘Cryptography::EllipticCurve’ is not a template Manoj1.cc:418:39: error: ‘P’ was not declared in this scope Manoj1.cc:420:31: error: ‘EllipticCurve’ is not a template Manoj1.cc:420:45: error: ‘P’ was not declared in this scope Manoj1.cc:521:36: error: ‘P’ was not declared in this scope Manoj1.cc:521:37: error: template argument 1 is invalid Manoj1.cc:525:36: error: ‘P’ was not declared in this scope Manoj1.cc:525:37: error: template argument 1 is invalid Manoj1.cc:533:64: error: ‘Cryptography::EllipticCurve’ is not a template Manoj1.cc:549:40: error: ‘P’ was not declared in this scope Manoj1.cc:549:41: error: template argument 1 is invalid Manoj1.cc:551:40: error: ‘P’ was not declared in this scope Manoj1.cc:551:41: error: template argument 1 is invalid Manoj1.cc: In member function ‘Cryptography::EllipticCurve::Point Cryptography::EllipticCurve::Point::scalarMultiply(int, const Cryptography::EllipticCurve::Point&)’: Manoj1.cc:90:51: error: call of overloaded ‘Point(int, int, Cryptography::EllipticCurve&)’ is ambiguous Manoj1.cc:90:51: note: candidates are: Manoj1.cc:243:21: note: Cryptography::EllipticCurve::Point::Point(const ffe_t&, const ffe_t&, Cryptography::EllipticCurve&) Manoj1.cc:231:21: note: Cryptography::EllipticCurve::Point::Point(int, int, Cryptography::EllipticCurve&) Manoj1.cc: In member function ‘void Cryptography::EllipticCurve::Point::add(Cryptography::EllipticCurve::Point::ffe_t, Cryptography::EllipticCurve::Point::ffe_t, Cryptography::EllipticCurve::Point::ffe_t, Cryptography::EllipticCurve::Point::ffe_t, Cryptography::EllipticCurve::Point::ffe_t&, Cryptography::EllipticCurve::Point::ffe_t&) const’: Manoj1.cc:179:40: error: request for member ‘i’ in ‘x1’, which is of non-class t
-
How to retrieve the user defined data type into main functionTemplates and namespaces are very important for my program. I have not posted the full code there...
-
How to retrieve the user defined data type into main functionHi everyone.. I have written the code for encryption algorithm. It has one user function header file also. Sample code is as shown below... I want return {Pa,C1,C2} in the program to main function. Please help me..
#include
#include
#include
using namespace std;
#include
#include "FiniteFieldElement.hpp"
namespace Cryptography
{
templatetypedef struct {
Cryptography::EllipticCurve::Point Pa;
Cryptography::FiniteFieldElementc1;
Cryptography::FiniteFieldElementc2;
} encrypt_data_t;class EllipticCurve { public: typedef FiniteFieldElement
ffe_t;
class Point { friend class EllipticCurve
;
typedef FiniteFieldElement
ffe_t;
ffe\_t x\_; ffe\_t y\_; EllipticCurve \*ec\_; } ..... ..... .... ... }; typedef EllipticCurve
this_t;
typedef class EllipticCurve
::Point point_t;
namespace utils
{
}
using namespace Cryptography;
using namespace utils;
template
encrypt_data_tmy_encrypt()
{
typedef EllipticCurve<263> ec\_t; ec\_t myEllipticCurve(1,1);
// Alice
ec\_t::Point Pa = a\*G; // public key // encrypt using Bob\`s key ec\_t::Point Pk = a\*Pb; ec\_t::ffe\_t c1( m1\*Pk.x() ); ec\_t::ffe\_t c2( m2\*Pk.y() ); cout << "Encrypted message from Alice to Bob = {Pa,c1,c2} = {" << Pa << ", " << c1 << ", " << c2 << "}\\n\\n"; encrypt\_data\_t <263> ret; ret.Pa = Pa; ret.c1 = c1; ret.c2 = c2; return ret;
}
main()
{
int result;
template
result = encrypt_data_tmy_encrypt();
}"I want to return {Pa,C1,C2} to the main program using structures... I am getting so many errors" "Please help me with this problem"
-
How to use user defined type in other function.Hi.. i have used the structure to pass three different variable as shown below... int main() { struct result t1; t1 = my_encrypt(); cout << t1.pa << t1.c1 << t1.c2 <<; } struct result my_encrypt() { typedef EllipticCurve<263> ec_t; struct result { ec_t::Point Pa; ec_t::ffe_t c1; ec_t::ffe_t c2; }t; ec_t::Point Pk = a*Pb; ec_t::ffe_t t.c1( m1*Pk.x() ); ec_t::ffe_t t.c2( m2*Pk.y() ); return (t); } I am getting so many errors.. Please tell me anything wrong declaration here. Can i declare that structure as global...
-
How to use user defined type in other function.Here is my some part of my code....
int my_encrypt()
{
typedef EllipticCurve<263> ec\_t; ec\_t myEllipticCurve(1,1);
ec_t::Point P = myEllipticCurve[2]; cout << "some point P = " << P << ", 2P = " << (P+P) << "\n"; int a = irand(1,myEllipticCurve.Degree()-1); ec_t::Point Pa = a*G; // public key cout << "Alice' public key Pa = " << a << "*" << G << " = " << Pa << endl;**
ec_t::Point Pk = a*Pb;
ec\_t::ffe\_t c1( m1\*Pk.x() ); ec\_t::ffe\_t c2( m2\*Pk.y() );
I need to return these three values (Pa, C1, C2) into my main function.**
-
How to use user defined type in other function.Hi, I have written a code in C++ which works on the "POINT" user defined type i.e. POINT = (x,y). I am giving input in int form, it is converting it into point might be using "template". I am retrieving these point from another function which is a header file of mine. Now the problem is, I am calling this function in NS-3 software/program, I am unable to convert this point form into integer. * Can i return more than one value from a function, because point has two values i.e. X and Y. Please help me out.
-
Reagarding error with ostreamI think it is not the problem with the code, because i am getting the output with g++ compiler. Now i am using ./waf compiler for NS-3, where i am facing problem. I am not sure ostream is supported by NS-3 because there they use NS_LOG_UNCOND("message") instead of "cout". I am getting errors where i have used ostream. What do you mean by "ostream" and is it compiler dependent.
-
Reagarding error with ostreamIn the main program i am calling another header function called "FiniteFieldElement.h" function. In that function i have used --
// ostream handler
template<int T>
friend ostream& operator<<(ostream& os, const FiniteFieldElement<T>& g)
{
return os << g.i_;
}I am calling this function and using "ostream" in so many places in main function. I am getting the errors like.. /usr/include/c++/4.6/ostream:493:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*) /usr/include/c++/4.6/ostream:473:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, unsigned char) /usr/include/c++/4.6/ostream:468:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, signed char) /usr/include/c++/4.6/ostream:462:5: note: template std::basic_ostream& std::operator<<(std::basic_ostream&, char) /usr/include/c++/4.6/ostream:456:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) /usr/include/c++/4.6/ostream:451:5: note: template std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)
-
Reagarding error with ostreamHi.. I have implemented ECC algorithm in C++ and it is working fine with g++ compiler... I need to apply this program to network simulator - 3. Complier of NS-3 is "./waf", there it is not building and it is giving countless errors mainly regarding "ostream". there is a line regarding ostream in my header function....---
// ostream handler
template<int T>
friend ostream& operator<<(ostream& os, const FiniteFieldElement<T>& g)
{
return os << g.i_;
} -
Bit concatenation in C++I cannot use shifting operator because it will give numbers other than 1/0. If I shift it once i will get 2. I dont want that. I need only binary (1/0).
-
Bit concatenation in C++hi guys.. I have written the below code in C. I have 3 bits in three different integer variables. How can I concatenate those values assuring that i need only binary values (1/0).
#include <stdio.h>
#include "manojturbo5.h"
#include "bitsconv.h"
#include "manojencoder2.h"void main()
{
int message,interleaver,u,p,q,r,final,result,i;printf("Enter the message\n");
scanf("%d",&message);bitconv (message);
for(r=0;r<32;r++)
{
u = array[31-r];
p = encoder(array[31-r]);
q = encoder2(array[31-r]);printf("%d\t %d\t %d\n",u,p,q);
}
return;
} -
D flipflop implementation in C++What i need is, i need to realize D-Flipflop(Digital block), which transfer the input to output when the clock is high. Clock should be of 50% duty cycle, means equal amounts of ON and OF periods. How can i do this in C/C++.
-
D flipflop implementation in C++I don't need a timing info from the system. It should provide the the system clock as a input to my program. How to clock in C++/C for the function of digital blocks.
-
D flipflop implementation in C++Hi, I have implement a D-Flipflop in C++, I.e. 'D' as a input and 'Q' as a output with 'clk' as a conrol input. When clk = '1' and D = '1/0' then Q = D; How to realize clock in C++. It should be of 50% duty cycle using the system frequency. is there any function to use the system clock in program.
-
Bit concatenation in C++Can you please suggest me a program to convert a string into binary, that store in char data type.