@@ -20,22 +20,30 @@ func TestKeyBindingStorage(t *testing.T) {
2020 )
2121}
2222
23- func testRetrieveSinglePrivateKeyCanOnlyBeDoneOnce (t * testing.T , storage sdjwtvc.KeyBindingStorage ) {
24- privateKeys := createPrivateKeys (t , 100 )
25- require .NoError (t , storage .StorePrivateKeys (privateKeys ))
26-
27- privJwk , err := jwk .Import (privateKeys [0 ])
23+ func getPubJwk (t * testing.T , priv * ecdsa.PrivateKey ) jwk.Key {
24+ privJwk , err := jwk .Import (priv )
2825 require .NoError (t , err )
2926 pubJwk , err := privJwk .PublicKey ()
3027 require .NoError (t , err )
28+ return pubJwk
29+ }
30+
31+ func testRetrieveSinglePrivateKeyCanOnlyBeDoneOnce (t * testing.T , storage sdjwtvc.KeyBindingStorage ) {
32+ privateKeys := createPrivateKeys (t , 100 )
33+ require .NoError (t , storage .StorePrivateKeys (privateKeys ))
3134
35+ pubJwk := getPubJwk (t , privateKeys [0 ])
3236 privKey , err := storage .GetAndRemovePrivateKey (pubJwk )
3337 require .NoError (t , err )
3438
3539 require .Equal (t , privateKeys [0 ], privKey )
3640
3741 privKey , err = storage .GetAndRemovePrivateKey (pubJwk )
3842 require .Error (t , err )
43+
44+ pubJwk = getPubJwk (t , privateKeys [1 ])
45+ privKey , err = storage .GetAndRemovePrivateKey (pubJwk )
46+ require .NoError (t , err )
3947}
4048
4149func testStoreManyPrivateKeys (t * testing.T , storage sdjwtvc.KeyBindingStorage ) {
0 commit comments