From d42366926507f0442e59bdfca13d99c212a27683 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 8 Jan 2024 05:01:55 +0530 Subject: [PATCH] feat: add doc comments --- gomcaptcha.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gomcaptcha.go b/gomcaptcha.go index ba75f03..56acd9b 100644 --- a/gomcaptcha.go +++ b/gomcaptcha.go @@ -1,3 +1,5 @@ +// Go library that implements mCaptcha PoW. +// It is a wrapper over [mcaptcha_pow_sha256](https://crates.io/crates/mcaptcha_pow_sha256). package gomcaptcha /* @@ -7,11 +9,15 @@ package gomcaptcha */ import "C" +// Struct representing Proof-of-Work type ProofOfWork struct { Nonce uint64 Result string } +// Compute Proof-of-Work over the challenge parameters presented by mCaptcha. +// All input data will be supplied by the mCaptcha instance. +// Outputs Proof-of-Work. func ProveWork(salt string, phrase string, difficulty uint) ProofOfWork { res := C.prove_work(C.CString(salt), C.CString(phrase), C.uint(difficulty)) @@ -23,6 +29,8 @@ func ProveWork(salt string, phrase string, difficulty uint) ProofOfWork { } +// / Check if Proof-of-Work is of sufficient difficulty. Use same salt and difficulty +// values used to compute PoW. func (v ProofOfWork) IsSufficientDifficulty(salt string, difficulty uint) bool { res := C.is_sufficient_difficulty( C.ulong(v.Nonce), @@ -33,6 +41,8 @@ func (v ProofOfWork) IsSufficientDifficulty(salt string, difficulty uint) bool { } +// / Check if Proof-of-Work is valid. Use same challenge phrase and salt values +// used to compute PoW. func (v ProofOfWork) IsValidProof(phrase string, salt string) bool { res := C.is_valid_proof( C.ulong(v.Nonce),