diff options
Diffstat (limited to 'validate.go')
-rw-r--r-- | validate.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/validate.go b/validate.go new file mode 100644 index 0000000..469c978 --- /dev/null +++ b/validate.go @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: BSD-2-Clause +// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> + +package main + +import ( + "crypto/sha256" +) + +// validateNonce checks if the nonce for the proof of work challenge is valid +// for the given identifier. +func validateNonce(identifier, nonce []byte) bool { + h := sha256.New() + h.Write(identifier) + h.Write(nonce) + ck := h.Sum(nil) + return validateBitZeros(ck, global.NeedBits) +} |