Skip to content

Commit

Permalink
Replaced random oracle instantiation to fixed-key HMAC in BIP derivat…
Browse files Browse the repository at this point in the history
…ion.

Static method random_oracle_hash was added.
  • Loading branch information
valery-osheter committed Apr 11, 2019
1 parent 358de5f commit f8b6192
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/crypto_utils/crypto_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,10 @@ class hmac_sha256_t : public hmac_template_t<hash_e::sha256>

};

inline buf256_t random_oracle_hash(mem_t input)
{
static const byte_t random_oracle_key[16] = {0xf4, 0x91, 0xf2, 0x73, 0x2b, 0x8d, 0x40, 0xe7, 0x81, 0x2b, 0x53, 0x5c, 0x6e, 0xa5, 0xbb, 0xc4};
return hmac_sha256_t(mem_t(random_oracle_key, 16)).calculate(input);
}

} //namespace crypto
19 changes: 6 additions & 13 deletions src/mpc_crypto_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,13 @@ static int test_bip()
return rv;
}

namespace mpc {
extern int zk_paillier_range_time;
}

MPCCRYPTO_API int MPCCrypto_test()
{
int rv = 0;
/*

if (rv = test_bip()) return rv;

test_key_t eddsa_key;
if (rv = test_eddsa_gen(eddsa_key)) return rv;
if (rv = test_eddsa_backup(eddsa_key)) return rv;
Expand All @@ -576,36 +575,30 @@ MPCCRYPTO_API int MPCCrypto_test()
if (rv = test_refresh(eddsa_key)) return rv;
}

*/

test_key_t ecdsa_key;
if (rv = test_ecdsa_gen(ecdsa_key)) return rv;

uint64_t t = ub::read_timer_ms();
for (int i=0; i<10; i++)
{
if (rv = test_ecdsa_sign(ecdsa_key)) return rv;
}
t = ub::read_timer_ms() - t;

/*

if (rv = test_ecdsa_backup(ecdsa_key)) return rv;
for (int i=0; i<3; i++)
{
if (rv = test_ecdsa_sign(ecdsa_key)) return rv;
if (rv = test_refresh(ecdsa_key)) return rv;
}

if (rv = test_bip()) return rv;
test_key_t secret_key1; if (rv = test_generic_secret_import(secret_key1)) return rv;
test_key_t secret_key2; if (rv = test_generic_secret_gen(secret_key2)) return rv;
for (int i = 0; i<3; i++)
{
if (rv = test_refresh(secret_key2)) return rv;
}
*/
printf("\nAll tests successfully finished. 10 Signatures took %d ms\n", int(t));

return rv;
}

3 changes: 2 additions & 1 deletion src/mpc_protocols/mpc_eddsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ ecc_point_t tweak_to_point(mem_t tweak) // static
bn_t p, a, b;
crypto::curve_p256.get_params(p, a, b);

buf256_t h = sha256_t::hash(tweak);
buf256_t h = crypto::random_oracle_hash(tweak);

bn_t x = bn_t(h) % p;

ecc_point_t point(crypto::curve_p256);
Expand Down

0 comments on commit f8b6192

Please sign in to comment.