-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
478 changed files
with
84,255 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pk | ||
*.vk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.