Skip to content

Commit

Permalink
init commit of privacy stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kk47 committed Jul 24, 2019
1 parent 2f96037 commit b4c08ec
Show file tree
Hide file tree
Showing 478 changed files with 84,255 additions and 866 deletions.
879 changes: 16 additions & 863 deletions dpos.log

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dpos.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
class index:

def GET(self):
#res, msg = data_update(db_file, url='http://seed1.bumo.io:16002/')
res, msg = data_update(db_file, url='http://127.0.0.1:36012/')
res, msg = data_update(db_file, url='http://seed1.bumo.io:16002/')
#res, msg = data_update(db_file, url='http://127.0.0.1:36012/')
v_cands=data_read('validator_candidates', db_file)
k_cands=data_read('kol_candidates', db_file)
committee=data_read('committee', db_file)
Expand Down
3 changes: 2 additions & 1 deletion model/dpos_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


base_url = 'http://127.0.0.1:36012/'
#base_url = 'http://seed1.bumo.io:16002/'
max_items = 500 # max tx number per http request
genesis_account = 'buQs9npaCq9mNFZG18qu88ZcmXYqd6bqpTU3'
genesis_priv_key = 'privbvYfqQyG3kZyHE4RX4TYVa32htw8xG4WdpCTrymPUJQ923XkKVbM'
Expand Down Expand Up @@ -660,7 +661,7 @@ def dposInit(self, update=False):
input_str = "{\"method\": \"init\", \"params\": {\"logic_contract\": \"%s\", \"committee\": [\"buQZoJk8bq6A1AtsmfRw3rYJ79eMHUyct9i2\", \"buQYKj4TTJPVDPXCLWeBZMoCr1JPhq9Z2tJm\", \"buQcYkkoZFMwDNQgCD7DoykNZjtax4FjVSzy\", \"buQmKmaeCyGcPk9KbvnkhpLzQa34tQ9MaWwt\"]}}" % logic_addr

logger.info('Start create dpos delegate contract')
res = self.createContract(dpos_addr, newNonce(dpos_creator_account['address']), content, input_str, src_account=dpos_creator_account)
res = self.createContract(dpos_addr, self.newNonce(dpos_creator_account['address']), content, input_str, src_account=dpos_creator_account)
if debug:
logger.info(json.dumps(res, indent=4))

Expand Down
2 changes: 2 additions & 0 deletions privacy/zsl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pk
*.vk
11 changes: 11 additions & 0 deletions privacy/zsl/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CXXFLAGS = -Wno-unused-parameter -std=c++11 -fPIC -Wno-unused-variable
CXXFLAGS += -L./zsl/snark

LDLIBS += -lgmpxx -lgmp -lboost_system -fopenmp -lcrypto -lzsl
SUBDIR = ./zsl/snark

all:
cd $(SUBDIR) && make
g++ main.cpp utils/util.cpp utils/sha256.cpp -o zsltest $(CXXFLAGS) $(LDLIBS)
clean:
rm -f zsltest ./zsl/snark/libsnark.a
74 changes: 74 additions & 0 deletions privacy/zsl/api.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef _API_HPP_
#define _API_HPP_

#include <string>
#include <iostream>
#include <fstream>

#include "note.hpp"


void computeSendNullifier(unsigned char *rho, unsigned char *send_nf) {
unsigned char data[33];
data[0] = 0x00;

for(int i = 0; i < 32; i++) {
data[i+1] = rho[i];
}

sha256(data, 33, send_nf);

return;
}

void computeSpendNullifier(unsigned char *rho, unsigned char *sk, unsigned char *spend_nf) {
unsigned char data[65];
data[0] = 0x01;

for(int i = 0; i < 32; i++) {
data[i+1] = rho[i];
}

for(int i = 0; i < 32; i++) {
data[i+33] = sk[i];
}

sha256(data, 65, spend_nf);

return;
}

void computeCommitment(unsigned char *rho, unsigned char *pk, uint64_t value, unsigned char *commitment) {
unsigned char data[64+sizeof(value)];

for(int i = 0; i < 32; i++) {
data[i] = rho[i];
}

for(int i = 0; i < 32; i++) {
data[i+32] = pk[i];
}

for(int i = 0; i < sizeof(value); i++) {
data[i+64] = (value >> (8 * i)) & 255; // little endian, big endian will use << operator
}

sha256(data, 64+sizeof(value), commitment);

return;
}

/*void CreateShielding(unsigned char *rho, unsigned char *pk, uint64_t value, std::map<std::string, std::string>) {
return;
}
void CreateShieldedTransfer(unsigned char *rho_1, unsigned char *sk_1, uint64_t value_1, uint64_t treeIndex_1, std::vector<std::string> authPath_1,
unsigned char *rho_2, unsigned char *sk_2, uint64_t value_2, uint64_t treeIndex_1, std::vector<std::string> authPath_2,
unsigned char *out_rho_1, unsigned char *out_pk_1, uint64_t out_value_1,
unsigned char *out_rho_2, unsigned char *out_pk_2, uint64_t out_value_2) {
return;
}*/

#endif
247 changes: 247 additions & 0 deletions privacy/zsl/main.cpp

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions privacy/zsl/note.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "note.hpp"

Note::Note() {

std::string a_pk_str;
get_randomness(a_pk_str);
if(!a_pk_str.empty()) rho = uint256S(a_pk_str);

std::string rho_str;
get_randomness(rho_str);
if(!rho_str.empty()) rho = uint256S(rho_str);
}

uint256 Note::cm() {
std::string data;
data += a_pk.ToString();
data += to_string(value);
data += rho.ToString();
std::string output;
sha256(data, output);
return uint256S(output);
}

uint256 Note::nullifier(const uint256& a_sk) const {
std::string output;
sha256(rho.ToString(), output);
return uint256S(output);
}
Loading

0 comments on commit b4c08ec

Please sign in to comment.