incorporated compressed OpenCL generation from https://github.com/scintill/vanitygen/branches/compressed_opencl
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
* Steps:
|
* Steps:
|
||||||
* - Compute Px = Pxj * (1/Pz)^2
|
* - Compute Px = Pxj * (1/Pz)^2
|
||||||
* - Compute Py = Pyj * (1/Pz)^3
|
* - Compute Py = Pyj * (1/Pz)^3
|
||||||
* - Compute H = RIPEMD160(SHA256(0x04 | Px | Py))
|
* - Compute H = RIPEMD160(SHA256({0x02|0x03|0x04} | Px | Py?))
|
||||||
*
|
*
|
||||||
* Output:
|
* Output:
|
||||||
* - Array of 20-byte address hash values
|
* - Array of 20-byte address hash values
|
||||||
@@ -94,6 +94,13 @@
|
|||||||
#define load_be32(v) bswap32(v)
|
#define load_be32(v) bswap32(v)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Configuration -- maybe I shouldn't be passing this in preproc */
|
||||||
|
#ifdef COMPRESSED_ADDRESS
|
||||||
|
__constant bool compressed_address = 1;
|
||||||
|
#else
|
||||||
|
__constant bool compressed_address = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop unrolling macros
|
* Loop unrolling macros
|
||||||
*
|
*
|
||||||
@@ -1234,7 +1241,7 @@ hash_ec_point(uint *hash_out, __global bn_word *xy, __global bn_word *zip)
|
|||||||
bn_mul_mont(&c, &c, &zzi); /* X / Z^2 */
|
bn_mul_mont(&c, &c, &zzi); /* X / Z^2 */
|
||||||
bn_from_mont(&c, &c);
|
bn_from_mont(&c, &c);
|
||||||
|
|
||||||
wh = 0x00000004; /* POINT_CONVERSION_UNCOMPRESSED */
|
wh = compressed_address ? 0x00000002 : 0x00000004; /* POINT_CONVERSION_[UN]COMPRESSED */
|
||||||
|
|
||||||
#define hash_ec_point_inner_3(i) \
|
#define hash_ec_point_inner_3(i) \
|
||||||
wl = wh; \
|
wl = wh; \
|
||||||
@@ -1253,12 +1260,30 @@ hash_ec_point(uint *hash_out, __global bn_word *xy, __global bn_word *zip)
|
|||||||
bn_mul_mont(&c, &c, &zzi); /* Y / Z^3 */
|
bn_mul_mont(&c, &c, &zzi); /* Y / Z^3 */
|
||||||
bn_from_mont(&c, &c);
|
bn_from_mont(&c, &c);
|
||||||
|
|
||||||
#define hash_ec_point_inner_5(i) \
|
if (!compressed_address) {
|
||||||
wl = wh; \
|
#define hash_ec_point_inner_5(i) \
|
||||||
wh = c.d[(BN_NWORDS - 1) - i]; \
|
wl = wh; \
|
||||||
hash1[BN_NWORDS + i] = (wl << 24) | (wh >> 8);
|
wh = c.d[(BN_NWORDS - 1) - i]; \
|
||||||
|
hash1[BN_NWORDS + i] = (wl << 24) | (wh >> 8);
|
||||||
|
|
||||||
bn_unroll(hash_ec_point_inner_5);
|
bn_unroll(hash_ec_point_inner_5);
|
||||||
|
} else {
|
||||||
|
if (bn_is_odd(c)) {
|
||||||
|
hash1[0] |= 0x01000000; /* 0x03 for odd y */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put in the last byte + SHA-2 padding.
|
||||||
|
*/
|
||||||
|
hash1[8] = wh << 24 | 0x800000;
|
||||||
|
hash1[9] = 0;
|
||||||
|
hash1[10] = 0;
|
||||||
|
hash1[11] = 0;
|
||||||
|
hash1[12] = 0;
|
||||||
|
hash1[13] = 0;
|
||||||
|
hash1[14] = 0;
|
||||||
|
hash1[15] = 33 * 8;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hash the first 64 bytes of the buffer
|
* Hash the first 64 bytes of the buffer
|
||||||
@@ -1266,26 +1291,28 @@ hash_ec_point(uint *hash_out, __global bn_word *xy, __global bn_word *zip)
|
|||||||
sha2_256_init(hash2);
|
sha2_256_init(hash2);
|
||||||
sha2_256_block(hash2, hash1);
|
sha2_256_block(hash2, hash1);
|
||||||
|
|
||||||
/*
|
if (!compressed_address) {
|
||||||
* Hash the last byte of the buffer + SHA-2 padding
|
/*
|
||||||
*/
|
* Hash the last byte of the buffer + SHA-2 padding
|
||||||
hash1[0] = wh << 24 | 0x800000;
|
*/
|
||||||
hash1[1] = 0;
|
hash1[0] = wh << 24 | 0x800000;
|
||||||
hash1[2] = 0;
|
hash1[1] = 0;
|
||||||
hash1[3] = 0;
|
hash1[2] = 0;
|
||||||
hash1[4] = 0;
|
hash1[3] = 0;
|
||||||
hash1[5] = 0;
|
hash1[4] = 0;
|
||||||
hash1[6] = 0;
|
hash1[5] = 0;
|
||||||
hash1[7] = 0;
|
hash1[6] = 0;
|
||||||
hash1[8] = 0;
|
hash1[7] = 0;
|
||||||
hash1[9] = 0;
|
hash1[8] = 0;
|
||||||
hash1[10] = 0;
|
hash1[9] = 0;
|
||||||
hash1[11] = 0;
|
hash1[10] = 0;
|
||||||
hash1[12] = 0;
|
hash1[11] = 0;
|
||||||
hash1[13] = 0;
|
hash1[12] = 0;
|
||||||
hash1[14] = 0;
|
hash1[13] = 0;
|
||||||
hash1[15] = 65 * 8;
|
hash1[14] = 0;
|
||||||
sha2_256_block(hash2, hash1);
|
hash1[15] = 65 * 8;
|
||||||
|
sha2_256_block(hash2, hash1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hash the SHA-2 result with RIPEMD160
|
* Hash the SHA-2 result with RIPEMD160
|
||||||
|
|||||||
@@ -933,6 +933,9 @@ vg_ocl_init(vg_context_t *vcp, vg_ocl_context_t *vocp, cl_device_id did,
|
|||||||
if (vocp->voc_quirks & VG_OCL_AMD_BFI_INT)
|
if (vocp->voc_quirks & VG_OCL_AMD_BFI_INT)
|
||||||
end += snprintf(optbuf + end, sizeof(optbuf) - end,
|
end += snprintf(optbuf + end, sizeof(optbuf) - end,
|
||||||
"-DAMD_BFI_INT ");
|
"-DAMD_BFI_INT ");
|
||||||
|
if (vcp->vc_compressed)
|
||||||
|
end += snprintf(optbuf + end, sizeof(optbuf) - end,
|
||||||
|
"-DCOMPRESSED_ADDRESS");
|
||||||
if (vocp->voc_quirks & VG_OCL_NV_VERBOSE)
|
if (vocp->voc_quirks & VG_OCL_NV_VERBOSE)
|
||||||
end += snprintf(optbuf + end, sizeof(optbuf) - end,
|
end += snprintf(optbuf + end, sizeof(optbuf) - end,
|
||||||
"-cl-nv-verbose ");
|
"-cl-nv-verbose ");
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ usage(const char *name)
|
|||||||
"-N Generate namecoin address\n"
|
"-N Generate namecoin address\n"
|
||||||
"-T Generate bitcoin testnet address\n"
|
"-T Generate bitcoin testnet address\n"
|
||||||
"-X <version> Generate address with the given version\n"
|
"-X <version> Generate address with the given version\n"
|
||||||
|
"-F <format> Generate address with the given format (pubkey, compressed)\n"
|
||||||
"-e Encrypt private keys, prompt for password\n"
|
"-e Encrypt private keys, prompt for password\n"
|
||||||
"-E <password> Encrypt private keys with <password> (UNSAFE)\n"
|
"-E <password> Encrypt private keys with <password> (UNSAFE)\n"
|
||||||
"-p <platform> Select OpenCL platform\n"
|
"-p <platform> Select OpenCL platform\n"
|
||||||
@@ -119,11 +120,12 @@ main(int argc, char **argv)
|
|||||||
int pattfpi[MAX_FILE];
|
int pattfpi[MAX_FILE];
|
||||||
int npattfp = 0;
|
int npattfp = 0;
|
||||||
int pattstdin = 0;
|
int pattstdin = 0;
|
||||||
|
int compressed = 0;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,
|
while ((opt = getopt(argc, argv,
|
||||||
"vqik1NTX:eE:p:P:d:w:t:g:b:VSh?f:o:s:D:")) != -1) {
|
"vqik1NTX:F:eE:p:P:d:w:t:g:b:VSh?f:o:s:D:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 2;
|
verbose = 2;
|
||||||
@@ -152,6 +154,16 @@ main(int argc, char **argv)
|
|||||||
addrtype = atoi(optarg);
|
addrtype = atoi(optarg);
|
||||||
privtype = 128 + addrtype;
|
privtype = 128 + addrtype;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
if (!strcmp(optarg, "compressed"))
|
||||||
|
compressed = 1;
|
||||||
|
else
|
||||||
|
if (strcmp(optarg, "pubkey")) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Invalid format '%s'\n", optarg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
prompt_password = 1;
|
prompt_password = 1;
|
||||||
break;
|
break;
|
||||||
@@ -330,6 +342,7 @@ main(int argc, char **argv)
|
|||||||
caseinsensitive);
|
caseinsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vcp->vc_compressed = compressed;
|
||||||
vcp->vc_verbose = verbose;
|
vcp->vc_verbose = verbose;
|
||||||
vcp->vc_result_file = result_file;
|
vcp->vc_result_file = result_file;
|
||||||
vcp->vc_remove_on_match = remove_on_match;
|
vcp->vc_remove_on_match = remove_on_match;
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ vg_exec_context_calc_address(vg_exec_context_t *vxcp)
|
|||||||
}
|
}
|
||||||
len = EC_POINT_point2oct(pgroup,
|
len = EC_POINT_point2oct(pgroup,
|
||||||
pubkey,
|
pubkey,
|
||||||
POINT_CONVERSION_UNCOMPRESSED,
|
vxcp->vxc_vc->vc_compressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED,
|
||||||
eckey_buf,
|
eckey_buf,
|
||||||
sizeof(eckey_buf),
|
sizeof(eckey_buf),
|
||||||
vxcp->vxc_bnctx);
|
vxcp->vxc_bnctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user