You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
683 B

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