Skip to content

Commit

Permalink
fix(credential-ld): simplify signature suite use of Uint8Array
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Nov 29, 2022
1 parent d4c63c1 commit 49a10ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
5 changes: 1 addition & 4 deletions packages/credential-ld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
}
},
"dependencies": {
"@digitalcredentials/ed25519-signature-2020": "3.0.2",
"@digitalcredentials/ed25519-signature-2020": "^3.0.2",
"@digitalcredentials/jsonld": "^5.2.1",
"@digitalcredentials/jsonld-signatures": "^9.3.1",
"@digitalcredentials/vc": "^5.0.0",
"@transmute/credentials-context": "^0.7.0-unstable.60",
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.60",
"@digitalcredentials/vc": "^5.0.0",
"@transmute/credentials-context": "^0.7.0-unstable.67",
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.67",
"@transmute/json-web-signature": "^0.7.0-unstable.67",
Expand Down
11 changes: 5 additions & 6 deletions packages/credential-ld/src/suites/Ed25519Signature2020.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@
import * as u8a from 'uint8arrays'
import { Ed25519Signature2020 } from '@digitalcredentials/ed25519-signature-2020'
import { Ed25519VerificationKey2020 } from '@digitalcredentials/ed25519-verification-key-2020'
import { TextEncoder } from 'util'

/**
* Veramo wrapper for the Ed25519Signature2020 suite by digitalcredentials
*
Expand Down Expand Up @@ -41,23 +41,22 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
data: messageString,
encoding: 'base64',
})
const utf8Encode = new TextEncoder()
return utf8Encode.encode(signature)
return u8a.fromString(signature)
},
}

const verificationKey = new Ed25519VerificationKey2020({
id,
controller,
publicKeyMultibase: this.preSigningKeyModification(u8a.fromString(key.publicKeyHex, 'hex')),
signer: ()=> signer,
signer: () => signer,
type: this.getSupportedVerificationType(),
})
// overwrite the signer since we're not passing the private key
verificationKey.signer = () => signer as any
return new Ed25519Signature2020({
key: verificationKey,
signer: signer
signer: signer,
})
}

Expand All @@ -74,7 +73,7 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
}

preSigningKeyModification(key: Uint8Array): string {
const modifiedKey = Uint8Array.from([...this.MULTICODEC_PREFIX, ...key])
const modifiedKey = u8a.concat([this.MULTICODEC_PREFIX, key])
return `${this.MULTIBASE_BASE58BTC_PREFIX}${u8a.toString(modifiedKey, 'base58btc')}`
}
}
6 changes: 3 additions & 3 deletions packages/data-store/src/identifier/private-key-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { ImportablePrivateKey, ManagedPrivateKey } from '@veramo/key-manager'
import { PrivateKey } from '../entities/private-key'
import { v4 as uuid4 } from 'uuid'
import Debug from 'debug'
import { OrPromise } from "@veramo/utils";
import { getConnectedDb } from "../utils";
import { OrPromise } from '@veramo/utils'
import { getConnectedDb } from '../utils'

const debug = Debug('veramo:typeorm:key-store')

/**
* An implementation of {@link @veramo/key-manager#abstractPrivateKeyStore | AbstractPrivateKeyStore} that uses a
* An implementation of {@link @veramo/key-manager#AbstractPrivateKeyStore | AbstractPrivateKeyStore} that uses a
* TypeORM database connection to store private key material.
*
* The keys can be encrypted while at rest if this class is initialized with an
Expand Down
12 changes: 5 additions & 7 deletions packages/test-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@
"@veramo/test-utils": "^4.1.1",
"@veramo/url-handler": "^4.1.1",
"@veramo/utils": "^4.1.1",
"buffer": "npm:buffer",
"crypto": "npm:crypto-browserify",
"did-resolver": "^4.0.1",
"ethr-did-resolver": "^8.0.0",
"path": "npm:path-browserify",
"process": "npm:process",
"react": "18.1.0",
"react-dom": "18.1.0",
"stream": "npm:stream-browserify",
"typeorm": "^0.3.10",
"web-did-resolver": "^2.0.20",
"web-vitals": "^2.1.4",
"web-did-resolver": "^2.0.21",
"web-vitals": "^2.1.4",
"util": "npm:util",
"path": "npm:path-browserify",
"process": "npm:process",
"buffer": "npm:buffer"
"web-did-resolver": "^2.0.21",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
Expand Down

0 comments on commit 49a10ec

Please sign in to comment.