Skip to content

Commit

Permalink
Reuse round trip test function
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-wood committed Dec 20, 2021
1 parent 8a6459e commit d98dcad
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions blindsign/blindrsa/blindrsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,6 @@ func loadPrivateKey(t *testing.T) *rsa.PrivateKey {
return privateKey
}

func TestSignVerify(t *testing.T) {
message := []byte("hello world")
key := loadPrivateKey(t)

verifier := NewRSAVerifier(&key.PublicKey, sha512.New())
signer := NewRSASigner(key)

blindedMsg, state, err := verifier.Blind(rand.Reader, message)
if err != nil {
t.Fatal(err)
}

blindedSig, err := signer.BlindSign(blindedMsg)
if err != nil {
t.Fatal(err)
}

sig, err := state.Finalize(blindedSig)
if err != nil {
t.Fatal(err)
}
if sig == nil {
t.Fatal("nil signature output")
}
}

func runSignatureProtocol(signer RSASigner, verifier RSAVerifier, message []byte, random io.Reader) ([]byte, error) {
blindedMsg, state, err := verifier.Blind(random, message)
if err != nil {
Expand All @@ -129,6 +103,22 @@ func runSignatureProtocol(signer RSASigner, verifier RSAVerifier, message []byte
return sig, nil
}

func TestRoundTrip(t *testing.T) {
message := []byte("hello world")
key := loadPrivateKey(t)

verifier := NewRSAVerifier(&key.PublicKey, sha512.New())
signer := NewRSASigner(key)

sig, err := runSignatureProtocol(signer, verifier, message, rand.Reader)
if err != nil {
t.Fatal(err)
}
if sig == nil {
t.Fatal("nil signature output")
}
}

func TestDeterministicSignFail(t *testing.T) {
message := []byte("hello world")
key := loadPrivateKey(t)
Expand Down

0 comments on commit d98dcad

Please sign in to comment.