Use func where possible

This commit is contained in:
Mark Spanbroek 2021-06-28 10:15:03 +02:00
parent b28954e75c
commit 483d60707f
1 changed files with 7 additions and 7 deletions

View File

@ -6,9 +6,9 @@ type
PublicKey* = distinct bls.PublicKey
Signature* = distinct bls.Signature
proc `==`*(a, b: PrivateKey): bool {.borrow.}
proc `==`*(a, b: PublicKey): bool {.borrow.}
proc `==`*(a, b: Signature): bool {.borrow.}
func `==`*(a, b: PrivateKey): bool {.borrow.}
func `==`*(a, b: PublicKey): bool {.borrow.}
func `==`*(a, b: Signature): bool {.borrow.}
proc random*(_: type PrivateKey): PrivateKey =
var seed = newSeq[byte](64)
@ -16,16 +16,16 @@ proc random*(_: type PrivateKey): PrivateKey =
doAssert deriveMasterSecretKey(bls.SecretKey(result), seed)
burnArray(seed)
proc erase*(key: var PrivateKey) =
func erase*(key: var PrivateKey) =
burnMem(key)
proc toPublicKey*(private: PrivateKey): PublicKey =
func toPublicKey*(private: PrivateKey): PublicKey =
doAssert publicFromSecret(bls.PublicKey(result), bls.SecretKey(private))
proc sign*(key: PrivateKey, message: openArray[byte]): Signature =
func sign*(key: PrivateKey, message: openArray[byte]): Signature =
Signature(bls.SecretKey(key).sign(message))
proc verify*(key: PublicKey,
func verify*(key: PublicKey,
message: openArray[byte],
signature: Signature): bool =
## TODO: not safe w.r.t. rogue public-key attack. Needs implementation of