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
74ad790d
Commit
74ad790d
authored
Apr 23, 2018
by
Koen van Ingen
Browse files
Replace bigint with actual string in DisclosedCredentialList
parent
56f74b37
Changes
2
Hide whitespace changes
Inline
Side-by-side
irmago_test.go
View file @
74ad790d
...
...
@@ -291,7 +291,7 @@ func TestVerifyValidSig(t *testing.T) {
proofStatus
,
disclosed
:=
VerifySigWithoutRequest
(
conf
,
irmaSignedMessage
)
require
.
Equal
(
t
,
proofStatus
,
VALID
)
require
.
Len
(
t
,
disclosed
,
1
)
require
.
Equal
(
t
,
disclosed
[
0
]
.
Get
Attribute
Value
(
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
)
,
"456"
)
require
.
Equal
(
t
,
*
disclosed
[
0
]
.
Attribute
s
[
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
]
,
"456"
)
}
func
TestVerifyInValidSig
(
t
*
testing
.
T
)
{
...
...
verify.go
View file @
74ad790d
...
...
@@ -34,7 +34,7 @@ type SignatureProofResult struct {
// DisclosedCredential contains raw disclosed credentials, without any extra parsing information
type
DisclosedCredential
struct
{
metadataAttribute
*
MetadataAttribute
Attributes
map
[
AttributeTypeIdentifier
]
*
big
.
Int
Attributes
map
[
AttributeTypeIdentifier
]
*
string
`json:"attributes"`
}
type
DisclosedCredentialList
[]
*
DisclosedCredential
...
...
@@ -49,10 +49,10 @@ func (disclosed DisclosedCredentialList) isAttributeSatisfied(attributeId Attrib
}
for
_
,
cred
:=
range
disclosed
{
disclosedAttributeValue
:=
cred
.
Get
Attribute
Value
(
attributeId
)
disclosedAttributeValue
:=
cred
.
Attribute
s
[
attributeId
]
// Continue to next credential if requested attribute isn't disclosed in this credential
if
disclosedAttributeValue
==
""
{
if
disclosedAttributeValue
==
nil
{
continue
}
...
...
@@ -60,9 +60,9 @@ func (disclosed DisclosedCredentialList) isAttributeSatisfied(attributeId Attrib
// Attribute is satisfied if:
// - Attribute is disclosed (i.e. not nil)
// - Value is empty OR value equal to disclosedValue
ar
.
AttributeValue
=
disclosedAttributeValue
ar
.
AttributeValue
=
*
disclosedAttributeValue
if
requestedValue
==
nil
||
disclosedAttributeValue
==
*
requestedValue
{
if
requestedValue
==
nil
||
*
disclosedAttributeValue
==
*
requestedValue
{
ar
.
AttributeProofStatus
=
PRESENT
return
true
,
&
ar
}
else
{
...
...
@@ -142,21 +142,20 @@ func (proofResult *ProofResult) ContainsAttribute(attrId AttributeTypeIdentifier
}
// Get string value of disclosed attribute, or nil if request attribute isn't disclosed in this credential
func
(
cred
*
DisclosedCredential
)
GetAttributeValue
(
id
AttributeTypeIdentifier
)
string
{
attr
:=
cred
.
Attributes
[
id
]
if
attr
!=
nil
{
return
string
(
attr
.
Bytes
())
}
return
""
}
//func (cred *DisclosedCredential) GetAttributeValue(id AttributeTypeIdentifier) string {
// attr := cred.Attributes[id]
// if attr != nil {
// return string(attr.Bytes())
// }
// return ""
//}
func
(
cred
*
DisclosedCredential
)
IsExpired
()
bool
{
return
cred
.
metadataAttribute
.
Expiry
()
.
Before
(
time
.
Now
())
}
func
NewDisclosedCredentialFromADisclosed
(
aDisclosed
map
[
int
]
*
big
.
Int
,
configuration
*
Configuration
)
*
DisclosedCredential
{
attributes
:=
make
(
map
[
AttributeTypeIdentifier
]
*
big
.
Int
)
attributes
:=
make
(
map
[
AttributeTypeIdentifier
]
*
string
)
metadata
:=
MetadataFromInt
(
aDisclosed
[
1
],
configuration
)
// index 1 is metadata attribute
cred
:=
metadata
.
CredentialType
()
...
...
@@ -167,7 +166,8 @@ func NewDisclosedCredentialFromADisclosed(aDisclosed map[int]*big.Int, configura
}
description
:=
cred
.
Attributes
[
k
-
2
]
attributes
[
description
.
GetAttributeTypeIdentifier
(
cred
.
Identifier
())]
=
v
attributeValue
:=
string
(
v
.
Bytes
())
attributes
[
description
.
GetAttributeTypeIdentifier
(
cred
.
Identifier
())]
=
&
attributeValue
}
return
&
DisclosedCredential
{
...
...
@@ -225,7 +225,7 @@ func addExtraAttributes(disclosed DisclosedCredentialList, proofResult *ProofRes
}
dummyDisj
:=
DisclosedAttributeDisjunction
{
DisclosedValue
:
cred
.
Get
Attribute
Value
(
attrId
)
,
DisclosedValue
:
*
cred
.
Attribute
s
[
attrId
]
,
DisclosedId
:
attrId
,
ProofStatus
:
EXTRA
,
}
...
...
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