From 5e4123fda814f9e79aea228cadb2ddd2ce94732a Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 5 Sep 2022 11:09:38 +0200 Subject: [PATCH] tighter nimcrypto imports (#532) --- eth/common/eth_types.nim | 3 +++ eth/p2p/discoveryv5/encoding.nim | 3 ++- eth/p2p/discoveryv5/enr.nim | 2 +- eth/p2p/discoveryv5/hkdf.nim | 5 ++++- eth/p2p/discoveryv5/node.nim | 2 +- eth/p2p/discoveryv5/protocol.nim | 2 -- eth/p2p/rlpx.nim | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/eth/common/eth_types.nim b/eth/common/eth_types.nim index d7c5b21..f85854e 100644 --- a/eth/common/eth_types.nim +++ b/eth/common/eth_types.nim @@ -9,6 +9,9 @@ when (NimMajor, NimMinor) < (1, 4): else: {.push raises: [].} +## Core ethereum types and smalll helpers - keep focused as it gets imported +## from many places + import std/[options, strutils, times], stew/[byteutils, endians2], stint, diff --git a/eth/p2p/discoveryv5/encoding.nim b/eth/p2p/discoveryv5/encoding.nim index b46cd51..49c6d59 100644 --- a/eth/p2p/discoveryv5/encoding.nim +++ b/eth/p2p/discoveryv5/encoding.nim @@ -15,7 +15,8 @@ import std/[tables, options, hashes, net], - nimcrypto, stint, chronicles, stew/[results, byteutils], metrics, + nimcrypto/[bcmode, rijndael, sha2], stint, chronicles, + stew/[results, byteutils], metrics, ".."/../[rlp, keys], "."/[messages, node, enr, hkdf, sessions] diff --git a/eth/p2p/discoveryv5/enr.nim b/eth/p2p/discoveryv5/enr.nim index acb50fe..1cad2f7 100644 --- a/eth/p2p/discoveryv5/enr.nim +++ b/eth/p2p/discoveryv5/enr.nim @@ -12,7 +12,7 @@ import std/[strutils, macros, algorithm, options], - stew/shims/net, stew/[base64, results], nimcrypto, + nimcrypto/[keccak, utils], stew/shims/net, stew/[base64, results], ".."/../[rlp, keys] export options, results, keys diff --git a/eth/p2p/discoveryv5/hkdf.nim b/eth/p2p/discoveryv5/hkdf.nim index 88ee7c9..6332694 100644 --- a/eth/p2p/discoveryv5/hkdf.nim +++ b/eth/p2p/discoveryv5/hkdf.nim @@ -1,4 +1,7 @@ -import nimcrypto +import + nimcrypto/[hmac, hash] + +export hmac, hash proc hkdf*(HashType: typedesc, ikm, salt, info: openArray[byte], output: var openArray[byte]) = diff --git a/eth/p2p/discoveryv5/node.nim b/eth/p2p/discoveryv5/node.nim index 12b7cf0..eda62ac 100644 --- a/eth/p2p/discoveryv5/node.nim +++ b/eth/p2p/discoveryv5/node.nim @@ -9,7 +9,7 @@ import std/hashes, - nimcrypto, stint, chronos, stew/shims/net, chronicles, + nimcrypto/[keccak], stint, chronos, stew/shims/net, chronicles, ../../keys, ../../net/utils, ./enr diff --git a/eth/p2p/discoveryv5/protocol.nim b/eth/p2p/discoveryv5/protocol.nim index 97ecfff..4e09c32 100644 --- a/eth/p2p/discoveryv5/protocol.nim +++ b/eth/p2p/discoveryv5/protocol.nim @@ -88,8 +88,6 @@ import "."/[messages, encoding, node, routing_table, enr, random2, sessions, ip_vote, nodes_verification] -import nimcrypto except toHex - export options, results, node, enr, encoding.maxDiscv5PacketSize diff --git a/eth/p2p/rlpx.nim b/eth/p2p/rlpx.nim index 85906f3..a69d06c 100644 --- a/eth/p2p/rlpx.nim +++ b/eth/p2p/rlpx.nim @@ -9,7 +9,7 @@ import std/[tables, algorithm, deques, hashes, options, typetraits], - stew/shims/macros, chronicles, nimcrypto, chronos, + stew/shims/macros, chronicles, nimcrypto/utils, chronos, ".."/[rlp, common, keys, async_utils], ./private/p2p_types, "."/[kademlia, auth, rlpxcrypt, enode, p2p_protocol_dsl]