mirror of
https://github.com/monero-project/monero.git
synced 2026-01-13 05:16:48 -08:00
bulletproofs: reject points not in the main subgroup
This commit is contained in:
@@ -60,6 +60,17 @@ namespace rct {
|
||||
|
||||
//Various key generation functions
|
||||
|
||||
bool toPointCheckOrder(ge_p3 *P, const unsigned char *data)
|
||||
{
|
||||
if (ge_frombytes_vartime(P, data))
|
||||
return false;
|
||||
ge_p2 R;
|
||||
ge_scalarmult(&R, curveOrder().bytes, P);
|
||||
key tmp;
|
||||
ge_tobytes(tmp.bytes, &R);
|
||||
return tmp == identity();
|
||||
}
|
||||
|
||||
//generates a random scalar which can be used as a secret key or mask
|
||||
void skGen(key &sk) {
|
||||
random32_unbiased(sk.bytes);
|
||||
@@ -200,6 +211,12 @@ namespace rct {
|
||||
return aP;
|
||||
}
|
||||
|
||||
//Computes aL where L is the curve order
|
||||
bool isInMainSubgroup(const key & a) {
|
||||
ge_p3 p3;
|
||||
return toPointCheckOrder(&p3, a.bytes);
|
||||
}
|
||||
|
||||
//Curve addition / subtractions
|
||||
|
||||
//for curve points: AB = A + B
|
||||
|
||||
Reference in New Issue
Block a user