diff --git a/src/service/registry.ts b/src/service/registry.ts index 4add6c9..dcbf1f2 100644 --- a/src/service/registry.ts +++ b/src/service/registry.ts @@ -201,11 +201,21 @@ export class RegistryService { const val = await this.db?.get(stringifyBytes(pk)); if (val) { - return deserializeRegistryEntry(val); + return this.deserializeRegistryEntry(val); } return null; } + + public deserializeRegistryEntry(event: Uint8Array): SignedRegistryEntry { + const dataLength = event[42]; + return { + pk: event.slice(1, 34), + revision: decodeEndian(event.slice(34, 42)), + data: event.slice(43, 43 + dataLength), + signature: event.slice(43 + dataLength), + }; + } } function verifyRegistryEntry(sre: SignedRegistryEntry): boolean { @@ -228,13 +238,3 @@ function serializeRegistryEntry(sre: SignedRegistryEntry): Uint8Array { ...sre.signature, ]); } - -function deserializeRegistryEntry(event: Uint8Array): SignedRegistryEntry { - const dataLength = event[42]; - return { - pk: event.slice(1, 34), - revision: decodeEndian(event.slice(34, 42)), - data: event.slice(43, 43 + dataLength), - signature: event.slice(43 + dataLength), - }; -}