Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to retrieve the user defined data type into main function Pin
Manoj739019-Jun-13 22:54
Manoj739019-Jun-13 22:54 
Hi 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..

C++
#include <cstdlib>

#include <iostream>

#include <vector>

using namespace std;

#include <math.h>

#include "FiniteFieldElement.hpp"


namespace Cryptography

{    
    template<int P>

typedef struct {
  Cryptography::EllipticCurve<P>::Point Pa;
  Cryptography::FiniteFieldElement<P> c1;
  Cryptography::FiniteFieldElement<P> c2;
} encrypt_data_t;

        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_;

                    }

                   
     		.....
		.....
		....
		...

                };
               

                typedef EllipticCurve<P> this_t;

                typedef class EllipticCurve<P>::Point point_t;

namespace   utils

{    

}



using namespace Cryptography;

using namespace utils;


template <int P>
encrypt_data_t<P> my_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 <int P> 
  result = encrypt_data_t<P> my_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"
AnswerRe: How to retrieve the user defined data type into main function Pin
CPallini20-Jun-13 1:57
mveCPallini20-Jun-13 1:57 
GeneralRe: How to retrieve the user defined data type into main function Pin
Manoj739020-Jun-13 18:36
Manoj739020-Jun-13 18:36 
GeneralRe: How to retrieve the user defined data type into main function Pin
Richard MacCutchan20-Jun-13 20:53
mveRichard MacCutchan20-Jun-13 20:53 
AnswerRe: How to retrieve the user defined data type into main function Pin
Richard MacCutchan20-Jun-13 2:09
mveRichard MacCutchan20-Jun-13 2:09 
GeneralRe: How to retrieve the user defined data type into main function Pin
Manoj739020-Jun-13 18:13
Manoj739020-Jun-13 18:13 
GeneralRe: How to retrieve the user defined data type into main function Pin
Richard MacCutchan20-Jun-13 20:38
mveRichard MacCutchan20-Jun-13 20:38 
AnswerRe: How to retrieve the user defined data type into main function Pin
Stefan_Lang24-Jun-13 0:41
Stefan_Lang24-Jun-13 0:41 
GeneralRe: How to retrieve the user defined data type into main function Pin
Manoj73901-Jul-13 18:42
Manoj73901-Jul-13 18:42 
GeneralRe: How to retrieve the user defined data type into main function Pin
Stefan_Lang2-Jul-13 0:22
Stefan_Lang2-Jul-13 0:22 
GeneralRe: How to retrieve the user defined data type into main function Pin
Manoj73902-Jul-13 23:47
Manoj73902-Jul-13 23:47 
GeneralRe: How to retrieve the user defined data type into main function Pin
Stefan_Lang3-Jul-13 0:28
Stefan_Lang3-Jul-13 0:28 
GeneralRe: How to retrieve the user defined data type into main function Pin
Stefan_Lang3-Jul-13 0:36
Stefan_Lang3-Jul-13 0:36 
GeneralRe: How to retrieve the user defined data type into main function Pin
Manoj73903-Jul-13 20:53
Manoj73903-Jul-13 20:53 
GeneralRe: How to retrieve the user defined data type into main function Pin
Stefan_Lang4-Jul-13 1:54
Stefan_Lang4-Jul-13 1:54 
Questionhow to start Pin
john563219-Jun-13 19:04
john563219-Jun-13 19:04 
AnswerRe: how to start Pin
thanh_bkhn19-Jun-13 20:18
professionalthanh_bkhn19-Jun-13 20:18 
AnswerRe: how to start Pin
Richard MacCutchan19-Jun-13 20:29
mveRichard MacCutchan19-Jun-13 20:29 
AnswerRe: how to start Pin
_AnsHUMAN_ 20-Jun-13 23:04
_AnsHUMAN_ 20-Jun-13 23:04 
Questionfatal error C1083: Cannot open source file: ' ..\filea.cpp Pin
ForNow19-Jun-13 5:53
ForNow19-Jun-13 5:53 
QuestionRe: fatal error C1083: Cannot open source file: ' ..\filea.cpp Pin
David Crow19-Jun-13 6:10
David Crow19-Jun-13 6:10 
AnswerRe: fatal error C1083: Cannot open source file: ' ..\filea.cpp Pin
ForNow19-Jun-13 6:19
ForNow19-Jun-13 6:19 
GeneralRe: fatal error C1083: Cannot open source file: ' ..\filea.cpp Pin
Richard MacCutchan19-Jun-13 6:56
mveRichard MacCutchan19-Jun-13 6:56 
SuggestionRe: fatal error C1083: Cannot open source file: ' ..\filea.cpp Pin
David Crow19-Jun-13 7:40
David Crow19-Jun-13 7:40 
QuestionHow to Implement HD video recording using DirectShow.? Pin
mbatra3119-Jun-13 3:34
mbatra3119-Jun-13 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.