diff --git a/packages/node/src/handlers.ts b/packages/node/src/handlers.ts index 6b6e0b83..de6fa2f8 100644 --- a/packages/node/src/handlers.ts +++ b/packages/node/src/handlers.ts @@ -219,7 +219,7 @@ export async function signGeneratedVertices(node: DRPNode, vertices: Vertex[]) { return; } - await node.signVertexOperation(vertex); + await node.signVertex(vertex); }); await Promise.all(signPromises); @@ -260,9 +260,7 @@ export async function verifyIncomingVertices( } const publicKeyBytes = uint8ArrayFromString(publicKey, "base64"); - const operationData = uint8ArrayFromString( - JSON.stringify(vertex.operation), - ); + const data = uint8ArrayFromString(vertex.hash); try { const cryptoKey = await crypto.subtle.importKey( @@ -277,7 +275,7 @@ export async function verifyIncomingVertices( { name: "Ed25519" }, cryptoKey, signature, - operationData, + data, ); return isValid ? vertex : null; diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index a1d801c8..9aa54354 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -99,13 +99,11 @@ export class DRPNode { operations.syncObject(this, id, peerId); } - async signVertexOperation(vertex: Vertex) { + async signVertex(vertex: Vertex) { if (vertex.peerId !== this.networkNode.peerId) { log.error("::signVertexOperation: Invalid peer id"); return ""; } - vertex.signature = await this.networkNode.sign( - JSON.stringify(vertex.operation), - ); + vertex.signature = await this.networkNode.sign(vertex.hash); } }