ringct: cosmetic fixes

Ported from Shen's RingCT repo
This commit is contained in:
Shen Noether 2016-06-02 19:03:35 +01:00 committed by moneromooo-monero
parent 55ff136e12
commit 56f6549962
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
4 changed files with 9 additions and 46 deletions

View file

@ -160,8 +160,8 @@ namespace rct {
skpkGen(sk.dest, pk.dest); skpkGen(sk.dest, pk.dest);
skpkGen(sk.mask, pk.mask); skpkGen(sk.mask, pk.mask);
key am = d2h(amount); key am = d2h(amount);
key aH = scalarmultH(am); key bH = scalarmultH(am);
addKeys(pk.mask, pk.mask, aH); addKeys(pk.mask, pk.mask, bH);
return make_tuple(sk, pk); return make_tuple(sk, pk);
} }
@ -171,13 +171,11 @@ namespace rct {
ctkey sk, pk; ctkey sk, pk;
skpkGen(sk.dest, pk.dest); skpkGen(sk.dest, pk.dest);
skpkGen(sk.mask, pk.mask); skpkGen(sk.mask, pk.mask);
//key am = d2h(amount);
//key aH = scalarmultH(am);
addKeys(pk.mask, pk.mask, bH); addKeys(pk.mask, pk.mask, bH);
return make_tuple(sk, pk); return make_tuple(sk, pk);
} }
//generates a random uint long long //generates a random uint long long (for testing)
xmr_amount randXmrAmount(xmr_amount upperlimit) { xmr_amount randXmrAmount(xmr_amount upperlimit) {
return h2d(skGen()) % (upperlimit); return h2d(skGen()) % (upperlimit);
} }
@ -678,30 +676,6 @@ void fe_mul(fe h,const fe f,const fe g)
void ge_tobytes2(unsigned char *s,const ge_p2 *h)
{
fe recip;
fe x;
fe y;
fe_invert(recip,h->Z);
fe_mul(x,h->X,recip);
fe_mul(y,h->Y,recip);
fe_tobytes(s,y);
}
key hashToPoint2(const key & hh) {
key pointk;
ge_p2 point;
key h = cn_fast_hash(hh);
ge_fromfe_frombytes_vartime(&point, h.bytes);
ge_tobytes2(pointk.bytes, &point);
return pointk;
}
void hashToPoint(key & pointk, const key & hh) { void hashToPoint(key & pointk, const key & hh) {
ge_p2 point; ge_p2 point;
ge_p1p1 point2; ge_p1p1 point2;

View file

@ -149,7 +149,6 @@ namespace rct {
//returns hashToPoint as described in https://github.com/ShenNoether/ge_fromfe_writeup //returns hashToPoint as described in https://github.com/ShenNoether/ge_fromfe_writeup
key hashToPointSimple(const key &in); key hashToPointSimple(const key &in);
key hashToPoint(const key &in); key hashToPoint(const key &in);
key hashToPoint2(const key &in);
void hashToPoint(key &out, const key &in); void hashToPoint(key &out, const key &in);
//sums a vector of curve points (for scalars use sc_add) //sums a vector of curve points (for scalars use sc_add)

View file

@ -49,12 +49,13 @@ namespace rct {
skGen(s2); skGen(s2);
addKeys2(L2, s2, c2, P2); addKeys2(L2, s2, c2, P2);
hash_to_scalar(c1, L2); hash_to_scalar(c1, L2);
//s1 = a - x * c1
sc_mulsub(s1.bytes, x.bytes, c1.bytes, a.bytes); sc_mulsub(s1.bytes, x.bytes, c1.bytes, a.bytes);
} }
else if (index == 1) { else if (index == 1) {
scalarmultBase(L2, a); scalarmultBase(L2, a);
skGen(s1);
hash_to_scalar(c1, L2); hash_to_scalar(c1, L2);
skGen(s1);
addKeys2(L1, s1, c1, P1); addKeys2(L1, s1, c1, P1);
hash_to_scalar(c2, L1); hash_to_scalar(c2, L1);
sc_mulsub(s2.bytes, x.bytes, c2.bytes, a.bytes); sc_mulsub(s2.bytes, x.bytes, c2.bytes, a.bytes);
@ -91,7 +92,6 @@ namespace rct {
asnlSig rv; asnlSig rv;
rv.s = zero(); rv.s = zero();
for (j = 0; j < ATOMS; j++) { for (j = 0; j < ATOMS; j++) {
//void GenSchnorrNonLinkable(Bytes L1, Bytes s1, Bytes s2, const Bytes x, const Bytes P1,const Bytes P2, int index) {
GenSchnorrNonLinkable(rv.L1[j], s1[j], rv.s2[j], x[j], P1[j], P2[j], (int)indices[j]); GenSchnorrNonLinkable(rv.L1[j], s1[j], rv.s2[j], x[j], P1[j], P2[j], (int)indices[j]);
sc_add(rv.s.bytes, rv.s.bytes, s1[j].bytes); sc_add(rv.s.bytes, rv.s.bytes, s1[j].bytes);
} }
@ -119,7 +119,6 @@ namespace rct {
} }
key cc; key cc;
sc_sub(cc.bytes, LHS.bytes, RHS.bytes); sc_sub(cc.bytes, LHS.bytes, RHS.bytes);
DP(cc);
return sc_isnonzero(cc.bytes) == 0; return sc_isnonzero(cc.bytes) == 0;
} }
@ -269,10 +268,6 @@ namespace rct {
copy(c_old, c); copy(c_old, c);
i = (i + 1); i = (i + 1);
} }
DP("c0");
DP(rv.cc);
DP("c_old");
DP(c_old);
sc_sub(c.bytes, c_old.bytes, rv.cc.bytes); sc_sub(c.bytes, c_old.bytes, rv.cc.bytes);
return sc_isnonzero(c.bytes) == 0; return sc_isnonzero(c.bytes) == 0;
} }
@ -327,11 +322,7 @@ namespace rct {
addKeys(Ctmp, Ctmp, as.Ci[i]); addKeys(Ctmp, Ctmp, as.Ci[i]);
} }
bool reb = equalKeys(C, Ctmp); bool reb = equalKeys(C, Ctmp);
DP("is sum Ci = C:");
DP(reb);
bool rab = VerASNL(as.Ci, CiH, as.asig); bool rab = VerASNL(as.Ci, CiH, as.asig);
DP("Is in range?");
DP(rab);
return (reb && rab); return (reb && rab);
} }
@ -369,21 +360,21 @@ namespace rct {
M[i][rows] = identity(); M[i][rows] = identity();
for (j = 0; j < rows; j++) { for (j = 0; j < rows; j++) {
M[i][j] = pubs[i][j].dest; M[i][j] = pubs[i][j].dest;
addKeys(M[i][rows], M[i][rows], pubs[i][j].mask); addKeys(M[i][rows], M[i][rows], pubs[i][j].mask); //add input commitments in last row
} }
} }
sc_0(sk[rows].bytes); sc_0(sk[rows].bytes);
for (j = 0; j < rows; j++) { for (j = 0; j < rows; j++) {
sk[j] = copy(inSk[j].dest); sk[j] = copy(inSk[j].dest);
sc_add(sk[rows].bytes, sk[rows].bytes, inSk[j].mask.bytes); sc_add(sk[rows].bytes, sk[rows].bytes, inSk[j].mask.bytes); //add masks in last row
} }
for (i = 0; i < cols; i++) { for (i = 0; i < cols; i++) {
for (size_t j = 0; j < outPk.size(); j++) { for (size_t j = 0; j < outPk.size(); j++) {
subKeys(M[i][rows], M[i][rows], outPk[j].mask); subKeys(M[i][rows], M[i][rows], outPk[j].mask); //subtract output Ci's in last row
} }
} }
for (size_t j = 0; j < outPk.size(); j++) { for (size_t j = 0; j < outPk.size(); j++) {
sc_sub(sk[rows].bytes, sk[rows].bytes, outSk[j].mask.bytes); sc_sub(sk[rows].bytes, sk[rows].bytes, outSk[j].mask.bytes); //subtract output masks in last row..
} }
key message = cn_fast_hash(outPk); key message = cn_fast_hash(outPk);
return MLSAG_Gen(message, M, sk, index); return MLSAG_Gen(message, M, sk, index);

View file

@ -184,7 +184,6 @@ namespace rct {
int byte, i, j; int byte, i, j;
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
byte = 0; byte = 0;
//val = (unsigned char) test[j];
i = 8 * j; i = 8 * j;
for (i = 7; i > -1; i--) { for (i = 7; i > -1; i--) {
byte = byte * 2 + amountb2[8 * j + i]; byte = byte * 2 + amountb2[8 * j + i];