29 lines
667 B
Nim
Raw Normal View History

import std/random
import std/sequtils
import std/strutils
2024-11-21 15:12:03 +01:00
import ./hashing
type
2024-11-27 11:48:50 +01:00
MockIdentity* = object
id: string
2024-11-27 11:48:50 +01:00
MockIdentifier* = object
id: string
2024-11-27 11:48:50 +01:00
MockSignature* = object
signer: string
2024-11-27 11:48:50 +01:00
proc init*(_: type MockIdentity): MockIdentity =
MockIdentity(id: newSeqWith(32, rand(byte)).mapIt(it.toHex(2)).join())
2024-11-27 11:48:50 +01:00
func identifier*(identity: MockIdentity): MockIdentifier =
MockIdentifier(id: identity.id)
2024-11-27 11:48:50 +01:00
func sign*(identity: MockIdentity; hash: MockHash): MockSignature =
MockSignature(signer: identity.id)
func verify*(
signature: MockSignature,
identifier: MockIdentifier,
hash: MockHash
): bool =
signature.signer == identifier.id