mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 16:27:39 +00:00
ringct: remove an unnecessary scalarmultBase in zeroCommit
This commit is contained in:
parent
8a7b3ff138
commit
01cc978722
3 changed files with 12 additions and 4 deletions
|
@ -134,12 +134,9 @@ namespace rct {
|
|||
}
|
||||
|
||||
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;
|
||||
return addKeys(G, bH);
|
||||
}
|
||||
|
||||
key commit(xmr_amount amount, const key &mask) {
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace rct {
|
|||
static const key Z = { {0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 } };
|
||||
static const key I = { {0x01, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 , 0x00, 0x00, 0x00,0x00 } };
|
||||
static const key L = { {0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 } };
|
||||
static const key G = { {0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66 } };
|
||||
|
||||
//Creates a zero scalar
|
||||
inline key zero() { return Z; }
|
||||
|
|
|
@ -1061,3 +1061,13 @@ TEST(ringct, key_ostream)
|
|||
out.str()
|
||||
);
|
||||
}
|
||||
|
||||
TEST(ringct, zeroCommmit)
|
||||
{
|
||||
static const uint64_t amount = crypto::rand<uint64_t>();
|
||||
const rct::key z = rct::zeroCommit(amount);
|
||||
const rct::key a = rct::scalarmultBase(rct::identity());
|
||||
const rct::key b = rct::scalarmultH(rct::d2h(amount));
|
||||
const rct::key manual = rct::addKeys(a, b);
|
||||
ASSERT_EQ(z, manual);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue