Skip to content

Commit

Permalink
Merge pull request #26 from Sphereon-Opensource/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
nklomp authored Apr 3, 2024
2 parents 7ea4063 + 223b70b commit c2916f8
Show file tree
Hide file tree
Showing 9 changed files with 3,284 additions and 3,260 deletions.
2 changes: 1 addition & 1 deletion packages/did-provider-ebsi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@sphereon/ssi-sdk-ext.key-manager": "workspace:^",
"@sphereon/ssi-sdk-ext.kms-local": "workspace:^",
"@sphereon/ssi-sdk.dev": "^0.15.1",
"@sphereon/ssi-sdk.dev": "^0.21.0",
"@veramo/cli": "4.2.0",
"@veramo/key-manager": "4.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/did-provider-lto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@lto-network/lto-crypto": "~1.1.1",
"@lto-network/lto-transactions": "1.2.12",
"@lto-network/signature-generator": "~1.0.0",
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/did-uni-client": "^0.6.2",
"@sphereon/lto-did-ts": "0.1.8-unstable.0",
"@veramo/core": "4.2.0",
"@veramo/did-manager": "4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/did-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@ethersproject/transactions": "^5.7.0",
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/did-uni-client": "^0.6.2",
"@sphereon/ssi-sdk-ext.key-utils": "workspace:^",
"@sphereon/ssi-sdk.core": "0.17.1",
"@stablelib/ed25519": "^1.0.3",
Expand Down
8 changes: 6 additions & 2 deletions packages/did-utils/src/did-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ export function extractPublicKeyHexWithJwkSupport(pk: _ExtendedVerificationMetho
if (pk.publicKeyJwk) {
if (pk.publicKeyJwk.kty === 'EC') {
const secp256 = new elliptic.ec(pk.publicKeyJwk.crv === 'secp256k1' ? 'secp256k1' : 'p256')
const padString = '0'

const x = u8a.fromString(pk.publicKeyJwk.x!, 'base64url')
const y = u8a.fromString(pk.publicKeyJwk.y!, 'base64url')
const xData = u8a.toString(x, 'base16')
const yData = u8a.toString(y, 'base16')
const size = yData.length <= 32 ? 32 : 64

const xHex = padLeft({ data: u8a.toString(x, 'base16'), size: 32, padString: '0' })
const yHex = padLeft({ data: u8a.toString(y, 'base16'), size: 32, padString: '0' })
const xHex = padLeft({ data: xData, size, padString })
const yHex = padLeft({ data: yData, size, padString })
const prefix = '04' // isEven(yHex) ? '02' : '03'
// Uncompressed Hex format: 04<x><y>
// Compressed Hex format: 02<x> (for even y) or 03<x> (for uneven y)
Expand Down
2 changes: 1 addition & 1 deletion packages/key-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@mattrglobal/bbs-signatures": "^1.3.1",
"@sphereon/ssi-sdk-ext.key-utils": "workspace:*",
"@sphereon/ssi-sdk.dev": "^0.15.1"
"@sphereon/ssi-sdk.dev": "^0.21.0"
},
"resolutions": {
"jsonld": "npm:@digitalcredentials/jsonld@^5.2.1",
Expand Down
21 changes: 20 additions & 1 deletion packages/key-utils/__tests__/functions.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generatePrivateKeyHex } from '../src'
import { generatePrivateKeyHex, padLeft } from '../src'
import { Key } from '../src'

describe('functions: key generator', () => {
Expand Down Expand Up @@ -44,3 +44,22 @@ describe('functions: key generator', () => {
expect((await generatePrivateKeyHex(Key.Ed25519)).length).toBe(128)
})
})
describe('functions: Leftpad', () => {
it('should pad left to 64 chars when 62 chars are present', () => {
const data = '2df693fc990b11367d8d1613b780fdd35876493e5e2517c4e1ada0ecfd8aa1'
const result = padLeft({ data, size: 64, padString: '0' })
expect(result).toEqual(`00${data}`)
})

it('should not pad left to 64 chars when 64 chars are present', () => {
const data = '002df693fc990b11367d8d1613b780fdd35876493e5e2517c4e1ada0ecfd8aa1'
const result = padLeft({ data, size: 64, padString: '0' })
expect(result).toEqual(`${data}`)
})

it('should not pad left to 64 chars when more than 64 chars are present', () => {
const data = '12345002df693fc990b11367d8d1613b780fdd35876493e5e2517c4e1ada0ecfd8aa1'
const result = padLeft({ data, size: 64, padString: '0' })
expect(result).toEqual(`${data}`)
})
})
2 changes: 1 addition & 1 deletion packages/kms-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"devDependencies": {
"@mattrglobal/bbs-signatures": "^1.3.1",
"@sphereon/jsencrypt": "3.3.2-unstable.0",
"@sphereon/ssi-sdk.dev": "^0.15.1",
"@sphereon/ssi-sdk.dev": "^0.21.0",
"@types/elliptic": "6.4.14",
"@veramo/cli": "4.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mnemonic-seed-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"typeorm": "0.3.12"
},
"devDependencies": {
"@sphereon/ssi-sdk.dev": "^0.15.1",
"@sphereon/ssi-sdk.dev": "^0.21.0",
"@types/bip39": "^3.0.0",
"@veramo/cli": "4.2.0",
"@veramo/remote-client": "4.2.0",
Expand Down
Loading

0 comments on commit c2916f8

Please sign in to comment.