aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-06-15 22:47:09 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-08-28 21:28:33 +0100
commitdee42d6dac1567d74763d94ee5007943d14b2274 (patch)
tree8ed77243d34bcdf038b95ec815f4147645dad1ec /src
parentmake rct tx serialization work (diff)
downloadmonero-dee42d6dac1567d74763d94ee5007943d14b2274.tar.xz
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).
Diffstat (limited to 'src')
-rw-r--r--src/ringct/rctOps.cpp17
-rw-r--r--src/ringct/rctOps.h4
2 files changed, 21 insertions, 0 deletions
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);
diff --git a/src/ringct/rctOps.h b/src/ringct/rctOps.h
index b3a5b8e52..3eb51be28 100644
--- a/src/ringct/rctOps.h
+++ b/src/ringct/rctOps.h
@@ -96,6 +96,10 @@ namespace rct {
tuple<ctkey, ctkey> ctskpkGen(xmr_amount amount);
//this one is mainly for testing, can take arbitrary amounts..
tuple<ctkey, ctkey> ctskpkGen(key bH);
+ // make a pedersen commitment with given key
+ key commit(xmr_amount amount, key mask);
+ // make a pedersen commitment with zero key
+ key zeroCommit(xmr_amount amount);
//generates a random uint long long
xmr_amount randXmrAmount(xmr_amount upperlimit);