diff options
Diffstat (limited to 'src/ringct/rctOps.h')
-rw-r--r-- | src/ringct/rctOps.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/ringct/rctOps.h b/src/ringct/rctOps.h index 1e71c645d..cb19bbbd6 100644 --- a/src/ringct/rctOps.h +++ b/src/ringct/rctOps.h @@ -64,19 +64,27 @@ namespace rct { //Various key initialization functions + 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 } }; + //Creates a zero scalar - key zero(); - void zero(key &z); + inline key zero() { return Z; } + inline void zero(key &z) { memset(&z, 0, 32); } //Creates a zero elliptic curve point - key identity(); - void identity(key &Id); + inline key identity() { return I; } + inline void identity(key &Id) { memcpy(&Id, &I, 32); } + //Creates a key equal to the curve order + inline key curveOrder() { return L; } + inline void curveOrder(key &l) { l = L; } //copies a scalar or point - void copy(key &AA, const key &A); - key copy(const key & AA); + inline void copy(key &AA, const key &A) { memcpy(&AA, &A, 32); } + inline key copy(const key & A) { key AA; memcpy(&AA, &A, 32); return AA; } + //initializes a key matrix; //first parameter is rows, //second is columns - keyM keyMInit(int, int); + keyM keyMInit(size_t rows, size_t cols); //Various key generation functions @@ -85,7 +93,7 @@ namespace rct { void skGen(key &); //generates a vector of secret keys of size "int" - keyV skvGen(int ); + keyV skvGen(size_t rows ); //generates a random curve point (for testing) key pkGen(); @@ -97,9 +105,9 @@ namespace rct { //generates C =aG + bH from b, a is random void genC(key & C, const key & a, xmr_amount amount); //this one is mainly for testing, can take arbitrary amounts.. - tuple<ctkey, ctkey> ctskpkGen(key bH); + tuple<ctkey, ctkey> ctskpkGen(const key &bH); // make a pedersen commitment with given key - key commit(xmr_amount amount, key mask); + key commit(xmr_amount amount, const key &mask); // make a pedersen commitment with zero key key zeroCommit(xmr_amount amount); //generates a random uint long long @@ -149,11 +157,14 @@ namespace rct { //for mg sigs key cn_fast_hash128(const void * in); key hash_to_scalar128(const void * in); - key cn_fast_hash(ctkeyV PC); - key hash_to_scalar(ctkeyV PC); + key cn_fast_hash(const ctkeyV &PC); + key hash_to_scalar(const ctkeyV &PC); //for mg sigs key cn_fast_hash(const keyV &keys); key hash_to_scalar(const keyV &keys); + //for ANSL + key cn_fast_hash(const key64 keys); + key hash_to_scalar(const key64 keys); //returns hashToPoint as described in https://github.com/ShenNoether/ge_fromfe_writeup key hashToPointSimple(const key &in); |