arnaucube
arnaucube/go-blindsecp256k1Public Self-hosted repository
go-blindsecp256k1/v0/blindsecp256k1v0_test.go
v0/blindsecp256k1v0_test.goRaw
 1package blindsecp256k1v0
 2
 3import (
 4	"math/big"
 5	"testing"
 6
 7	"github.com/stretchr/testify/assert"
 8)
 9
10func TestFlow(t *testing.T) {
11	// message to be signed
12	msg := new(big.Int).SetBytes([]byte("test"))
13
14	// create new signer
15	signerPrivateData := NewSigner()
16	signerPublicData := signerPrivateData.PublicData()
17
18	// user blinds the msg
19	msgBlinded, user := Blind(msg, signerPublicData)
20
21	// signer signs the blinded message
22	sBlind := signerPrivateData.BlindSign(msgBlinded)
23
24	// user unblinds the blinded signature
25	sig := Unblind(sBlind, msg, user)
26
27	// signature can be verified with signer PublicKey (Q)
28	verified := Verify(msg, sig, signerPublicData.Q)
29	assert.True(t, verified)
30}