From dee42d6dac1567d74763d94ee5007943d14b2274 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 15 Jun 2016 22:47:09 +0100 Subject: ringct: add functions to commit to an amount One to commit to an amount with zero key (for use with fake commitments for pre-rct outputs), and one with an arbitrary key (for rct outputs). --- src/ringct/rctOps.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ringct/rctOps.cpp') diff --git a/src/ringct/rctOps.cpp b/src/ringct/rctOps.cpp index 0561a191a..365b19a41 100644 --- a/src/ringct/rctOps.cpp +++ b/src/ringct/rctOps.cpp @@ -170,6 +170,23 @@ namespace rct { return make_tuple(sk, pk); } + key zeroCommit(xmr_amount amount) { + key mask = identity(); + mask = scalarmultBase(mask); + key am = d2h(amount); + key bH = scalarmultH(am); + addKeys(mask, mask, bH); + return mask; + } + + key commit(xmr_amount amount, key mask) { + mask = scalarmultBase(mask); + key am = d2h(amount); + key bH = scalarmultH(am); + addKeys(mask, mask, bH); + return mask; + } + //generates a random uint long long (for testing) xmr_amount randXmrAmount(xmr_amount upperlimit) { return h2d(skGen()) % (upperlimit); -- cgit v1.2.3