mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-06-06 22:19:30 +00:00
fix(tests): wrap HmacDrbgContext via newBearSslRng for libp2p v2.0.0
libp2p v2.0.0's 3-arg `random(T, scheme, rng)` overload now takes the `Rng` wrapper type instead of `var HmacDrbgContext`. My prior `common.rng()[]` (deref) attempt resolves to `HmacDrbgContext` which no longer matches. Wrap our existing `ref HmacDrbgContext` (from `common.rng`) via `newBearSslRng` to get an `Rng` value, satisfying the new signature without re-seeding a fresh PRNG on every key generation.
This commit is contained in:
parent
5a21455c88
commit
03ef02a2ff
@ -22,17 +22,17 @@ proc ts*(offset = 0, origin = now()): Timestamp =
|
||||
# Switch
|
||||
|
||||
proc generateEcdsaKey*(): libp2p_keys.PrivateKey =
|
||||
# libp2p v2.0.0 also exports a `rng` symbol (returns the new `Rng` wrapper),
|
||||
# so the unqualified `rng[]` here is ambiguous against our local
|
||||
# `common.rng` template. Qualify explicitly to keep using the
|
||||
# `ref HmacDrbgContext` that `PrivateKey.random` expects.
|
||||
libp2p_keys.PrivateKey.random(ECDSA, common.rng()[]).get()
|
||||
# libp2p v2.0.0's 3-arg `random(T, scheme, rng)` overload now takes the
|
||||
# `Rng` wrapper instead of `var HmacDrbgContext`. Wrap our existing
|
||||
# `ref HmacDrbgContext` (from `common.rng`) via `newBearSslRng` to satisfy
|
||||
# the new signature without re-seeding a fresh PRNG each call.
|
||||
libp2p_keys.PrivateKey.random(ECDSA, newBearSslRng(common.rng())).get()
|
||||
|
||||
proc generateEcdsaKeyPair*(): libp2p_keys.KeyPair =
|
||||
libp2p_keys.KeyPair.random(ECDSA, common.rng()[]).get()
|
||||
libp2p_keys.KeyPair.random(ECDSA, newBearSslRng(common.rng())).get()
|
||||
|
||||
proc generateSecp256k1Key*(): libp2p_keys.PrivateKey =
|
||||
libp2p_keys.PrivateKey.random(Secp256k1, common.rng()[]).get()
|
||||
libp2p_keys.PrivateKey.random(Secp256k1, newBearSslRng(common.rng())).get()
|
||||
|
||||
proc ethSecp256k1Key*(hex: string): eth_keys.PrivateKey =
|
||||
eth_keys.PrivateKey.fromHex(hex).get()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user