Commit d02771dd authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Include new message also in logs

parent d5720003
......@@ -4,7 +4,6 @@ import (
"encoding/json"
"testing"
"github.com/mhe/gabi"
"github.com/pkg/errors"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/irmaclient"
......@@ -130,9 +129,9 @@ func (th TestHandler) RequestPin(remainingAttempts int, callback irmaclient.PinH
}
type SessionResult struct {
Err error
SignatureResult *irma.SignedMessage
VerificationResult gabi.ProofList
Err error
SignatureResult *irma.SignedMessage
DisclosureResult *irma.Disclosure
}
// ManualTestHandler embeds a TestHandler to inherit its methods.
......@@ -159,12 +158,8 @@ func (th *ManualTestHandler) Success(result string) {
retval.SignatureResult = &irma.SignedMessage{}
err = json.Unmarshal([]byte(result), retval.SignatureResult)
case irma.ActionDisclosing:
proofs := []*gabi.ProofD{}
err = json.Unmarshal([]byte(result), &proofs)
retval.VerificationResult = make(gabi.ProofList, len(proofs))
for i, proof := range proofs {
retval.VerificationResult[i] = proof
}
retval.DisclosureResult = &irma.Disclosure{}
err = json.Unmarshal([]byte(result), retval.DisclosureResult)
}
if err != nil {
th.Failure(&irma.SessionError{
......
......@@ -41,7 +41,7 @@ func manualSessionHelper(t *testing.T, client *irmaclient.Client, h *ManualTestH
verifyasRequest := &irma.DisclosureRequest{}
err := json.Unmarshal([]byte(verifyAs), verifyasRequest)
require.NoError(t, err)
list, status, err := irma.ProofList(result.VerificationResult).Verify(client.Configuration, verifyasRequest)
list, status, err := result.DisclosureResult.Verify(client.Configuration, verifyasRequest)
require.NoError(t, err)
return list, status
case irma.ActionSigning:
......
......@@ -6,7 +6,6 @@ import (
"github.com/bwesterb/go-atum"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
)
......@@ -25,8 +24,8 @@ type LogEntry struct {
SignedMessage []byte `json:",omitempty"` // In case of signature sessions
Timestamp *atum.Timestamp `json:",omitempty"` // In case of signature sessions
IssueCommitment *gabi.IssueCommitmentMessage `json:",omitempty"`
ProofList gabi.ProofList `json:",omitempty"`
IssueCommitment *irma.IssueCommitmentMessage `json:",omitempty"`
Disclosure *irma.Disclosure `json:",omitempty"`
}
const actionRemoval = irma.Action("removal")
......@@ -72,14 +71,14 @@ func (entry *LogEntry) GetDisclosedCredentials(conf *irma.Configuration) ([]*irm
if err != nil {
return nil, err
}
var proofs gabi.ProofList
var disclosure *irma.Disclosure
disjunctions := request.ToDisclose()
if entry.Type == irma.ActionIssuing {
proofs = entry.IssueCommitment.Proofs
disclosure = entry.IssueCommitment.Disclosure()
} else {
proofs = entry.ProofList
disclosure = entry.Disclosure
}
_, attrs, err := irma.ProofList(proofs).DisclosedAttributes(conf, disjunctions)
_, attrs, err := disclosure.DisclosedAttributes(conf, disjunctions)
return attrs, err
}
......@@ -106,7 +105,7 @@ func (entry *LogEntry) GetSignedMessage() (abs *irma.SignedMessage, err error) {
}
sigrequest := request.(*irma.SignatureRequest)
return &irma.SignedMessage{
Signature: entry.ProofList,
Signature: entry.Disclosure.Proofs,
Nonce: sigrequest.Nonce,
Context: sigrequest.Context,
Message: string(entry.SignedMessage),
......@@ -137,9 +136,9 @@ func (session *session) createLogEntry(response interface{}) (*LogEntry, error)
fallthrough
case irma.ActionDisclosing:
entry.ProofList = response.(gabi.ProofList)
entry.Disclosure = response.(*irma.Disclosure)
case irma.ActionIssuing:
entry.IssueCommitment = response.(*gabi.IssueCommitmentMessage)
entry.IssueCommitment = response.(*irma.IssueCommitmentMessage)
default:
return nil, errors.New("Invalid log type")
}
......
......@@ -332,7 +332,7 @@ func (session *session) sendResponse(message interface{}) {
return
}
}
log, _ = session.createLogEntry(message.(gabi.ProofList)) // TODO err
log, _ = session.createLogEntry(message) // TODO err
case irma.ActionDisclosing:
messageJson, err = json.Marshal(message)
if err != nil {
......@@ -350,7 +350,7 @@ func (session *session) sendResponse(message interface{}) {
return
}
}
log, _ = session.createLogEntry(message.(gabi.ProofList)) // TODO err
log, _ = session.createLogEntry(message) // TODO err
case irma.ActionIssuing:
response := []*gabi.IssueSignatureMessage{}
if err = session.transport.Post("commitments", &response, message); err != nil {
......
......@@ -80,6 +80,7 @@ var clientUpdates = []func(client *Client) error{
// So read the logs again into a slice of a temp struct that does contain this field.
type oldLogEntry struct {
Response json.RawMessage
ProofList gabi.ProofList
SessionInfo struct {
Nonce *big.Int `json:"nonce"`
Context *big.Int `json:"context"`
......@@ -144,11 +145,12 @@ var clientUpdates = []func(client *Client) error{
if err = json.Unmarshal(oldEntry.Response, &proofs); err != nil {
return
}
entry.Disclosure = &irma.Disclosure{}
for _, proof := range proofs {
entry.ProofList = append(entry.ProofList, proof)
entry.Disclosure.Proofs = append(entry.Disclosure.Proofs, proof)
}
case irma.ActionIssuing:
entry.IssueCommitment = &gabi.IssueCommitmentMessage{}
entry.IssueCommitment = &irma.IssueCommitmentMessage{}
if err = json.Unmarshal(oldEntry.Response, entry.IssueCommitment); err != nil {
return err
}
......
......@@ -120,6 +120,12 @@ func (pl ProofList) Expired(configuration *Configuration, t *time.Time) bool {
// of the disclosed attributes, then the corresponding item in the returned slice has status AttributeProofStatusMissing.
// The first return parameter of this function indicates whether or not all disjunctions (if present) are satisfied.
func (d *Disclosure) DisclosedAttributes(configuration *Configuration, disjunctions AttributeDisjunctionList) (bool, []*DisclosedAttribute, error) {
return ProofList(d.Proofs).DisclosedAttributes(configuration, disjunctions)
// TODO new verification logic that uses d.Indices
}
func (pl ProofList) DisclosedAttributes(configuration *Configuration, disjunctions AttributeDisjunctionList) (bool, []*DisclosedAttribute, error) {
var list []*DisclosedAttribute
list = make([]*DisclosedAttribute, len(disjunctions))
for i := range list {
......@@ -135,7 +141,7 @@ func (d *Disclosure) DisclosedAttributes(configuration *Configuration, disjuncti
// we append these to list just before returning
extraAttrs := map[AttributeTypeIdentifier]*DisclosedAttribute{}
for _, proof := range d.Proofs {
for _, proof := range pl {
proofd, ok := proof.(*gabi.ProofD)
if !ok {
continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment