onbit-uchenik / shamir_secret_share

C++ implementation of Shamir Secret Scheme over GF(256)
Apache License 2.0
22 stars 8 forks source link

Using this library in EOS smart contract #3

Closed varshadqz closed 3 years ago

varshadqz commented 3 years ago

I am trying to use this library in EOS smart contract, as it supports c++. Code is as follow:

#include <eosio/eosio.hpp>
#include <eosio/print.hpp>
#include <eosio/system.hpp>
#include <string>
#include <vector>
#include "shamir_secret_share/src/GF(256).h"
#include "shamir_secret_share/src/shamir.h"

using namespace eosio;
using namespace std;
using namespace GF256;
using namespace shamir;

class [[eosio::contract("shamirkey")]] shamirkey: public eosio::contract {
        public:
                using contract::contract;
                shamirkey(name receiver, name code, datastream<const char*> ds):contract(receiver, code, ds) {}
                [[eosio::action]]
                        void sharing(){
                                require_auth(_self);
                                init();
                                scheme scheme1(8,5);
                                shares* scheme1_shares = scheme1.createShares("its our team secret");
                                for(int i=0;i<8;i++) {
                                        print("shares of pariticipant ", (i+1), " => ");
                                        for(auto val:(*scheme1_shares)[i]) {
                                                print(val.x, " ", val.y);
                                        }
                                        print("_____________________________________________________");
                                }
                        }
};

when I compile this SC using:

eosio-cpp shamirkey.cpp -o shamirkey.wasm

Its giving errors :

/usr/opt/eosio.cdt/1.7.0/bin/wasm-ld: error: /tmp/shamirkey.cpp.o: undefined symbol: shamir::init()
/usr/opt/eosio.cdt/1.7.0/bin/wasm-ld: error: /tmp/shamirkey.cpp.o: undefined symbol: shamir::scheme::scheme(int, int)
/usr/opt/eosio.cdt/1.7.0/bin/wasm-ld: error: /tmp/shamirkey.cpp.o: undefined symbol: shamir::scheme::createShares(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
/usr/opt/eosio.cdt/1.7.0/bin/wasm-ld: error: /tmp/shamirkey.cpp.o: undefined symbol: GF256::byte::print()

Please help. How to use this library in an EOSIO smart contract?

onbit-uchenik commented 3 years ago

@varshadqz I think you are not linking it properly. Please read this and try to understand how its linking. https://github.com/onbit-syn/shamir_secret_share Please feel free to reach out even still not working.