Skip to content

Commit a6ab8c8

Browse files
committed
Update ARKG for spec changes, add tests
1 parent 39f1cc0 commit a6ab8c8

3 files changed

Lines changed: 243 additions & 95 deletions

File tree

examples/sign_arkg.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from fido2.server import Fido2Server
3535
from fido2.utils import sha256, websafe_encode, websafe_decode
3636
from fido2.cose import CoseKey
37-
from fido2.arkg import ARKG_P256ADD_ECDH
37+
from fido2.arkg import ARKG_P256_ESP256
3838
from exampleutils import get_client
3939
import sys
4040

@@ -58,9 +58,7 @@
5858
result = client.make_credential(
5959
{
6060
**create_options["publicKey"],
61-
"extensions": {
62-
"sign": {"generateKey": {"algorithms": [ARKG_P256ADD_ECDH.ALGORITHM]}}
63-
},
61+
"extensions": {"sign": {"generateKey": {"algorithms": [ARKG_P256_ESP256]}}},
6462
}
6563
)
6664

@@ -80,23 +78,22 @@
8078
)
8179
sys.exit(1)
8280

83-
# Extension output contains master public key and keyHandle
81+
# Extension output contains master public key
8482
pk = CoseKey.parse(
8583
cbor.decode(websafe_decode(sign_key["publicKey"]))
8684
) # COSE key in bytes
87-
kh = sign_key["keyHandle"] # key handle in bytes
8885
print("public key", pk)
89-
print("keyHandle from Authenticator", cbor.decode(websafe_decode(kh)))
9086

9187
# Master public key contains blinding and KEM keys
9288
# ARKG derive_public_key uses these
93-
print("Blinding public key", pk.blinding_key)
94-
print("KEM public key", pk.kem_key)
89+
print("Blinding public key", pk.pkbl)
90+
print("KEM public key", pk.pkkem)
9591

96-
# Arbitrary bytestring used for info
97-
info = b"my-info-here"
92+
# Arbitrary bytestring used for ctx, ikm
93+
ctx = b"my-ctx-here"
94+
ikm = b"my-ikm-here"
9895
# Derived public key to verify with, and kh to send to Authenticator
99-
pk2 = pk.derive_public_key(info)
96+
pk2 = pk.derive_public_key(ikm, ctx)
10097
print("Derived public key", pk2)
10198
ref = pk2.get_ref()
10299
print("COSE Key ref for derived key", ref)

0 commit comments

Comments
 (0)