Browse Source

use gost-512 for RIPEMD160

master
orignal 6 years ago
parent
commit
fb63b01fe5
  1. 16
      pattern.c
  2. 15
      util.c
  3. 15
      vanitygen.c

16
pattern.c

@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
#include "pattern.h"
#include "util.h"
#include "avl.h"
#include "streebog.h"
/*
* Common code for execution helper
@ -270,7 +270,7 @@ vg_exec_context_calc_address(vg_exec_context_t *vxcp) @@ -270,7 +270,7 @@ vg_exec_context_calc_address(vg_exec_context_t *vxcp)
{
EC_POINT *pubkey;
const EC_GROUP *pgroup;
unsigned char eckey_buf[96], hash1[32], hash2[20];
unsigned char eckey_buf[96], hash1[32], hash2[20], hash3[64];
int len;
vg_exec_context_consolidate_key(vxcp);
@ -290,8 +290,16 @@ vg_exec_context_calc_address(vg_exec_context_t *vxcp) @@ -290,8 +290,16 @@ vg_exec_context_calc_address(vg_exec_context_t *vxcp)
eckey_buf,
sizeof(eckey_buf),
vxcp->vxc_bnctx);
SHA256(eckey_buf, len, hash1);
RIPEMD160(hash1, sizeof(hash1), hash2);
if (vxcp->vxc_vc->vc_pubkeytype == 38) // gostcoin
{
sph_gost512 (hash3, eckey_buf, len);
RIPEMD160(hash3, 64, hash2);
}
else
{
SHA256(eckey_buf, len, hash1);
RIPEMD160(hash1, sizeof(hash1), hash2);
}
memcpy(&vxcp->vxc_binres[1],
hash2, 20);
EC_POINT_free(pubkey);

15
util.c

@ -247,7 +247,7 @@ vg_encode_address(const EC_POINT *ppoint, const EC_GROUP *pgroup, @@ -247,7 +247,7 @@ vg_encode_address(const EC_POINT *ppoint, const EC_GROUP *pgroup,
{
unsigned char eckey_buf[128], *pend;
unsigned char binres[21] = {0,};
unsigned char hash1[32];
unsigned char hash1[32], hash2[64];
pend = eckey_buf;
@ -259,8 +259,16 @@ vg_encode_address(const EC_POINT *ppoint, const EC_GROUP *pgroup, @@ -259,8 +259,16 @@ vg_encode_address(const EC_POINT *ppoint, const EC_GROUP *pgroup,
NULL);
pend = eckey_buf + 0x41;
binres[0] = addrtype;
SHA256(eckey_buf, pend - eckey_buf, hash1);
RIPEMD160(hash1, sizeof(hash1), &binres[1]);
if (addrtype == 38)
{
sph_gost512 (hash2, eckey_buf, pend - eckey_buf);
RIPEMD160(hash2, 64, &binres[1]);
}
else
{
SHA256(eckey_buf, pend - eckey_buf, hash1);
RIPEMD160(hash1, sizeof(hash1), &binres[1]);
}
vg_b58_encode_check(binres, sizeof(binres), result, addrtype == 38);
}
@ -287,6 +295,7 @@ vg_encode_script_address(const EC_POINT *ppoint, const EC_GROUP *pgroup, @@ -287,6 +295,7 @@ vg_encode_script_address(const EC_POINT *ppoint, const EC_GROUP *pgroup,
65,
NULL);
binres[0] = addrtype;
// TODO
SHA256(script_buf, 69, hash1);
RIPEMD160(hash1, sizeof(hash1), &binres[1]);

15
vanitygen.c

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include "pattern.h"
#include "util.h"
#include "streebog.h"
const char *version = VANITYGEN_VERSION;
@ -44,7 +45,7 @@ vg_thread_loop(void *arg) @@ -44,7 +45,7 @@ vg_thread_loop(void *arg)
{
unsigned char hash_buf[128];
unsigned char *eckey_buf;
unsigned char hash1[32];
unsigned char hash1[32], hash2[64];
int i, c, len, output_interval;
int hash_len;
@ -200,8 +201,16 @@ vg_thread_loop(void *arg) @@ -200,8 +201,16 @@ vg_thread_loop(void *arg)
vxcp->vxc_bnctx);
assert(len == 65);
SHA256(hash_buf, hash_len, hash1);
RIPEMD160(hash1, sizeof(hash1), &vxcp->vxc_binres[1]);
if (vcp->vc_pubkeytype == 38) // gostcoin
{
sph_gost512 (hash2, hash_buf, hash_len);
RIPEMD160(hash2, 64, &vxcp->vxc_binres[1]);
}
else
{
SHA256(hash_buf, hash_len, hash1);
RIPEMD160(hash1, sizeof(hash1), &vxcp->vxc_binres[1]);
}
switch (test_func(vxcp)) {
case 1:

Loading…
Cancel
Save