aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-05-13 20:45:20 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-08-28 21:26:54 +0100
commit9b1afe5f2d488c64e3fb5e087055cf66d2165391 (patch)
treea61056d713db439c80617296b9b3031cb67bd744 /src/crypto
parentMerge pull request #991 (diff)
downloadmonero-9b1afe5f2d488c64e3fb5e087055cf66d2165391.tar.xz
ringct: import of Shen Noether's ring confidential transactions
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/crypto-ops.c14
-rw-r--r--src/crypto/crypto-ops.h8
-rw-r--r--src/crypto/crypto.h16
-rw-r--r--src/crypto/keccak.c6
-rw-r--r--src/crypto/keccak.h4
5 files changed, 35 insertions, 13 deletions
diff --git a/src/crypto/crypto-ops.c b/src/crypto/crypto-ops.c
index a9b659a6b..1b390e402 100644
--- a/src/crypto/crypto-ops.c
+++ b/src/crypto/crypto-ops.c
@@ -40,17 +40,15 @@ DISABLE_VS_WARNINGS(4146 4244)
static void fe_mul(fe, const fe, const fe);
static void fe_sq(fe, const fe);
-static void fe_tobytes(unsigned char *, const fe);
static void ge_madd(ge_p1p1 *, const ge_p3 *, const ge_precomp *);
static void ge_msub(ge_p1p1 *, const ge_p3 *, const ge_precomp *);
static void ge_p2_0(ge_p2 *);
static void ge_p3_dbl(ge_p1p1 *, const ge_p3 *);
-static void ge_sub(ge_p1p1 *, const ge_p3 *, const ge_cached *);
static void fe_divpowm1(fe, const fe, const fe);
/* Common functions */
-static uint64_t load_3(const unsigned char *in) {
+uint64_t load_3(const unsigned char *in) {
uint64_t result;
result = (uint64_t) in[0];
result |= ((uint64_t) in[1]) << 8;
@@ -58,7 +56,7 @@ static uint64_t load_3(const unsigned char *in) {
return result;
}
-static uint64_t load_4(const unsigned char *in)
+uint64_t load_4(const unsigned char *in)
{
uint64_t result;
result = (uint64_t) in[0];
@@ -120,7 +118,7 @@ Postconditions:
|h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
*/
-static void fe_add(fe h, const fe f, const fe g) {
+void fe_add(fe h, const fe f, const fe g) {
int32_t f0 = f[0];
int32_t f1 = f[1];
int32_t f2 = f[2];
@@ -258,7 +256,7 @@ static void fe_copy(fe h, const fe f) {
/* From fe_invert.c */
-static void fe_invert(fe out, const fe z) {
+void fe_invert(fe out, const fe z) {
fe t0;
fe t1;
fe t2;
@@ -1031,7 +1029,7 @@ Proof:
so floor(2^(-255)(h + 19 2^(-25) h9 + 2^(-1))) = q.
*/
-static void fe_tobytes(unsigned char *s, const fe h) {
+void fe_tobytes(unsigned char *s, const fe h) {
int32_t h0 = h[0];
int32_t h1 = h[1];
int32_t h2 = h[2];
@@ -1591,7 +1589,7 @@ void ge_scalarmult_base(ge_p3 *h, const unsigned char *a) {
r = p - q
*/
-static void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) {
+void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) {
fe t0;
fe_add(r->X, p->Y, p->X);
fe_sub(r->Y, p->Y, p->X);
diff --git a/src/crypto/crypto-ops.h b/src/crypto/crypto-ops.h
index cdc5ac1ee..4986499f4 100644
--- a/src/crypto/crypto-ops.h
+++ b/src/crypto/crypto-ops.h
@@ -143,3 +143,11 @@ void sc_sub(unsigned char *, const unsigned char *, const unsigned char *);
void sc_mulsub(unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *);
int sc_check(const unsigned char *);
int sc_isnonzero(const unsigned char *); /* Doesn't normalize */
+
+// internal
+uint64_t load_3(const unsigned char *in);
+uint64_t load_4(const unsigned char *in);
+void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q);
+void fe_add(fe h, const fe f, const fe g);
+void fe_tobytes(unsigned char *, const fe);
+void fe_invert(fe out, const fe z);
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index fa55c2aab..aa437d57d 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -64,6 +64,22 @@ namespace crypto {
friend class crypto_ops;
};
+ POD_CLASS public_keyV {
+ std::vector<public_key> keys;
+ int rows;
+ };
+
+ POD_CLASS secret_keyV {
+ std::vector<secret_key> keys;
+ int rows;
+ };
+
+ POD_CLASS public_keyM {
+ int cols;
+ int rows;
+ std::vector<secret_keyV> column_vectors;
+ };
+
POD_CLASS key_derivation: ec_point {
friend class crypto_ops;
};
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c
index 3ee2a887c..090d563a2 100644
--- a/src/crypto/keccak.c
+++ b/src/crypto/keccak.c
@@ -73,11 +73,11 @@ void keccakf(uint64_t st[25], int rounds)
// compute a keccak hash (md) of given byte length from "in"
typedef uint64_t state_t[25];
-int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen)
+int keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
{
state_t st;
uint8_t temp[144];
- int i, rsiz, rsizw;
+ size_t i, rsiz, rsizw;
rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen;
rsizw = rsiz / 8;
@@ -106,7 +106,7 @@ int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen)
return 0;
}
-void keccak1600(const uint8_t *in, int inlen, uint8_t *md)
+void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md)
{
keccak(in, inlen, md, sizeof(state_t));
}
diff --git a/src/crypto/keccak.h b/src/crypto/keccak.h
index 4f7f85729..fbd8e1904 100644
--- a/src/crypto/keccak.h
+++ b/src/crypto/keccak.h
@@ -16,11 +16,11 @@
#endif
// compute a keccak hash (md) of given byte length from "in"
-int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen);
+int keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen);
// update the state
void keccakf(uint64_t st[25], int norounds);
-void keccak1600(const uint8_t *in, int inlen, uint8_t *md);
+void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md);
#endif