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.

32 lines
847 B

  1. package blindsecp256k1v0
  2. import (
  3. "math/big"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestFlow(t *testing.T) {
  8. // signer: create new signer key pair
  9. sk := NewPrivateKey()
  10. signerPubK := sk.Public()
  11. // signer: when user requests new R parameter to blind a new msg,
  12. // create new signerR (public) with its secret k
  13. k, signerR := NewRequestParameters()
  14. // user: blinds the msg using signer's R
  15. msg := new(big.Int).SetBytes([]byte("test"))
  16. msgBlinded, userSecretData := Blind(msg, signerPubK, signerR)
  17. // signer: signs the blinded message using its private key & secret k
  18. sBlind := sk.BlindSign(msgBlinded, k)
  19. // user: unblinds the blinded signature
  20. sig := Unblind(sBlind, userSecretData)
  21. // signature can be verified with signer PublicKey (Q)
  22. verified := Verify(msg, sig, signerPubK)
  23. assert.True(t, verified)
  24. }