mirror of
https://github.com/monero-project/monero.git
synced 2024-12-27 15:19:24 -05:00
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).
This commit is contained in:
parent
cc7f449d57
commit
dee42d6dac
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user