GithubHelp home page GithubHelp logo

ikalchev / kpabe-yct14-cpp Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 4.0 16 KB

A lightweight Key-Policy Attribute-Based Encryption scheme in C++

License: Apache License 2.0

Python 5.94% C++ 94.06%
abe access-control attribute-based encryption-scheme functional-encryption

kpabe-yct14-cpp's People

Contributors

ikalchev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kpabe-yct14-cpp's Issues

kp abe on ESP32

Hello,
I am interested on testing the kp abe on an esp32 device. I would like to know how to load the dependencies (GMP and PBC are not part of the FreeRT-OS from espressif idf). Can you make a branch with the modifications for the kp abe to run on the esp32 please?
Thanks in advance

YCT-KPABE on ESP32

Hello,
I would like to implement the library on ESP32.
Kindly advise on the modifications that should be done in order to flash the library on ESP32.
Do you recommend a specific compilation method for the dependencies (gmp, pbc, mbedtls, and boost.test)?
Should the library be imported in an ESP32-template (https://github.com/espressif/esp-idf-template) and then flashed using the idf.py command instead of Scons?
Note: I have already recompiled the libraries PBC and GMP as was mentioned in your reply to the closed issue, however, not successfully flashed on ESP32.

Error compiling using scons

I am using WSL with Ubuntu under Windows 10. I installed all the relevant libraries to compile the code. However, when attempting to compile using scons -f SConstruct.py I get an error. The full output from the compiler is below.

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o kpabe.o -c -std=gnu++14 -Os -I. -I/usr/local/include -I/usr/local/include/pbc kpabe.cpp
kpabe.cpp: In function 'void mbedtlsSymCrypt(const uint8_t*, size_t, uint8_t*, uint8_t*, size_t*, mbedtls_operation_t)':
kpabe.cpp:54:49: error: 'const struct mbedtls_cipher_info_t' has no member named 'key_bitlen'
   54 |    mbedtls_cipher_setkey(&ctx, key, cipherInfo->key_bitlen, mode);
      |                                                 ^~~~~~~~~~
kpabe.cpp:57:54: error: 'const struct mbedtls_cipher_info_t' has no member named 'iv_size'
   57 |    mbedtls_cipher_crypt(&ctx, iv.data(), cipherInfo->iv_size, input, ilen, output, olen);
      |                                                      ^~~~~~~
scons: *** [kpabe.o] Error 1
scons: building terminated because of errors.

Do you have any ideas of what the issue could be?

AND with more than 15 attributes causes decryption to fail

Hello,
I was trying to decrypt the secret with a "worst case" policy of all attributes in the universe in AND. See the code below:

#include <vector>
#include <iostream>

#include <pbc/pbc.h>

#include "kpabe.hpp"

using namespace std;

int main() {
   // Setup the scheme
   PrivateParams priv;
   PublicParams pub;
   vector <int> attributeUniverse {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
   setup(attributeUniverse, pub, priv);

   // Create an access policy and derive a key for it.
   // (1 OR 2) AND (3 OR 4)
    Node node1(1);
    Node node2(2);
    Node node3(3);
    Node node4(4);
    Node node5(5);
    Node node6(6);
    Node node7(7);
    Node node8(8);
    Node node9(9);
    Node node10(10);
    Node node11(11);
    Node node12(12);
    Node node13(13);
    Node node14(14);
    Node node15(15);
    Node root(Node::Type::AND, {node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, node14, node15});

   auto key = keyGeneration(priv, root);

   // Create an attribute-based secret (attributes 1 and 3).
   element_s secret;
   //vector<int> encryptionAttributes {1, 3};
   auto Cw = createSecret(pub, attributeUniverse, secret);

   // Recover secret
   element_s recovered;
   recoverSecret(key, Cw, attributeUniverse, recovered);
   cout << element_cmp(&secret, &recovered) << endl; // should be ==0

   for(auto& attrCiPair: Cw) {
      element_clear(&attrCiPair.second);
   }
   Cw.clear();

   // Secret cannto be recovered if the encryption attributes do not satisfy the policy.
   //encryptionAttributes = {1};
   //Cw = createSecret(pub, encryptionAttributes, secret);
   //try {
   //   recoverSecret(key, Cw, encryptionAttributes, recovered);
   //} catch(const UnsatError& e) {
   //   cout << "Unsatisfied" << endl;
   //}

   return 0;
}


The fact is that for more than 15 attributes in AND the library fails to decrypt the secret.
The line:

cout << element_cmp(&secret, &recovered) << endl; // should be ==0

gives 1.

Is this a library limitation or a bug?

Encrypt/Decrypt Functions

@ikalchev
Hello.
I have found the 'encrypt' and 'decrypt' functions in the kpabe.cpp file, and tested them.
They are not working properly in my test. Have they been tested before?
Could you please give an example on how to use them properly?
Much appreciated.

Build error using SContruct.py

I got the following error when trying to compile.

g++ -o kpabe_test kpabe_test.o -L. -L/usr/local/lib -lpbc -lgmp -lmbedcrypto -lm -lkpabe -lboost_unit_test_framework
./libkpabe.a(kpabe.o): In function `element_pow_zn':
kpabe.cpp:(.text+0x52): undefined reference to `__gmpz_init'
kpabe.cpp:(.text+0x7c): undefined reference to `__gmpz_clear'
./libkpabe.a(kpabe.o): In function `getPairing()':
kpabe.cpp:(.text+0x1f2): undefined reference to `pairing_init_set_str'
./libkpabe.a(kpabe.o): In function `hashElement(element_s*, unsigned char*)':
kpabe.cpp:(.text+0x250): undefined reference to `mbedtls_md_info_from_type'
kpabe.cpp:(.text+0x261): undefined reference to `mbedtls_md'
./libkpabe.a(kpabe.o): In function `mbedtlsSymCrypt(unsigned char const*, unsigned long, unsigned char*, unsigned char*, unsigned long*, mbedtls_operation_t)':
kpabe.cpp:(.text+0x2ac): undefined reference to `mbedtls_cipher_info_from_type'
kpabe.cpp:(.text+0x2bc): undefined reference to `mbedtls_cipher_setup'
kpabe.cpp:(.text+0x2d4): undefined reference to `mbedtls_cipher_setkey'
kpabe.cpp:(.text+0x303): undefined reference to `mbedtls_cipher_crypt'
collect2: error: ld returned 1 exit status
scons: *** [kpabe_test] Error 1
scons: building terminated because of errors.

I have the mbedtls headers in /usr/include/mbedtls/ and /usr/local/include/mbedtls/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.