diff --git a/abc/keys.nim b/abc/keys.nim index a4f3f09..0db9404 100644 --- a/abc/keys.nim +++ b/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