mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-02 13:43:06 +00:00
There's a new byteutils in newer versions of stew - also, remove upraises and disable windows testing which requires SSL library install
29 lines
725 B
Nim
29 lines
725 B
Nim
import ../basics
|
|
import ../protocol
|
|
|
|
{.push raises: [].}
|
|
|
|
type
|
|
SignedState* = object
|
|
state*: State
|
|
signatures*: seq[Signature]
|
|
|
|
func hasParticipant*(signed: SignedState, participant: EthAddress): bool =
|
|
signed.state.channel.participants.contains(participant)
|
|
|
|
func isSignedBy*(signed: SignedState, account: EthAddress): bool =
|
|
for signature in signed.signatures:
|
|
if signer =? signature.recover(signed.state):
|
|
if signer == account:
|
|
return true
|
|
false
|
|
|
|
func verifySignatures*(signed: SignedState): bool =
|
|
for signature in signed.signatures:
|
|
if signer =? signature.recover(signed.state):
|
|
if not signed.hasParticipant(signer):
|
|
return false
|
|
else:
|
|
return false
|
|
true
|