|
@ -7,17 +7,24 @@ Blind signature over [secp256k1](https://en.bitcoin.it/wiki/Secp256k1), based on |
|
|
## Usage |
|
|
## Usage |
|
|
|
|
|
|
|
|
```go |
|
|
```go |
|
|
|
|
|
import ( |
|
|
|
|
|
[...] |
|
|
|
|
|
"github.com/arnaucube/go-blindsecp256k1" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
[...] |
|
|
|
|
|
|
|
|
// signer: create new signer key pair |
|
|
// signer: create new signer key pair |
|
|
sk := NewPrivateKey() |
|
|
|
|
|
|
|
|
sk := blindsecp256k1.NewPrivateKey() |
|
|
signerPubK := sk.Public() |
|
|
signerPubK := sk.Public() |
|
|
|
|
|
|
|
|
// signer: when user requests new R parameter to blind a new msg, |
|
|
// signer: when user requests new R parameter to blind a new msg, |
|
|
// create new signerR (public) with its secret k |
|
|
// create new signerR (public) with its secret k |
|
|
k, signerR := NewRequestParameters() |
|
|
|
|
|
|
|
|
k, signerR := blindsecp256k1.NewRequestParameters() |
|
|
|
|
|
|
|
|
// user: blinds the msg using signer's R |
|
|
// user: blinds the msg using signer's R |
|
|
msg := new(big.Int).SetBytes([]byte("test")) |
|
|
msg := new(big.Int).SetBytes([]byte("test")) |
|
|
msgBlinded, userSecretData, err := Blind(msg, signerR) |
|
|
|
|
|
|
|
|
msgBlinded, userSecretData, err := blindsecp256k1.Blind(msg, signerR) |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
|
|
|
|
|
|
// signer: signs the blinded message using its private key & secret k |
|
|
// signer: signs the blinded message using its private key & secret k |
|
@ -25,10 +32,10 @@ sBlind, err := sk.BlindSign(msgBlinded, k) |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
|
|
|
|
|
|
// user: unblinds the blinded signature |
|
|
// user: unblinds the blinded signature |
|
|
sig := Unblind(sBlind, userSecretData) |
|
|
|
|
|
|
|
|
sig := blindsecp256k1.Unblind(sBlind, userSecretData) |
|
|
|
|
|
|
|
|
// signature can be verified with signer PublicKey |
|
|
// signature can be verified with signer PublicKey |
|
|
verified := Verify(msg, sig, signerPubK) |
|
|
|
|
|
|
|
|
verified := blindsecp256k1.Verify(msg, sig, signerPubK) |
|
|
assert.True(t, verified) |
|
|
assert.True(t, verified) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|