Skip to content
GitLab
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
0ce495f8
Commit
0ce495f8
authored
Feb 27, 2018
by
Koen van Ingen
Browse files
Simpler attributeresultlist type
parent
5414cf36
Changes
3
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
0ce495f8
...
...
@@ -19,15 +19,14 @@ const (
metadataLength
=
1
+
3
+
2
+
2
+
16
)
type
AttributeResultList
struct
{
AttributeResults
[]
*
AttributeResult
}
type
AttributeResult
struct
{
AttributeValue
string
`json:"value"`
// Value of the disclosed attribute
AttributeId
AttributeTypeIdentifier
`json:"id"`
AttributeProofStatus
AttributeProofStatus
`json:"status"`
}
type
AttributeResultList
[]
*
AttributeResult
// AttributeProofStatus is the proof status of a single attribute
type
AttributeProofStatus
string
...
...
@@ -482,14 +481,10 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
return
nil
}
func
(
al
*
AttributeResultList
)
Append
(
result
*
AttributeResult
)
{
al
.
AttributeResults
=
append
(
al
.
AttributeResults
,
result
)
}
func
(
al
*
AttributeResultList
)
String
()
string
{
// TODO: pretty print?
str
:=
"Attribute --- Value --- ProofStatus:"
for
_
,
v
:=
range
al
.
AttributeResults
{
for
_
,
v
:=
range
*
al
{
str
=
str
+
"
\n
"
+
v
.
String
()
}
return
str
...
...
irmaclient/manual_session_test.go
View file @
0ce495f8
...
...
@@ -38,7 +38,7 @@ func corruptProofString(proof string) string {
proofBytes
:=
[]
byte
(
proof
)
// 15 because this is somewhere in a bigint in the json string
proofBytes
[
15
]
^=
0x0
2
proofBytes
[
15
]
^=
0x0
1
return
string
(
proofBytes
)
}
return
proof
...
...
@@ -85,7 +85,7 @@ func TestManualSession(t *testing.T) {
t
.
Logf
(
"Invalid proof result: %v Expected: %v"
,
ps
,
irma
.
VALID
)
t
.
Fail
()
}
if
attrStatus
:=
result
.
ToAttributeResultList
()
.
AttributeResults
[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
PRESENT
{
if
attrStatus
:=
result
.
ToAttributeResultList
()[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
PRESENT
{
t
.
Logf
(
"Invalid attribute result value: %v Expected: %v"
,
attrStatus
,
irma
.
PRESENT
)
t
.
Fail
()
}
...
...
@@ -160,12 +160,12 @@ func TestManualSessionInvalidRequest(t *testing.T) {
}
// First attribute result is MISSING, because it is in the request but not disclosed
if
attrStatus
:=
result
.
ToAttributeResultList
()
.
AttributeResults
[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
MISSING
{
if
attrStatus
:=
result
.
ToAttributeResultList
()[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
MISSING
{
t
.
Logf
(
"Invalid attribute result value: %v Expected: %v"
,
attrStatus
,
irma
.
MISSING
)
t
.
Fail
()
}
// Second attribute result is EXTRA, since it is disclosed, but not matching the sigrequest
if
attrStatus
:=
result
.
ToAttributeResultList
()
.
AttributeResults
[
1
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
EXTRA
{
if
attrStatus
:=
result
.
ToAttributeResultList
()[
1
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
EXTRA
{
t
.
Logf
(
"Invalid attribute result value: %v Expected: %v"
,
attrStatus
,
irma
.
EXTRA
)
t
.
Fail
()
}
...
...
@@ -195,7 +195,7 @@ func TestManualSessionInvalidAttributeValue(t *testing.T) {
t
.
Logf
(
"Invalid proof result: %v Expected: %v"
,
ps
,
irma
.
MISSING_ATTRIBUTES
)
t
.
Fail
()
}
if
attrStatus
:=
result
.
ToAttributeResultList
()
.
AttributeResults
[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
INVALID_VALUE
{
if
attrStatus
:=
result
.
ToAttributeResultList
()[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
INVALID_VALUE
{
t
.
Logf
(
"Invalid attribute result value: %v Expected: %v"
,
attrStatus
,
irma
.
INVALID_VALUE
)
t
.
Fail
()
}
...
...
@@ -255,11 +255,11 @@ func TestManualSessionMultiProof(t *testing.T) {
t
.
Logf
(
"Invalid proof result: %v Expected: %v"
,
result
.
ProofStatus
,
irma
.
VALID
)
t
.
Fail
()
}
if
attrStatus
:=
result
.
ToAttributeResultList
()
.
AttributeResults
[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
PRESENT
{
if
attrStatus
:=
result
.
ToAttributeResultList
()[
0
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
PRESENT
{
t
.
Logf
(
"Invalid attribute result value: %v Expected: %v"
,
attrStatus
,
irma
.
PRESENT
)
t
.
Fail
()
}
if
attrStatus
:=
result
.
ToAttributeResultList
()
.
AttributeResults
[
1
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
PRESENT
{
if
attrStatus
:=
result
.
ToAttributeResultList
()[
1
]
.
AttributeProofStatus
;
attrStatus
!=
irma
.
PRESENT
{
t
.
Logf
(
"Invalid attribute result value: %v Expected: %v"
,
attrStatus
,
irma
.
PRESENT
)
t
.
Fail
()
}
...
...
verify.go
View file @
0ce495f8
...
...
@@ -112,7 +112,7 @@ func (disclosed DisclosedCredentialList) IsExpired() bool {
return
false
}
func
(
proofResult
*
ProofResult
)
ToAttributeResultList
()
*
AttributeResultList
{
func
(
proofResult
*
ProofResult
)
ToAttributeResultList
()
AttributeResultList
{
var
resultList
AttributeResultList
for
_
,
v
:=
range
proofResult
.
disjunctions
{
...
...
@@ -122,9 +122,9 @@ func (proofResult *ProofResult) ToAttributeResultList() *AttributeResultList {
AttributeProofStatus
:
v
.
ProofStatus
,
}
resultList
.
A
ppend
(
&
result
)
resultList
=
a
ppend
(
resultList
,
&
result
)
}
return
&
resultList
return
resultList
}
// Returns true if this attrId is present in one of the disjunctions
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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