Ejemplo n.º 1
0
 //cn_fast_hash for a key-vector of arbitrary length
 //this is useful since you take a number of keys
 //put them in the key vector and it concatenates them
 //and then hashes them
 key cn_fast_hash(const keyV &keys) {
     if (keys.empty()) return rct::hash2rct(crypto::cn_fast_hash("", 0));
     key rv;
     cn_fast_hash(rv, &keys[0], keys.size() * sizeof(keys[0]));
     //dp(rv);
     return rv;
 }
Ejemplo n.º 2
0
	void dp(keyV a) {
		int j = 0;
		printf("[");
		for (j = 0; j < a.size(); j++) {
			dp(a[j]);
			if (j < a.size() - 1) {
				printf(",");
			}
		}
		printf("]");
		printf("\n");
	}
 //sums a vector of curve points (for scalars use sc_add)
 void sumKeys(key & Csum, const keyV &  Cis) {
     identity(Csum);
     size_t i = 0;
     for (i = 0; i < Cis.size(); i++) {
         addKeys(Csum, Csum, Cis[i]);
     }
 }
 //cn_fast_hash for a key-vector of arbitrary length
 //this is useful since you take a number of keys
 //put them in the key vector and it concatenates them
 //and then hashes them
 key cn_fast_hash(const keyV &keys) {
     size_t l = keys.size();
     vector<unsigned char> m(l * 32);
     size_t i;
     for (i = 0 ; i < l ; i++) {
         memcpy(&m[i * 32], keys[i].bytes, 32);
     }
     key rv;
     cn_fast_hash(rv, &m[0], 32 * l);
     //dp(rv);
     return rv;
 }