Change ciphertext length to match protocol spec, and refactor the use of constants.

This commit is contained in:
Sean Bowe
2016-05-04 18:25:38 -06:00
parent c9a2eea5e2
commit 5961dcb6da
11 changed files with 60 additions and 44 deletions

View File

@@ -8,8 +8,7 @@
#include "uint256.h"
#include "serialize.h"
static const unsigned int INCREMENTAL_MERKLE_TREE_DEPTH = 20;
static const unsigned int INCREMENTAL_MERKLE_TREE_DEPTH_TESTING = 4;
#include "Zcash.h"
namespace libzcash {

View File

@@ -165,7 +165,7 @@ uint256 random_uint256()
return ret;
}
template class NoteEncryption<ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE>;
template class NoteDecryption<ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE>;
template class NoteEncryption<ZCASH_NOTEPLAINTEXT_LEADING + ZCASH_V_SIZE + ZCASH_RHO_SIZE + ZCASH_R_SIZE + ZCASH_MEMO_SIZE>;
template class NoteDecryption<ZCASH_NOTEPLAINTEXT_LEADING + ZCASH_V_SIZE + ZCASH_RHO_SIZE + ZCASH_R_SIZE + ZCASH_MEMO_SIZE>;
}

View File

@@ -9,7 +9,7 @@ https://github.com/zcash/zips/blob/master/protocol/protocol.pdf
#include <boost/array.hpp>
#include "uint256.h"
#include "zerocash/Zerocash.h"
#include "zcash/Zcash.h"
namespace libzcash {
@@ -73,7 +73,7 @@ uint256 random_uint256();
}
typedef libzcash::NoteEncryption<ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE> ZCNoteEncryption;
typedef libzcash::NoteDecryption<ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE> ZCNoteDecryption;
typedef libzcash::NoteEncryption<ZCASH_NOTEPLAINTEXT_LEADING + ZCASH_V_SIZE + ZCASH_RHO_SIZE + ZCASH_R_SIZE + ZCASH_MEMO_SIZE> ZCNoteEncryption;
typedef libzcash::NoteDecryption<ZCASH_NOTEPLAINTEXT_LEADING + ZCASH_V_SIZE + ZCASH_RHO_SIZE + ZCASH_R_SIZE + ZCASH_MEMO_SIZE> ZCNoteDecryption;
#endif /* ZC_NOTE_ENCRYPTION_H_ */
#endif /* ZC_NOTE_ENCRYPTION_H_ */

18
src/zcash/Zcash.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef _ZCCONSTANTS_H_
#define _ZCCONSTANTS_H_
#define ZC_NUM_JS_INPUTS 2
#define ZC_NUM_JS_OUTPUTS 2
#define INCREMENTAL_MERKLE_TREE_DEPTH 20
#define INCREMENTAL_MERKLE_TREE_DEPTH_TESTING 4
// TODO: these constants should be 'ZC'
// for consistency, but I didn't want to
// interfere with the old constants
#define ZCASH_NOTEPLAINTEXT_LEADING 1
#define ZCASH_V_SIZE 8
#define ZCASH_RHO_SIZE 32
#define ZCASH_R_SIZE 32
#define ZCASH_MEMO_SIZE 128
#endif // _ZCCONSTANTS_H_