Skip to content

Commit 729a9e0

Browse files
committed
ringct: cleanup proveRctCLSAGSimple
1. Document parameters 2. Document inner variables 3. Remove dead variables 4. Remove unneseccary allocations
1 parent 9866a0e commit 729a9e0

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/ringct/rctSigs.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -761,15 +761,22 @@ namespace rct {
761761
return result;
762762
}
763763

764-
clsag proveRctCLSAGSimple(const key &message, const ctkeyV &pubs, const ctkey &inSk, const key &a, const key &Cout, unsigned int index, hw::device &hwdev) {
765-
//setup vars
766-
size_t rows = 1;
767-
size_t cols = pubs.size();
768-
CHECK_AND_ASSERT_THROW_MES(cols >= 1, "Empty pubs");
769-
keyV tmp(rows + 1);
770-
keyV sk(rows + 1);
771-
keyM M(cols, tmp);
772-
764+
/**
765+
* brief: proveRctCLSAGSimple - given a msg, mixring, pseudo out commitment, and private keys, make a CLSAG proof
766+
* param: message - any message we want to sign, but normally a transaction body hash
767+
* param: pubs - AKA mixring, a list of referenced output pubkey and amount commitment tuples { (K_o, C_a), ... }
768+
* param: inSk - (x, c_a) where x is the privkey of pubs[index].dest and c_a is the blinding factor of pubs[index].mask
769+
* param: c_out - the blinding factor for Cout
770+
* param: Cout - AKA the "pseudo amount commitment"
771+
* param: index - the index of our private keys in the mixring
772+
* return: a CLSAG that proves someone with opening knowledge of K_o[k] and C_a[k] (k unknown) signed this message
773+
*/
774+
clsag proveRctCLSAGSimple(const key &message, const ctkeyV &pubs, const ctkey &inSk, const key &c_out, const key &Cout, unsigned int index, hw::device &hwdev) {
775+
CHECK_AND_ASSERT_THROW_MES(!pubs.empty(), "Empty pubs");
776+
777+
// P: unmodified output pubkeys K_o
778+
// C: commitments to zero C_0 = C_a - Cout
779+
// C_nonzero: unmodified amount commitments C_a
773780
keyV P, C, C_nonzero;
774781
P.reserve(pubs.size());
775782
C.reserve(pubs.size());
@@ -783,10 +790,15 @@ namespace rct {
783790
C.push_back(tmp);
784791
}
785792

786-
sk[0] = copy(inSk.dest);
787-
sc_sub(sk[1].bytes, inSk.mask.bytes, a.bytes);
788-
clsag result = CLSAG_Gen(message, P, sk[0], C, sk[1], C_nonzero, Cout, index, hwdev);
789-
memwipe(sk.data(), sk.size() * sizeof(key));
793+
// zero_commit_sk: private key of "true" commitment to zero c_0 s.t. C_0[index] = c_0 * G
794+
// c_0 = c_a - c_out where:
795+
// c_a is the true amount commitment blinding factor and
796+
// c_out is the blinding factor of the pseudo amount commitment C_out
797+
key zero_commit_sk;
798+
sc_sub(zero_commit_sk.bytes, inSk.mask.bytes, c_out.bytes);
799+
800+
clsag result = CLSAG_Gen(message, P, inSk.dest, C, zero_commit_sk, C_nonzero, Cout, index, hwdev);
801+
memwipe(&zero_commit_sk, sizeof(zero_commit_sk));
790802
return result;
791803
}
792804

0 commit comments

Comments
 (0)