Skip to content

Commit

Permalink
Fix libsodium, remove ifdefs, compile warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mariano54 committed Aug 28, 2018
1 parent f2ddfad commit 04a978e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 34 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,9 @@ keybase team request-access chia_network

### TODO
* Serialize aggregation info
* Optimize performance
* New constant time hashing to g2
* Secure allocation during signing, key derivation
* Threshold signatures
* Full python implementation
* Remove unnecessary dependency files
* Constant time and side channel attacks
* Adaptor signatures / Blind signatures
5 changes: 0 additions & 5 deletions src/aggregationinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_AGGREGATIONINFO_CPP_
#define SRC_AGGREGATIONINFO_CPP_

#include <string>
#include <cstring>
#include <set>
Expand Down Expand Up @@ -395,5 +392,3 @@ AggregationInfo::AggregationInfo() {}
AggregationInfo::~AggregationInfo() {
Clear();
}

#endif // SRC_BLSAGGREGATIONINFO_HPP_
8 changes: 4 additions & 4 deletions src/bls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ bool BLS::Init() {
std::cout << "ep_param_set_any_pairf() failed";
return false;
}
#if BLSALLOC
if (sodium::sodium_init() < 0) {
#if BLSALLOC == sodium
if (libsodium::sodium_init() < 0) {
std::cout << "libsodium init failed";
return false;
}
Expand All @@ -53,8 +53,8 @@ void BLS::AssertInitialized() {
if (!relic::core_get()) {
throw std::string("Library not initialized properly. Call BLS::Init()");
}
#if BLSALLOC
if (sodium::sodium_init() < 0) {
#if BLSALLOC == sodium
if (libsodium::sodium_init() < 0) {
throw std::string("Libsodium initialization failed.");
}
#endif
Expand Down
5 changes: 0 additions & 5 deletions src/blssignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_BLSSIGNATURE_CPP_
#define SRC_BLSSIGNATURE_CPP_

#include <string>
#include <cstring>
#include "blssignature.hpp"
Expand Down Expand Up @@ -201,5 +198,3 @@ void BLSSignature::CompressPoint(uint8_t* result, relic::g2_t* point) {
}
std::memcpy(result, buffer + 1, SIGNATURE_SIZE);
}

#endif // SRC_BLSSIGNATURE_CPP_
2 changes: 1 addition & 1 deletion src/blsutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <string>
#include <cstdlib>

#if BLSALLOC
#if BLSALLOC == sodium
namespace libsodium {
#include "sodium/utils.h"
#include "sodium/core.h"
Expand Down
6 changes: 0 additions & 6 deletions src/chaincode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_CHAINCODE_CPP_
#define SRC_CHAINCODE_CPP_

#include "chaincode.hpp"
#include "bls.hpp"

Expand Down Expand Up @@ -52,6 +49,3 @@ std::ostream &operator<<(std::ostream &os, ChainCode const &s) {
void ChainCode::Serialize(uint8_t *buffer) const {
bn_write_bin(buffer, ChainCode::CHAIN_CODE_SIZE, chainCode);
}

#endif // SRC_CHAINCODE_CPP_

5 changes: 0 additions & 5 deletions src/extendedprivatekey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_EXTENDEDPRIVATEKEY_CPP_
#define SRC_EXTENDEDPRIVATEKEY_CPP_

#include <string>
#include <cstring>
#include "extendedprivatekey.hpp"
Expand Down Expand Up @@ -218,5 +215,3 @@ void ExtendedPrivateKey::Serialize(uint8_t *buffer) const {

// Destructors in BLSPrivateKey and ChainCode handle cleaning of memory
ExtendedPrivateKey::~ExtendedPrivateKey() {}

#endif // SRC_EXTENDEDPRIVATEKEY_CPP_
7 changes: 1 addition & 6 deletions src/extendedpublickey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_EXTENDEDPUBLICKEY_CPP_
#define SRC_EXTENDEDPUBLICKEY_CPP_

#include <string>
#include "extendedpublickey.hpp"
#include "extendedprivatekey.hpp"
Expand Down Expand Up @@ -58,7 +55,7 @@ ExtendedPublicKey ExtendedPublicKey::PublicChild(uint32_t i) const {
size_t inputLen = BLSPublicKey::PUBLIC_KEY_SIZE + 4 + 1;

// Hmac input includes sk or pk, int i, and byte with 0 or 1
uint8_t hmacInput[inputLen];
uint8_t hmacInput[BLSPublicKey::PUBLIC_KEY_SIZE + 4 + 1];

// Fill the input with the required data
pk.Serialize(hmacInput);
Expand Down Expand Up @@ -145,5 +142,3 @@ void ExtendedPublicKey::Serialize(uint8_t *buffer) const {
chainCode.Serialize(buffer + 13);
pk.Serialize(buffer + 13 + ChainCode::CHAIN_CODE_SIZE);
}

#endif // SRC_EXTENDEDPUBLICKEY_CPP_

0 comments on commit 04a978e

Please sign in to comment.