From 13e78ac0fe36f840ffe4819826409ba8b215f740 Mon Sep 17 00:00:00 2001 From: Brian DeHamer Date: Fri, 8 Sep 2023 09:15:34 -0700 Subject: [PATCH] fix bug in mocked inclusion proof calculation (#737) Signed-off-by: Brian DeHamer --- .changeset/slow-weeks-shop.md | 5 +++++ packages/mock/src/rekor/tlog.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/slow-weeks-shop.md diff --git a/.changeset/slow-weeks-shop.md b/.changeset/slow-weeks-shop.md new file mode 100644 index 00000000..6a56f507 --- /dev/null +++ b/.changeset/slow-weeks-shop.md @@ -0,0 +1,5 @@ +--- +'@sigstore/mock': patch +--- + +Fix bug in mocked inclusion proof calculation diff --git a/packages/mock/src/rekor/tlog.ts b/packages/mock/src/rekor/tlog.ts index 41bfca9c..5e27a4b8 100644 --- a/packages/mock/src/rekor/tlog.ts +++ b/packages/mock/src/rekor/tlog.ts @@ -56,7 +56,7 @@ class TLogImpl implements TLog { const logID = crypto.createHash('sha256').update(this.publicKey).digest(); const logIndex = crypto.randomInt(10_000_000); const timestamp = Math.floor(Date.now() / 1000); - const body = Buffer.from(canonicalize(proposedEntry)!).toString('base64'); + const body = Buffer.from(canonicalize(proposedEntry)!); const entry = { logID, logIndex, timestamp, body }; const set = this.calculateSET(entry); @@ -86,13 +86,13 @@ class TLogImpl implements TLog { logIndex, logID, }: { - body: string; + body: Buffer; timestamp: number; logIndex: number; logID: Buffer; }): Buffer { const setData = { - body: body, + body: body.toString('base64'), integratedTime: timestamp, logIndex: logIndex, logID: logID.toString('hex'), @@ -109,7 +109,7 @@ class TLogImpl implements TLog { timestamp, logID, }: { - body: string; + body: Buffer; timestamp: number; logID: Buffer; }): InclusionProof {