github.com/turingchain2020/turingchain@v1.1.21/wallet/bipwallet/btcutilecc/blind.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package btcutil 6 7 import ( 8 "crypto/ecdsa" 9 "fmt" 10 "math/big" 11 ) 12 13 // BlindSignature Based on algorithm described in An Efficient Blind Signature Scheme 14 // Based on the Elliptic Curve Discrete Logarithm Problem by 15 // Nikooghadam and Zakerolhosseini 16 type BlindSignature struct { 17 M, S *big.Int // called m and s in the paper 18 F *ecdsa.PublicKey 19 } 20 21 // BlindVerify 不清楚干嘛的 22 func BlindVerify(Q *ecdsa.PublicKey, sig *BlindSignature) bool { 23 crv := Secp256k1().Params() 24 25 // onlooker verifies signature (§4.5) 26 sG := ScalarBaseMult(sig.S) 27 rm := new(big.Int).Mul(new(big.Int).Mod(sig.F.X, crv.N), sig.M) 28 rm.Mod(rm, crv.N) 29 rmQ := ScalarMult(rm, Q) 30 rmQplusF := Add(rmQ, sig.F) 31 32 fmt.Println("") 33 fmt.Printf("sG = %x\n", sG.X) 34 fmt.Printf("rmQ + F = %x\n", rmQplusF.X) 35 return KeysEqual(sG, rmQplusF) 36 }