Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define COSE Key Thumbprint for PQ COSE Keys #74

Open
OR13 opened this issue Sep 5, 2023 · 1 comment
Open

Define COSE Key Thumbprint for PQ COSE Keys #74

OR13 opened this issue Sep 5, 2023 · 1 comment

Comments

@OR13
Copy link
Collaborator

OR13 commented Sep 5, 2023

see https://www.ietf.org/archive/id/draft-ietf-cose-key-thumbprint-01.html#name-others

@OR13
Copy link
Collaborator Author

OR13 commented Sep 5, 2023

For future me / others:

import crypto from 'crypto'
import * as cbor from 'cbor-web'
// https://www.ietf.org/archive/id/draft-ietf-cose-key-thumbprint-01.html#section-6
// {
//   1:2,
//  -1:1,
//  -2:h'65eda5a12577c2bae829437fe338701a
//       10aaa375e1bb5b5de108de439c08551d',
//  -3:h'1e52ed75701163f7f9e40ddf9f341b3d
//       c9ba860af7e0ca7ca7e9eecd0084d19c'
// }
it('https://www.ietf.org/archive/id/draft-ietf-cose-key-thumbprint', async () => {
  const coseKey = new Map();
  coseKey.set(1, 2)
  coseKey.set(-1, 1)
  coseKey.set(-2, Buffer.from('65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c08551d', 'hex'))
  coseKey.set(-3, Buffer.from('1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd0084d19c', 'hex'))
  const encoded = cbor.encode(coseKey)
  const digest = crypto.createHash("sha256").update(encoded).digest()
  expect(digest.toString('hex')).toBe('496bd8afadf307e5b08c64b0421bf9dc01528a344a43bda88fadd1669da253ec')
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant