From 2bf5effe95641667a1ed51c04eff7760f6a42ef4 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 3 Oct 2016 13:00:14 +0200 Subject: Initial --- main.cpp | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ce1573f --- /dev/null +++ b/main.cpp @@ -0,0 +1,141 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "bigint.h" +#include "numalgo.h" +#include "rsa.h" + +using namespace std; + +class eof_error : public runtime_error{ +public: + eof_error() + :runtime_error("EOF"){} +}; + +int64_t rand64(){ + return ((int64_t)rand()<<32)+(((int64_t)rand()%2)<<31)+rand(); +} + +Bigint readevalexpr(istream &is){ + Bigint a; + is>>a; + if(is.eof())throw eof_error(); + // cerr<<"Read "<>s; + assert(!is.fail()); + a=readevalexpr(is); + Bigint b=readevalexpr(is); + //cerr<<"Operation "<>bi; + assert(bi==Bigint(n)); + } + } +#endif + +#if 1 + { + string s="4405994068155852661780322209877856931246944549396705884037139443014164958640201650440984581318995014"; + istringstream iss(s); + Bigint bi; + iss>>bi; + uint32_t digs[11]={1752788038,953502834,2175607868,1627159508,1754291416,1207689192,3196357285,3165170272,3313904421,3194703103,2062}; + for(int i=0;i<11;i++)assert(bi._digit(i)==digs[i]); + ostringstream oss; + oss<