Commit 6980e38e authored by Sietse Ringers's avatar Sietse Ringers
Browse files

refactor: gabi.PublicKeys moved to gabikeys in keyshare server code

parent 4b431fa5
......@@ -5,8 +5,8 @@ import (
"crypto/rsa"
"sync"
"github.com/privacybydesign/gabi"
"github.com/privacybydesign/gabi/big"
"github.com/privacybydesign/gabi/gabikeys"
irma "github.com/privacybydesign/irmago"
)
......@@ -29,7 +29,7 @@ type (
// IRMA issuer keys that are allowed to be used in keyshare
// sessions
trustedKeys map[irma.PublicKeyIdentifier]*gabi.PublicKey
trustedKeys map[irma.PublicKeyIdentifier]*gabikeys.PublicKey
}
)
......@@ -37,7 +37,7 @@ func NewKeyshareCore() *Core {
return &Core{
decryptionKeys: map[uint32]AesKey{},
commitmentData: map[uint64]*big.Int{},
trustedKeys: map[irma.PublicKeyIdentifier]*gabi.PublicKey{},
trustedKeys: map[irma.PublicKeyIdentifier]*gabikeys.PublicKey{},
}
}
......@@ -69,6 +69,6 @@ func (c *Core) SetSignKey(key *rsa.PrivateKey, id int) {
}
// Add public key as trusted by keyshareCore. Calling this on incorrectly generated key material WILL compromise keyshare secrets!
func (c *Core) DangerousAddTrustedPublicKey(keyID irma.PublicKeyIdentifier, key *gabi.PublicKey) {
func (c *Core) DangerousAddTrustedPublicKey(keyID irma.PublicKeyIdentifier, key *gabikeys.PublicKey) {
c.trustedKeys[keyID] = key
}
......@@ -11,6 +11,7 @@ import (
"github.com/dgrijalva/jwt-go"
"github.com/privacybydesign/gabi"
"github.com/privacybydesign/gabi/big"
"github.com/privacybydesign/gabi/gabikeys"
irma "github.com/privacybydesign/irmago"
)
......@@ -202,7 +203,7 @@ func (c *Core) verifyAccess(ep EncryptedKeysharePacket, jwtToken string) (unencr
// Get keyshare commitment usign given idemix public key(s)
func (c *Core) GenerateCommitments(ep EncryptedKeysharePacket, accessToken string, keyIDs []irma.PublicKeyIdentifier) ([]*gabi.ProofPCommitment, uint64, error) {
// Validate input request and build key list
var keyList []*gabi.PublicKey
var keyList []*gabikeys.PublicKey
for _, keyID := range keyIDs {
key, ok := c.trustedKeys[keyID]
if !ok {
......@@ -241,7 +242,7 @@ func (c *Core) GenerateCommitments(ep EncryptedKeysharePacket, accessToken strin
// Generate response for zero-knowledge proof of keyshare secret, for a given previous commit and challenge
func (c *Core) GenerateResponse(ep EncryptedKeysharePacket, accessToken string, commitID uint64, challenge *big.Int, keyID irma.PublicKeyIdentifier) (string, error) {
// Validate request
if uint(challenge.BitLen()) > gabi.DefaultSystemParameters[1024].Lh || challenge.Cmp(big.NewInt(0)) < 0 {
if uint(challenge.BitLen()) > gabikeys.DefaultSystemParameters[1024].Lh || challenge.Cmp(big.NewInt(0)) < 0 {
return "", ErrInvalidChallenge
}
key, ok := c.trustedKeys[keyID]
......
......@@ -10,6 +10,7 @@ import (
"time"
"github.com/dgrijalva/jwt-go"
"github.com/privacybydesign/gabi/gabikeys"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
......@@ -487,11 +488,11 @@ ZAS54R1mcyP67iBPxixiKeFqajUS+C4GFBrNSXbQTWf+jTyWkgfNSg==
-----END RSA PRIVATE KEY-----`
var jwtTestKey *rsa.PrivateKey
var testPubK1 *gabi.PublicKey
var testPubK1 *gabikeys.PublicKey
func setupParameters() error {
var err error
testPubK1, err = gabi.NewPublicKeyFromXML(xmlPubKey1)
testPubK1, err = gabikeys.NewPublicKeyFromXML(xmlPubKey1)
if err != nil {
return err
}
......
Supports Markdown
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