Add debug logging to verify public key derivation
This commit is contained in:
parent
94f1da3ff1
commit
661a668169
|
|
@ -97,10 +97,19 @@ class DeviceIdentity(context: Context) {
|
||||||
?: throw IllegalStateException("No private key available")
|
?: throw IllegalStateException("No private key available")
|
||||||
val privateKeyBytes = base64UrlDecode(privateKeyBase64)
|
val privateKeyBytes = base64UrlDecode(privateKeyBase64)
|
||||||
|
|
||||||
// Create EdDSA private key
|
// Create EdDSA private key from seed
|
||||||
val privateKeySpec = EdDSAPrivateKeySpec(privateKeyBytes, ed25519Spec)
|
val privateKeySpec = EdDSAPrivateKeySpec(privateKeyBytes, ed25519Spec)
|
||||||
val privateKey = EdDSAPrivateKey(privateKeySpec)
|
val privateKey = EdDSAPrivateKey(privateKeySpec)
|
||||||
|
|
||||||
|
// Verify the derived public key matches stored public key
|
||||||
|
val derivedPubKey = privateKey.abyte
|
||||||
|
val storedPubKeyBase64 = prefs.getString(keyPublic, null)
|
||||||
|
val storedPubKey = storedPubKeyBase64?.let { base64UrlDecode(it) }
|
||||||
|
|
||||||
|
Log.d(tag, "Stored pubkey: ${storedPubKeyBase64?.take(20)}...")
|
||||||
|
Log.d(tag, "Derived pubkey: ${base64UrlEncode(derivedPubKey).take(20)}...")
|
||||||
|
Log.d(tag, "Keys match: ${derivedPubKey.contentEquals(storedPubKey)}")
|
||||||
|
|
||||||
// Sign the payload using standard Ed25519 (not prehashed Ed25519ph)
|
// Sign the payload using standard Ed25519 (not prehashed Ed25519ph)
|
||||||
val signature = EdDSAEngine().apply {
|
val signature = EdDSAEngine().apply {
|
||||||
initSign(privateKey)
|
initSign(privateKey)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue