Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
648ea1eb
Commit
648ea1eb
authored
May 02, 2018
by
Koen van Ingen
Browse files
JSON marshalling of DisclosedAttributeDisjunction
parent
74ad790d
Changes
2
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
648ea1eb
...
...
@@ -451,6 +451,27 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
return
json
.
Marshal
(
temp
)
}
// Since we have a custom MarshalJSON for AttributeDisjunction, we also need one for every struct that extends AttributeDisjunction...
func
(
disclosedAttributeDisjunction
*
DisclosedAttributeDisjunction
)
MarshalJSON
()
([]
byte
,
error
)
{
temp
:=
struct
{
Label
string
`json:"label"`
Attributes
[]
AttributeTypeIdentifier
`json:"attributes"`
DisclosedValue
string
`json:"disclosedValue"`
DisclosedId
AttributeTypeIdentifier
`json:"disclosedId"`
ProofStatus
AttributeProofStatus
`json:"proofStatus"`
}{
Label
:
disclosedAttributeDisjunction
.
Label
,
Attributes
:
disclosedAttributeDisjunction
.
Attributes
,
DisclosedValue
:
disclosedAttributeDisjunction
.
DisclosedValue
,
DisclosedId
:
disclosedAttributeDisjunction
.
DisclosedId
,
ProofStatus
:
disclosedAttributeDisjunction
.
ProofStatus
,
}
return
json
.
Marshal
(
temp
)
}
// UnmarshalJSON unmarshals an attribute disjunction from JSON.
func
(
disjunction
*
AttributeDisjunction
)
UnmarshalJSON
(
bytes
[]
byte
)
error
{
if
disjunction
.
Values
==
nil
{
...
...
verify.go
View file @
648ea1eb
...
...
@@ -22,13 +22,13 @@ const (
// ProofResult is a result of a complete proof, containing all the disclosed attributes and corresponding request
type
ProofResult
struct
{
d
isjunctions
[]
*
DisclosedAttributeDisjunction
D
isjunctions
[]
*
DisclosedAttributeDisjunction
`json:"disjunctions"`
ProofStatus
ProofStatus
}
type
SignatureProofResult
struct
{
*
ProofResult
m
essage
string
M
essage
string
`json:"message"`
}
// DisclosedCredential contains raw disclosed credentials, without any extra parsing information
...
...
@@ -83,11 +83,11 @@ func (disclosed DisclosedCredentialList) isAttributeSatisfied(attributeId Attrib
func
(
disclosed
DisclosedCredentialList
)
createAndCheckSignatureProofResult
(
configuration
*
Configuration
,
sigRequest
*
SignatureRequest
)
*
SignatureProofResult
{
signatureProofResult
:=
SignatureProofResult
{
ProofResult
:
&
ProofResult
{},
m
essage
:
sigRequest
.
Message
,
M
essage
:
sigRequest
.
Message
,
}
for
_
,
content
:=
range
sigRequest
.
Content
{
isSatisfied
,
disjunction
:=
content
.
SatisfyDisclosed
(
disclosed
,
configuration
)
signatureProofResult
.
d
isjunctions
=
append
(
signatureProofResult
.
d
isjunctions
,
disjunction
)
signatureProofResult
.
D
isjunctions
=
append
(
signatureProofResult
.
D
isjunctions
,
disjunction
)
// If satisfied, continue to next one
if
isSatisfied
{
...
...
@@ -99,7 +99,7 @@ func (disclosed DisclosedCredentialList) createAndCheckSignatureProofResult(conf
signatureProofResult
.
ProofStatus
=
MISSING_ATTRIBUTES
}
signatureProofResult
.
d
isjunctions
=
addExtraAttributes
(
disclosed
,
signatureProofResult
.
ProofResult
)
signatureProofResult
.
D
isjunctions
=
addExtraAttributes
(
disclosed
,
signatureProofResult
.
ProofResult
)
return
&
signatureProofResult
}
...
...
@@ -116,7 +116,7 @@ func (disclosed DisclosedCredentialList) IsExpired() bool {
func
(
proofResult
*
ProofResult
)
ToAttributeResultList
()
AttributeResultList
{
var
resultList
AttributeResultList
for
_
,
v
:=
range
proofResult
.
d
isjunctions
{
for
_
,
v
:=
range
proofResult
.
D
isjunctions
{
result
:=
AttributeResult
{
AttributeValue
:
v
.
DisclosedValue
,
AttributeId
:
v
.
DisclosedId
,
...
...
@@ -130,7 +130,7 @@ func (proofResult *ProofResult) ToAttributeResultList() AttributeResultList {
// Returns true if this attrId is present in one of the disjunctions
func
(
proofResult
*
ProofResult
)
ContainsAttribute
(
attrId
AttributeTypeIdentifier
)
bool
{
for
_
,
disj
:=
range
proofResult
.
d
isjunctions
{
for
_
,
disj
:=
range
proofResult
.
D
isjunctions
{
for
_
,
attr
:=
range
disj
.
Attributes
{
if
attr
==
attrId
{
return
true
...
...
@@ -215,8 +215,8 @@ func extractDisclosedCredentials(conf *Configuration, proofList gabi.ProofList)
// Add extra disclosed attributes to an existing and checked ProofResult in 'dummy disjunctions'
func
addExtraAttributes
(
disclosed
DisclosedCredentialList
,
proofResult
*
ProofResult
)
[]
*
DisclosedAttributeDisjunction
{
returnDisjunctions
:=
make
([]
*
DisclosedAttributeDisjunction
,
len
(
proofResult
.
d
isjunctions
))
copy
(
returnDisjunctions
,
proofResult
.
d
isjunctions
)
returnDisjunctions
:=
make
([]
*
DisclosedAttributeDisjunction
,
len
(
proofResult
.
D
isjunctions
))
copy
(
returnDisjunctions
,
proofResult
.
D
isjunctions
)
for
_
,
cred
:=
range
disclosed
{
for
attrId
:=
range
cred
.
Attributes
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment