Rename getKey -> getPublicKey (#621)

* rename getKey to getPublicKey

* use publicKey directly in gossipsub

* update error messages
This commit is contained in:
Tanguy Cizain
2021-09-02 12:03:40 +02:00
committed by GitHub
parent 62ca6dd9a0
commit 8cddfde837
17 changed files with 55 additions and 59 deletions

View File

@@ -602,11 +602,9 @@ proc new*(
outgoing: bool = true,
commonPrologue: seq[byte] = @[]): T =
let pkBytes = privateKey
.getKey()
let pkBytes = privateKey.getPublicKey()
.expect("Expected valid Private Key")
.getBytes()
.expect("Couldn't get Private Key bytes")
.getBytes().expect("Couldn't get public Key bytes")
var noise = Noise(
rng: rng,

View File

@@ -435,16 +435,14 @@ proc new*(
T: typedesc[Secio],
rng: ref BrHmacDrbgContext,
localPrivateKey: PrivateKey): T =
let pkRes = localPrivateKey.getKey()
let pkRes = localPrivateKey.getPublicKey()
if pkRes.isErr:
raise newException(Defect, "Can't fetch local private key")
raise newException(Defect, "Invalid private key")
let secio = Secio(
rng: rng,
localPrivateKey: localPrivateKey,
localPublicKey: localPrivateKey
.getKey()
.expect("Can't fetch local private key"),
localPublicKey: pkRes.get(),
)
secio.init()
secio