Commit 093a9c0e authored by Jerry Ryan's avatar Jerry Ryan
Browse files

be4 all done too...

parent c9a9abcc
......@@ -33,7 +33,7 @@ inline static void encodeVec(P& poly, const PlaintextModulus& mod, int64_t lb, i
poly.SetValuesToZero();
for( size_t i=0; i < value.size(); i++ ) {
for( size_t i=0; i < value.size() && i < poly.GetLength(); i++ ) {
if( value[i] > INT32_MAX || value[i] < INT32_MIN ) {
PALISADE_THROW( config_error, "Cannot encode a coefficient larger than 32 bits");
}
......
......@@ -77,8 +77,8 @@ typedef native_int::NativeVector<NativeInteger> NativeVector;
//uncommented line (and breaking the documentation of the line)
#ifndef MATHBACKEND
//#define MATHBACKEND 2
#define MATHBACKEND 4
#define MATHBACKEND 2
//#define MATHBACKEND 4
//#define MATHBACKEND 6
#endif
......
......@@ -40,7 +40,7 @@
#include <thread>
#include "backend.h"
#define FIXED_SEED // if defined, then uses a fixed seed number for reproducible results during debug. Use only one OMP thread to ensure reproducibility
//#define FIXED_SEED // if defined, then uses a fixed seed number for reproducible results during debug. Use only one OMP thread to ensure reproducibility
namespace lbcrypto {
......
......@@ -88,42 +88,11 @@ namespace lbcrypto {
vector<int64_t> digest;
HashUtil::Hash(plainText, SHA_256, digest);
cout << "Parms: " << *signKey.GetSignatureParameters().GetILParams() << endl;
Plaintext hashedText( new CoefPackedEncoding(signKey.GetSignatureParameters().GetILParams(), ep, digest) );
cout << "unencoded: " << endl;
cout << std::hex;
for( size_t ii=0; ii<digest.size(); ii++ ) {
cout << std::setfill('0') << std::setw(2) << (unsigned int) digest[ii];
}
cout << std::dec << endl;
cout << "char as int is " << (int)(hashedText->GetCoefPackedValue()[0]&0xff) << endl;
hashedText->Encode();
Element &u = hashedText->GetElement<Element>();
cout << std::hex;
for( size_t ii=0; ii<5; ii++ ) {
cout << u[ii] << " ";
}
cout << std::dec << endl;
cout << "Element Params: " << *u.GetParams() << endl;
cout << "orig: " << u[0] << endl;
u.SwitchFormat();
cout << "switched: " << u[0] << endl;
u.SwitchFormat();
cout << u[0] << endl;
u.SwitchFormat();
cout << u[0] << endl;
u.SwitchFormat();
cout << u[0] << endl;
u.SwitchFormat();
cout << u[0] << endl;
u.SwitchFormat();
cout << u[0] << endl;
u.SwitchFormat();
cout << "signing :" << plainText << " " << plainText.size() << " " << u.GetLength() << endl;
//Getting the trapdoor, its public matrix, perturbation matrix and gaussian generator to use in sampling
Matrix<Element> A = signKey.GetPrivateElement().first;
......@@ -150,7 +119,6 @@ namespace lbcrypto {
typename Element::DggType & dggLargeSigma = signKey.GetSignatureParameters().GetDiscreteGaussianGeneratorLargeSigma();
return RLWETrapdoorUtility<Element>::GaussSampOffline(n, k, T, dgg, dggLargeSigma, base);
}
//Method for signing given object
......@@ -171,8 +139,6 @@ namespace lbcrypto {
Plaintext hashedText;
HashUtil::Hash(plainText, SHA_256, digest);
cout << "sign online :" << plainText << " " << plainText.size() << " " << n << endl;
if( plainText.size() <= n ) {
for (size_t i = 0;i < n - 32;i = i + 4)
digest.push_back(seed[i]);
......@@ -192,7 +158,6 @@ namespace lbcrypto {
Matrix<Element> zHat = RLWETrapdoorUtility<Element>::GaussSampOnline(n, k, A, T, u, dgg, perturbationVector, base);
signatureText->SetElement(zHat);
}
......@@ -210,8 +175,6 @@ namespace lbcrypto {
Plaintext hashedText;
HashUtil::Hash(plainText, SHA_256, digest);
cout << "verify: " << " :" << plainText << ": " << plainText.size() << " " << n << endl;
if( plainText.size() <= n ) {
for (size_t i = 0;i < n - 32;i = i + 4)
digest.push_back(seed[i]);
......@@ -221,9 +184,7 @@ namespace lbcrypto {
hashedText->Encode();
Element &u = hashedText->GetElement<Element>();
cout << "orig: " << u[0] << endl;
u.SwitchFormat();
cout << "switched: " << u[0] << endl;
//Multiply signature with the verification key
Matrix<Element> A = verificationKey.GetPublicElement();
......@@ -233,9 +194,6 @@ namespace lbcrypto {
//Check the verified vector is actually the encoding of the object
Element r = R(0, 0);
cout << "R: " << r[0] << endl;
cout << "U: " << u[0] << endl;
return r == u;
}
......
......@@ -177,19 +177,18 @@ TEST(UTSignatureGPV, sign_verify_multiple_texts) {
Signature<Matrix<Poly>> signature, signature2;
string text("We can use arbitrary sized texts");
string text2("Which looks cool");
text2 = "xxxxxxxxxxxxxxxx";
// scheme.Sign(s_k, text, &signature);
scheme.Sign(s_k, text, &signature);
scheme.Sign(s_k, text2, &signature2);
// EXPECT_EQ(true, scheme.Verify(v_k, signature, text))
// <<"Failed signature 1 - text 1 verification";
EXPECT_EQ(true, scheme.Verify(v_k, signature, text))
<<"Failed signature 1 - text 1 verification";
EXPECT_EQ(true, scheme.Verify(v_k, signature2, text2))
<< "Failed signature 2 - text 2 verification";
// EXPECT_NE(true, scheme.Verify(v_k, signature2, text))
// << "Failed signature 2 - text 1 verification";
// EXPECT_NE(true, scheme.Verify(v_k, signature, text2))
// << "Failed signature 1 - text 2 verification";
EXPECT_NE(true, scheme.Verify(v_k, signature2, text))
<< "Failed signature 2 - text 1 verification";
EXPECT_NE(true, scheme.Verify(v_k, signature, text2))
<< "Failed signature 1 - text 2 verification";
// for( int i=9; i<=64; i++ ) {
// string txt;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment