Mark Spanbroek 742d9e8334 signature scheme needs to support verifying signatures
So that it no longer needs to support recovering a public
key from a signature
2024-12-11 10:53:36 +01:00

29 lines
667 B
Nim

import std/random
import std/sequtils
import std/strutils
import ./hashing
type
MockIdentity* = object
id: string
MockIdentifier* = object
id: string
MockSignature* = object
signer: string
proc init*(_: type MockIdentity): MockIdentity =
MockIdentity(id: newSeqWith(32, rand(byte)).mapIt(it.toHex(2)).join())
func identifier*(identity: MockIdentity): MockIdentifier =
MockIdentifier(id: identity.id)
func sign*(identity: MockIdentity; hash: MockHash): MockSignature =
MockSignature(signer: identity.id)
func verify*(
signature: MockSignature,
identifier: MockIdentifier,
hash: MockHash
): bool =
signature.signer == identifier.id