aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ringct/rctOps.cpp59
-rw-r--r--src/ringct/rctOps.h24
-rw-r--r--utils/gpg_keys/guzzi.asc30
3 files changed, 55 insertions, 58 deletions
diff --git a/src/ringct/rctOps.cpp b/src/ringct/rctOps.cpp
index 239168388..cf55897a7 100644
--- a/src/ringct/rctOps.cpp
+++ b/src/ringct/rctOps.cpp
@@ -37,50 +37,12 @@ namespace rct {
//Various key initialization functions
- //Creates a zero scalar
- void zero(key &zero) {
- memset(&zero, 0, 32);
- }
-
- //Creates a zero scalar
- key zero() {
- static const key z = { {0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 } };
- return z;
- }
-
- //Creates a zero elliptic curve point
- void identity(key &Id) {
- Id[0] = (unsigned char)(0x01);
- memset(Id.bytes+1, 0, 31);
- }
-
- //Creates a zero elliptic curve point
- key identity() {
- key Id;
- Id[0] = (unsigned char)(0x01);
- memset(Id.bytes+1, 0, 31);
- return Id;
- }
-
- //copies a scalar or point
- void copy(key &AA, const key &A) {
- memcpy(&AA, &A, 32);
- }
-
- //copies a scalar or point
- key copy(const key &A) {
- key AA;
- memcpy(&AA, &A, 32);
- return AA;
- }
-
-
//initializes a key matrix;
//first parameter is rows,
//second is columns
- keyM keyMInit(int rows, int cols) {
+ keyM keyMInit(size_t rows, size_t cols) {
keyM rv(cols);
- int i = 0;
+ size_t i = 0;
for (i = 0 ; i < cols ; i++) {
rv[i] = keyV(rows);
}
@@ -107,11 +69,12 @@ namespace rct {
//Generates a vector of secret key
//Mainly used in testing
- keyV skvGen(int rows ) {
+ keyV skvGen(size_t rows ) {
keyV rv(rows);
- int i = 0;
+ size_t i = 0;
+ crypto::rand(rows * sizeof(key), (uint8_t*)&rv[0]);
for (i = 0 ; i < rows ; i++) {
- skGen(rv[i]);
+ sc_reduce32(rv[i].bytes);
}
return rv;
}
@@ -155,7 +118,7 @@ namespace rct {
//generates a <secret , public> / Pedersen commitment but takes bH as input
- tuple<ctkey, ctkey> ctskpkGen(key bH) {
+ tuple<ctkey, ctkey> ctskpkGen(const key &bH) {
ctkey sk, pk;
skpkGen(sk.dest, pk.dest);
skpkGen(sk.mask, pk.mask);
@@ -172,12 +135,12 @@ namespace rct {
return mask;
}
- key commit(xmr_amount amount, key mask) {
- mask = scalarmultBase(mask);
+ key commit(xmr_amount amount, const key &mask) {
+ key c = scalarmultBase(mask);
key am = d2h(amount);
key bH = scalarmultH(am);
- addKeys(mask, mask, bH);
- return mask;
+ addKeys(c, c, bH);
+ return c;
}
//generates a random uint long long (for testing)
diff --git a/src/ringct/rctOps.h b/src/ringct/rctOps.h
index a7e13eefa..cd3a6dc0d 100644
--- a/src/ringct/rctOps.h
+++ b/src/ringct/rctOps.h
@@ -64,19 +64,23 @@ namespace rct {
//Various key initialization functions
+ static const key Z = { {0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 } };
+ static const key I = { {0x01, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 } };
+
//Creates a zero scalar
- key zero();
- void zero(key &z);
+ inline key zero() { return Z; }
+ inline void zero(key &z) { memset(&z, 0, 32); }
//Creates a zero elliptic curve point
- key identity();
- void identity(key &Id);
+ inline key identity() { return I; }
+ inline void identity(key &Id) { memcpy(&Id, &I, 32); }
//copies a scalar or point
- void copy(key &AA, const key &A);
- key copy(const key & AA);
+ inline void copy(key &AA, const key &A) { memcpy(&AA, &A, 32); }
+ inline key copy(const key & A) { key AA; memcpy(&AA, &A, 32); return AA; }
+
//initializes a key matrix;
//first parameter is rows,
//second is columns
- keyM keyMInit(int, int);
+ keyM keyMInit(size_t rows, size_t cols);
//Various key generation functions
@@ -85,7 +89,7 @@ namespace rct {
void skGen(key &);
//generates a vector of secret keys of size "int"
- keyV skvGen(int );
+ keyV skvGen(size_t rows );
//generates a random curve point (for testing)
key pkGen();
@@ -97,9 +101,9 @@ namespace rct {
//generates C =aG + bH from b, a is random
void genC(key & C, const key & a, xmr_amount amount);
//this one is mainly for testing, can take arbitrary amounts..
- tuple<ctkey, ctkey> ctskpkGen(key bH);
+ tuple<ctkey, ctkey> ctskpkGen(const key &bH);
// make a pedersen commitment with given key
- key commit(xmr_amount amount, key mask);
+ key commit(xmr_amount amount, const key &mask);
// make a pedersen commitment with zero key
key zeroCommit(xmr_amount amount);
//generates a random uint long long
diff --git a/utils/gpg_keys/guzzi.asc b/utils/gpg_keys/guzzi.asc
new file mode 100644
index 000000000..2c374523f
--- /dev/null
+++ b/utils/gpg_keys/guzzi.asc
@@ -0,0 +1,30 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mQENBFed+r8BCADScb2cSXAk7v0+tbEUDOf6VuhKc26C2Kfwk/Ei2iWC7Vaa/bru
+aNLpM1nVuWKdNnfX3MZo38yItvxS4HlkI29pXcrzyqd3sfPklPgLliaayKkqh1Xx
+jl6T5NM9VVJ5dMo0pMzns49xFknOsBXdSH/ziZVD0SuSNctNb5XraCrfuDPw0fn0
+lLZ4a6WwUXL9+4Y+xbvNmYHjlnAB7xjvOpprSuJ769zDGpQlV2UXeRqjjMPzVbH4
+PYgmNAItbhvog2UfKeQK8K0Fwj1uNsZ5fnqvoa9lsgsbyV4x4DbQu/W5NVP1ylDC
+MnHKABa8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