Skip to content

Commit 22370d2

Browse files
sgbettclaude
andcommitted
fix(wallet): use correct protocol ID and key ID in prove_certificate (#424)
prove_certificate was using 'certificate field revelation' and prefixing the cert type to key_id, diverging from the TS/Go reference SDKs. This made Ruby-issued verifier keyrings cryptographically incompatible with other SDKs. Now uses 'certificate field encryption' and "#{serial_number} #{field_name}" to match cross-SDK behaviour. Closes #424 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5907040 commit 22370d2

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

gem/bsv-sdk/lib/bsv/auth/get_verifiable_certificates.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ module Auth
99
# +prove_certificate+ for each to obtain a verifier-specific keyring for
1010
# selective field revelation.
1111
#
12-
# NOTE: Issue #424 documents a known bug in +WalletClient#prove_certificate+ — it
13-
# uses the wrong protocol ID (+certificate field revelation+ vs +certificate field
14-
# encryption+) and an incorrect key ID format. Until that bug is fixed, the keyring
15-
# produced here will be cryptographically incompatible with the TS/Go SDKs.
1612
module GetVerifiableCertificates
1713
module_function
1814

gem/bsv-wallet/lib/bsv/wallet_interface/wallet_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ def prove_certificate(args, originator: nil)
569569
# Encrypt the keyring entry for the verifier
570570
encrypted = encrypt({
571571
plaintext: key_value.bytes,
572-
protocol_id: [2, 'certificate field revelation'],
573-
key_id: "#{cert_arg[:type]} #{cert_arg[:serial_number]} #{field_name}",
572+
protocol_id: [2, 'certificate field encryption'],
573+
key_id: "#{cert_arg[:serial_number]} #{field_name}",
574574
counterparty: verifier
575575
})
576576
keyring_for_verifier[field_name] = encrypted[:ciphertext]

gem/bsv-wallet/spec/bsv/wallet_interface/certificate_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@
462462

463463
decrypted = verifier_wallet.decrypt({
464464
ciphertext: result[:keyring_for_verifier]['name'],
465-
protocol_id: [2, 'certificate field revelation'],
466-
key_id: "#{cert_type} #{serial_number} name",
465+
protocol_id: [2, 'certificate field encryption'],
466+
key_id: "#{serial_number} name",
467467
counterparty: prover_identity
468468
})
469469
expect(decrypted[:plaintext].pack('C*')).to eq(keyring['name'])

0 commit comments

Comments
 (0)