From cecc2cfffe2ad0f97f629abdd5c5d85bdf838990 Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Sat, 3 Dec 2022 19:54:11 +0800 Subject: [PATCH] v1.0.1 --- zkp.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zkp.go b/zkp.go index a967709..042d682 100644 --- a/zkp.go +++ b/zkp.go @@ -74,7 +74,7 @@ func DLogProve(sk *big.Int) (proof *DLogProof, err error) { // return proof = &DLogProof{ - RandomPoint: fmt.Sprintf("%x,%x", pkr.X, pkr.Y), + RandomPoint: fmt.Sprintf("%064x,%064x", pkr.X, pkr.Y), ChallengeResponse: (*big_Int)(cr), } return proof, nil @@ -91,12 +91,12 @@ func DLogVerify(pkstr string, proof *DLogProof) bool { // Step 0. get pk & pkr var pk, err1 = HexStringToS256Point(pkstr) if err1 != nil { - //errors.New("input pk is invalid") + log.Infof("input pk is invalid: %s, pk=[%s]", err1, pkstr) return false } var pkr, err2 = HexStringToS256Point(proof.RandomPoint) if err2 != nil { - //errors.New("input pkr is invalid") + log.Infof("input pkr is invalid: %s, pkr=[%s]", err2, proof.RandomPoint) return false } @@ -131,11 +131,11 @@ func DLogVerify(pkstr string, proof *DLogProof) bool { func HexStringToS256Point(pstr string) (*ecdsa.PublicKey, error) { var pk = ecdsa.PublicKey{Curve: crypto.S256()} if x2y2 := strings.Split(pstr, ","); len(x2y2) != 2 { - return nil, errors.New("input pk is invalid") + return nil, errors.New("input point is invalid") } else if x, err := hex.DecodeString(x2y2[0]); err != nil { - return nil, errors.New("input pk.x is invalid") + return nil, fmt.Errorf("input point.x is invalid: [%s]", err) } else if y, err := hex.DecodeString(x2y2[1]); err != nil { - return nil, errors.New("input pk.y is invalid") + return nil, fmt.Errorf("input point.y is invalid: [%s]", err) } else { pk.X = new(big.Int).SetBytes(x) pk.Y = new(big.Int).SetBytes(y)