Skip to content

Commit 49a10ec

Browse files
committedNov 29, 2022
fix(credential-ld): simplify signature suite use of Uint8Array
1 parent d4c63c1 commit 49a10ec

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed
 

‎packages/credential-ld/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
}
1515
},
1616
"dependencies": {
17-
"@digitalcredentials/ed25519-signature-2020": "3.0.2",
17+
"@digitalcredentials/ed25519-signature-2020": "^3.0.2",
1818
"@digitalcredentials/jsonld": "^5.2.1",
1919
"@digitalcredentials/jsonld-signatures": "^9.3.1",
2020
"@digitalcredentials/vc": "^5.0.0",
21-
"@transmute/credentials-context": "^0.7.0-unstable.60",
22-
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.60",
23-
"@digitalcredentials/vc": "^5.0.0",
2421
"@transmute/credentials-context": "^0.7.0-unstable.67",
2522
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.67",
2623
"@transmute/json-web-signature": "^0.7.0-unstable.67",

‎packages/credential-ld/src/suites/Ed25519Signature2020.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@
33
import * as u8a from 'uint8arrays'
44
import { Ed25519Signature2020 } from '@digitalcredentials/ed25519-signature-2020'
55
import { Ed25519VerificationKey2020 } from '@digitalcredentials/ed25519-verification-key-2020'
6-
import { TextEncoder } from 'util'
6+
77
/**
88
* Veramo wrapper for the Ed25519Signature2020 suite by digitalcredentials
99
*
@@ -41,23 +41,22 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
4141
data: messageString,
4242
encoding: 'base64',
4343
})
44-
const utf8Encode = new TextEncoder()
45-
return utf8Encode.encode(signature)
44+
return u8a.fromString(signature)
4645
},
4746
}
4847

4948
const verificationKey = new Ed25519VerificationKey2020({
5049
id,
5150
controller,
5251
publicKeyMultibase: this.preSigningKeyModification(u8a.fromString(key.publicKeyHex, 'hex')),
53-
signer: ()=> signer,
52+
signer: () => signer,
5453
type: this.getSupportedVerificationType(),
5554
})
5655
// overwrite the signer since we're not passing the private key
5756
verificationKey.signer = () => signer as any
5857
return new Ed25519Signature2020({
5958
key: verificationKey,
60-
signer: signer
59+
signer: signer,
6160
})
6261
}
6362

@@ -74,7 +73,7 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
7473
}
7574

7675
preSigningKeyModification(key: Uint8Array): string {
77-
const modifiedKey = Uint8Array.from([...this.MULTICODEC_PREFIX, ...key])
76+
const modifiedKey = u8a.concat([this.MULTICODEC_PREFIX, key])
7877
return `${this.MULTIBASE_BASE58BTC_PREFIX}${u8a.toString(modifiedKey, 'base58btc')}`
7978
}
8079
}

‎packages/data-store/src/identifier/private-key-store.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { ImportablePrivateKey, ManagedPrivateKey } from '@veramo/key-manager'
44
import { PrivateKey } from '../entities/private-key'
55
import { v4 as uuid4 } from 'uuid'
66
import Debug from 'debug'
7-
import { OrPromise } from "@veramo/utils";
8-
import { getConnectedDb } from "../utils";
7+
import { OrPromise } from '@veramo/utils'
8+
import { getConnectedDb } from '../utils'
99

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

1212
/**
13-
* An implementation of {@link @veramo/key-manager#abstractPrivateKeyStore | AbstractPrivateKeyStore} that uses a
13+
* An implementation of {@link @veramo/key-manager#AbstractPrivateKeyStore | AbstractPrivateKeyStore} that uses a
1414
* TypeORM database connection to store private key material.
1515
*
1616
* The keys can be encrypted while at rest if this class is initialized with an

‎packages/test-react-app/package.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,19 @@
2222
"@veramo/test-utils": "^4.1.1",
2323
"@veramo/url-handler": "^4.1.1",
2424
"@veramo/utils": "^4.1.1",
25+
"buffer": "npm:buffer",
2526
"crypto": "npm:crypto-browserify",
2627
"did-resolver": "^4.0.1",
2728
"ethr-did-resolver": "^8.0.0",
29+
"path": "npm:path-browserify",
30+
"process": "npm:process",
2831
"react": "18.1.0",
2932
"react-dom": "18.1.0",
3033
"stream": "npm:stream-browserify",
3134
"typeorm": "^0.3.10",
32-
"web-did-resolver": "^2.0.20",
33-
"web-vitals": "^2.1.4",
34-
"web-did-resolver": "^2.0.21",
35-
"web-vitals": "^2.1.4",
3635
"util": "npm:util",
37-
"path": "npm:path-browserify",
38-
"process": "npm:process",
39-
"buffer": "npm:buffer"
36+
"web-did-resolver": "^2.0.21",
37+
"web-vitals": "^2.1.4"
4038
},
4139
"scripts": {
4240
"start": "react-scripts start",

0 commit comments

Comments
 (0)
Please sign in to comment.