mirror of https://github.com/status-im/nim-abc.git
Use func where possible
This commit is contained in:
parent
b28954e75c
commit
483d60707f
14
abc/keys.nim
14
abc/keys.nim
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue