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
d8b2bd7b
Commit
d8b2bd7b
authored
Oct 03, 2019
by
Sietse Ringers
Browse files
refactor: renaming nonrevocation methods
parent
ff930a82
Changes
4
Show whitespace changes
Inline
Side-by-side
internal/sessiontest/requestor_test.go
View file @
d8b2bd7b
...
...
@@ -379,7 +379,7 @@ func TestRevocation(t *testing.T) {
req
:=
revocationRequest
()
require
.
NoError
(
t
,
client
.
Configuration
.
RevocationStorage
.
SetRecords
(
req
.
Base
()))
require
.
NoError
(
t
,
client
.
PrepareNonrevocation
(
req
))
require
.
NoError
(
t
,
client
.
NonrevPreprare
(
req
))
// revoke cred0
require
.
NoError
(
t
,
revocationServer
.
Revoke
(
cred
,
"cred0"
))
...
...
irmaclient/client.go
View file @
d8b2bd7b
...
...
@@ -57,6 +57,9 @@ type Client struct {
Configuration
*
irma
.
Configuration
irmaConfigurationPath
string
handler
ClientHandler
jobsCancel
chan
struct
{}
jobChan
chan
func
()
}
// SentryDSN should be set in the init() function
...
...
@@ -188,26 +191,19 @@ func New(
return
nil
,
errors
.
New
(
"Too many keyshare servers"
)
}
reportErr
:=
func
(
err
error
)
{
irma
.
Logger
.
Error
(
err
)
raven
.
CaptureError
(
err
,
nil
)
return
}
defer
func
()
{
var
cred
*
credential
var
err
error
client
.
jobChan
=
make
(
chan
func
(),
100
)
for
credid
,
attrsets
:=
range
client
.
attributes
{
for
i
:=
range
attrsets
{
if
cred
,
err
=
client
.
credential
(
credid
,
i
);
err
!=
nil
{
reportErr
(
err
)
credid
:=
credid
// make copy of same name to capture the value for closure below
i
:=
i
// same, see https://golang.org/doc/faq#closures_and_goroutines
client
.
jobChan
<-
func
()
{
if
err
:=
client
.
nonrevCredPrepareCache
(
credid
,
i
);
err
!=
nil
{
client
.
reportError
(
err
)
}
if
err
=
cred
.
PrepareNonrevCache
();
err
!=
nil
{
reportErr
(
err
)
}
}
}
}
()
go
client
.
startJobs
()
return
client
,
schemeMgrErr
}
...
...
@@ -216,6 +212,43 @@ func (client *Client) Close() error {
return
client
.
storage
.
Close
()
}
func
(
client
*
Client
)
nonrevCredPrepareCache
(
credid
irma
.
CredentialTypeIdentifier
,
index
int
)
error
{
cred
,
err
:=
client
.
credential
(
credid
,
index
)
if
err
!=
nil
{
return
err
}
return
cred
.
NonrevPrepareCache
()
}
func
(
client
*
Client
)
reportError
(
err
error
)
{
irma
.
Logger
.
Error
(
err
)
raven
.
CaptureError
(
err
,
nil
)
}
func
(
client
*
Client
)
startJobs
()
{
if
client
.
jobsCancel
!=
nil
{
// already running
return
}
client
.
jobsCancel
=
make
(
chan
struct
{})
for
{
select
{
case
<-
client
.
jobsCancel
:
client
.
jobsCancel
=
nil
return
case
job
:=
<-
client
.
jobChan
:
job
()
}
}
}
func
(
client
*
Client
)
stopJobs
()
{
if
client
.
jobsCancel
==
nil
{
return
}
close
(
client
.
jobsCancel
)
}
// CredentialInfoList returns a list of information of all contained credentials.
func
(
client
*
Client
)
CredentialInfoList
()
irma
.
CredentialInfoList
{
list
:=
irma
.
CredentialInfoList
([]
*
irma
.
CredentialInfo
{})
...
...
@@ -721,10 +754,10 @@ func (client *Client) groupCredentials(choice *irma.DisclosureChoice) (
return
todisclose
,
attributeIndices
,
nil
}
// Prepare
Nonrevocation
updates the revocation state for each credential in the request
//
Nonrev
Prepare updates the revocation state for each credential in the request
// requiring a nonrevocation proof, using the updates included in the request, or the remote
// revocation server if those do not suffice.
func
(
client
*
Client
)
PrepareNonrevocation
(
request
irma
.
SessionRequest
)
error
{
func
(
client
*
Client
)
NonrevPreprare
(
request
irma
.
SessionRequest
)
error
{
var
err
error
var
cred
*
credential
var
updated
bool
...
...
@@ -737,7 +770,7 @@ func (client *Client) PrepareNonrevocation(request irma.SessionRequest) error {
if
cred
,
err
=
client
.
credential
(
id
,
i
);
err
!=
nil
{
return
err
}
if
updated
,
err
=
cred
.
prepareNonrevocation
(
client
.
Configuration
,
request
);
err
!=
nil
{
if
updated
,
err
=
cred
.
NonrevPrepare
(
client
.
Configuration
,
request
);
err
!=
nil
{
return
err
}
if
updated
{
...
...
@@ -750,24 +783,22 @@ func (client *Client) PrepareNonrevocation(request irma.SessionRequest) error {
return
nil
}
func
(
client
*
Client
)
repopulateNonrevCaches
(
request
irma
.
SessionRequest
)
error
{
var
err
error
var
cred
*
credential
func
(
client
*
Client
)
nonrevRepopulateCaches
(
request
irma
.
SessionRequest
)
{
for
id
:=
range
request
.
Disclosure
()
.
Identifiers
()
.
CredentialTypes
{
typ
:=
client
.
Configuration
.
CredentialTypes
[
id
]
if
!
typ
.
SupportsRevocation
()
{
continue
}
for
i
:=
0
;
i
<
len
(
client
.
attrs
(
id
));
i
++
{
if
cred
,
err
=
client
.
credential
(
id
,
i
);
err
!=
nil
{
return
err
id
:=
id
i
:=
i
client
.
jobChan
<-
func
()
{
if
err
:=
client
.
nonrevCredPrepareCache
(
id
,
i
);
err
!=
nil
{
client
.
reportError
(
err
)
}
if
err
=
cred
.
PrepareNonrevCache
();
err
!=
nil
{
return
err
}
}
}
return
nil
}
// ProofBuilders constructs a list of proof builders for the specified attribute choice.
...
...
irmaclient/credential.go
View file @
d8b2bd7b
...
...
@@ -41,18 +41,18 @@ func (cred *credential) AttributeList() *irma.AttributeList {
return
cred
.
attrs
}
//
prepareNonrevocation
attempts to update the credential's nonrevocation witness from
//
NonrevPrepare
attempts to update the credential's nonrevocation witness from
// 1) the session request, and then 2) the revocation server if our witness is too far out of date.
// Returns whether or not the credential's nonrevocation state was updated. If so the caller should
// persist the updated credential to storage.
func
(
cred
*
credential
)
prepareNonrevocation
(
conf
*
irma
.
Configuration
,
request
irma
.
SessionRequest
)
(
bool
,
error
)
{
func
(
cred
*
credential
)
NonrevPrepare
(
conf
*
irma
.
Configuration
,
request
irma
.
SessionRequest
)
(
bool
,
error
)
{
credtype
:=
cred
.
CredentialType
()
.
Identifier
()
if
!
request
.
Base
()
.
RequestsRevocation
(
credtype
)
{
return
false
,
nil
}
revupdates
:=
request
.
Base
()
.
RevocationUpdates
[
credtype
]
updated
,
err
:=
cred
.
updateNonrevWitnes
s
(
revupdates
,
conf
.
RevocationStorage
)
updated
,
err
:=
cred
.
NonrevApplyUpdate
s
(
revupdates
,
conf
.
RevocationStorage
)
if
err
!=
nil
{
return
updated
,
err
}
...
...
@@ -68,12 +68,12 @@ func (cred *credential) prepareNonrevocation(conf *irma.Configuration, request i
if
err
!=
nil
{
return
updated
,
err
}
return
cred
.
updateNonrevWitnes
s
(
revupdates
,
conf
.
RevocationStorage
)
return
cred
.
NonrevApplyUpdate
s
(
revupdates
,
conf
.
RevocationStorage
)
}
//
updateNonrevWitnes
s updates the credential's nonrevocation witness using the specified messages,
//
NonrevApplyUpdate
s updates the credential's nonrevocation witness using the specified messages,
// if they all verify and if their indices are ahead and adjacent to that of our witness.
func
(
cred
*
credential
)
updateNonrevWitnes
s
(
messages
[]
*
irma
.
RevocationRecord
,
rs
*
irma
.
RevocationStorage
)
(
bool
,
error
)
{
func
(
cred
*
credential
)
NonrevApplyUpdate
s
(
messages
[]
*
irma
.
RevocationRecord
,
rs
*
irma
.
RevocationStorage
)
(
bool
,
error
)
{
var
err
error
var
pk
*
revocation
.
PublicKey
oldindex
:=
cred
.
NonRevocationWitness
.
Index
...
...
@@ -86,5 +86,5 @@ func (cred *credential) updateNonrevWitness(messages []*irma.RevocationRecord, r
}
}
return
cred
.
NonRevocationWitness
.
Index
!=
oldindex
,
cred
.
Prepare
Nonrev
Cache
()
return
cred
.
NonRevocationWitness
.
Index
!=
oldindex
,
cred
.
Nonrev
PrepareCache
()
}
irmaclient/session.go
View file @
d8b2bd7b
...
...
@@ -9,7 +9,7 @@ import (
"strings"
"github.com/bwesterb/go-atum"
"github.com/getsentry/raven-go"
raven
"github.com/getsentry/raven-go"
"github.com/go-errors/errors"
"github.com/privacybydesign/gabi"
"github.com/privacybydesign/gabi/big"
...
...
@@ -77,7 +77,7 @@ type session struct {
client
*
Client
request
irma
.
SessionRequest
done
bool
prepRevocation
chan
error
prepRevocation
chan
error
// used when nonrevocation preprocessing is done
// State for issuance sessions
issuerProofNonce
*
big
.
Int
...
...
@@ -138,6 +138,8 @@ func (client *Client) NewSession(sessionrequest string, handler Handler) Session
// newManualSession starts a manual session, given a signature request in JSON and a handler to pass messages to
func
(
client
*
Client
)
newManualSession
(
request
irma
.
SessionRequest
,
handler
Handler
,
action
irma
.
Action
)
SessionDismisser
{
client
.
stopJobs
()
session
:=
&
session
{
Action
:
action
,
Handler
:
handler
,
...
...
@@ -181,6 +183,8 @@ func (client *Client) newQrSession(qr *irma.Qr, handler Handler) SessionDismisse
return
client
.
newQrSession
(
newqr
,
handler
)
}
client
.
stopJobs
()
u
,
_
:=
url
.
ParseRequestURI
(
qr
.
URL
)
// Qr validator already checked this for errors
session
:=
&
session
{
ServerURL
:
qr
.
URL
,
...
...
@@ -309,7 +313,7 @@ func (session *session) processSessionInfo() {
// Prepare and update all revocation state asynchroniously while the user makes her choices
go
func
()
{
session
.
prepRevocation
<-
session
.
client
.
PrepareNonrevocation
(
session
.
request
)
session
.
prepRevocation
<-
session
.
client
.
NonrevPreprare
(
session
.
request
)
}()
// Ask for permission to execute the session
...
...
@@ -468,14 +472,9 @@ func (session *session) sendResponse(message interface{}) {
session
.
client
.
handler
.
UpdateAttributes
()
}
session
.
done
=
true
session
.
client
.
nonrevRepopulateCaches
(
session
.
request
)
session
.
client
.
startJobs
()
session
.
Handler
.
Success
(
string
(
messageJson
))
go
func
()
{
if
err
:=
session
.
client
.
repopulateNonrevCaches
(
session
.
request
);
err
!=
nil
{
raven
.
CaptureError
(
err
,
nil
)
irma
.
Logger
.
Error
(
err
)
}
}()
}
// managerSession performs a "session" in which a new scheme manager is added (asking for permission first).
...
...
@@ -652,11 +651,14 @@ func panicToError(e interface{}) *irma.SessionError {
}
// Idempotently send DELETE to remote server, returning whether or not we did something
// TODO this function does more, rename
func
(
session
*
session
)
delete
()
bool
{
if
!
session
.
done
{
if
session
.
IsInteractive
()
{
session
.
transport
.
Delete
()
}
session
.
client
.
nonrevRepopulateCaches
(
session
.
request
)
session
.
client
.
startJobs
()
session
.
done
=
true
return
true
}
...
...
Write
Preview
Supports
Markdown
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