diff --git a/package.json b/package.json index deaf8f79..d681e570 100644 --- a/package.json +++ b/package.json @@ -185,14 +185,14 @@ "iso-random-stream": "^2.0.0", "multiformats": "^9.4.5", "node-forge": "^1.1.0", - "protons-runtime": "^1.0.4", + "protons-runtime": "^2.0.2", "uint8arrays": "^3.0.0" }, "devDependencies": { "@types/mocha": "^9.0.0", "aegir": "^37.0.12", "benchmark": "^2.1.4", - "protons": "^3.0.4", + "protons": "^4.0.1", "sinon": "^14.0.0", "util": "^0.12.3", "wherearewe": "^1.0.0" diff --git a/src/keys/ed25519-class.ts b/src/keys/ed25519-class.ts index 63587ae4..99b7ab24 100644 --- a/src/keys/ed25519-class.ts +++ b/src/keys/ed25519-class.ts @@ -26,7 +26,7 @@ export class Ed25519PublicKey { return pbm.PublicKey.encode({ Type: pbm.KeyType.Ed25519, Data: this.marshal() - }) + }).subarray() } equals (key: any) { @@ -67,7 +67,7 @@ export class Ed25519PrivateKey { return pbm.PrivateKey.encode({ Type: pbm.KeyType.Ed25519, Data: this.marshal() - }) + }).subarray() } equals (key: any) { diff --git a/src/keys/keys.ts b/src/keys/keys.ts index 10efbd48..a11d7440 100644 --- a/src/keys/keys.ts +++ b/src/keys/keys.ts @@ -3,6 +3,7 @@ import { enumeration, encodeMessage, decodeMessage, message, bytes } from 'protons-runtime' import type { Codec } from 'protons-runtime' +import type { Uint8ArrayList } from 'uint8arraylist' export enum KeyType { RSA = 'RSA', @@ -34,11 +35,11 @@ export namespace PublicKey { }) } - export const encode = (obj: PublicKey): Uint8Array => { + export const encode = (obj: PublicKey): Uint8ArrayList => { return encodeMessage(obj, PublicKey.codec()) } - export const decode = (buf: Uint8Array): PublicKey => { + export const decode = (buf: Uint8Array | Uint8ArrayList): PublicKey => { return decodeMessage(buf, PublicKey.codec()) } } @@ -56,11 +57,11 @@ export namespace PrivateKey { }) } - export const encode = (obj: PrivateKey): Uint8Array => { + export const encode = (obj: PrivateKey): Uint8ArrayList => { return encodeMessage(obj, PrivateKey.codec()) } - export const decode = (buf: Uint8Array): PrivateKey => { + export const decode = (buf: Uint8Array | Uint8ArrayList): PrivateKey => { return decodeMessage(buf, PrivateKey.codec()) } } diff --git a/src/keys/rsa-class.ts b/src/keys/rsa-class.ts index 16075eb3..055015b0 100644 --- a/src/keys/rsa-class.ts +++ b/src/keys/rsa-class.ts @@ -29,7 +29,7 @@ export class RsaPublicKey { return pbm.PublicKey.encode({ Type: pbm.KeyType.RSA, Data: this.marshal() - }) + }).subarray() } encrypt (bytes: Uint8Array) { @@ -84,7 +84,7 @@ export class RsaPrivateKey { return pbm.PrivateKey.encode({ Type: pbm.KeyType.RSA, Data: this.marshal() - }) + }).subarray() } equals (key: any) { diff --git a/src/keys/secp256k1-class.ts b/src/keys/secp256k1-class.ts index 82b05e2f..2dd3c7a5 100644 --- a/src/keys/secp256k1-class.ts +++ b/src/keys/secp256k1-class.ts @@ -26,7 +26,7 @@ export class Secp256k1PublicKey { return keysProtobuf.PublicKey.encode({ Type: keysProtobuf.KeyType.Secp256k1, Data: this.marshal() - }) + }).subarray() } equals (key: any) { @@ -67,7 +67,7 @@ export class Secp256k1PrivateKey { return keysProtobuf.PrivateKey.encode({ Type: keysProtobuf.KeyType.Secp256k1, Data: this.marshal() - }) + }).subarray() } equals (key: any) {