11"use strict" ;
22Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3+ exports . LogCheckpoint = void 0 ;
34exports . verifyCheckpoint = verifyCheckpoint ;
45/*
5- Copyright 2023 The Sigstore Authors.
6+ Copyright 2025 The Sigstore Authors.
67
78Licensed under the Apache License, Version 2.0 (the "License");
89you may not use this file except in compliance with the License.
@@ -18,7 +19,6 @@ limitations under the License.
1819*/
1920const core_1 = require ( "@sigstore/core" ) ;
2021const error_1 = require ( "../error" ) ;
21- const trust_1 = require ( "../trust" ) ;
2222// Separator between the note and the signatures in a checkpoint
2323const CHECKPOINT_SEPARATOR = '\n\n' ;
2424// Checkpoint signatures are of the following form:
@@ -37,39 +37,29 @@ const SIGNATURE_REGEX = /\u2014 (\S+) (\S+)\n/g;
3737// inclusion proof
3838// See: https://github.com/transparency-dev/formats/blob/main/log/README.md
3939function verifyCheckpoint ( entry , tlogs ) {
40- // Filter tlog instances to just those which were valid at the time of the
41- // entry
42- const validTLogs = ( 0 , trust_1 . filterTLogAuthorities ) ( tlogs , {
43- targetDate : new Date ( Number ( entry . integratedTime ) * 1000 ) ,
44- } ) ;
4540 const inclusionProof = entry . inclusionProof ;
4641 const signedNote = SignedNote . fromString ( inclusionProof . checkpoint . envelope ) ;
4742 const checkpoint = LogCheckpoint . fromString ( signedNote . note ) ;
4843 // Verify that the signatures in the checkpoint are all valid
49- if ( ! verifySignedNote ( signedNote , validTLogs ) ) {
44+ if ( ! verifySignedNote ( signedNote , tlogs ) ) {
5045 throw new error_1 . VerificationError ( {
5146 code : 'TLOG_INCLUSION_PROOF_ERROR' ,
5247 message : 'invalid checkpoint signature' ,
5348 } ) ;
5449 }
55- // Verify that the root hash from the checkpoint matches the root hash in the
56- // inclusion proof
57- if ( ! core_1 . crypto . bufferEqual ( checkpoint . logHash , inclusionProof . rootHash ) ) {
58- throw new error_1 . VerificationError ( {
59- code : 'TLOG_INCLUSION_PROOF_ERROR' ,
60- message : 'root hash mismatch' ,
61- } ) ;
62- }
50+ return checkpoint ;
6351}
6452// Verifies the signatures in the SignedNote. For each signature, the
6553// corresponding transparency log is looked up by the key hint and the
6654// signature is verified against the public key in the transparency log.
6755// Throws an error if any of the signatures are invalid.
6856function verifySignedNote ( signedNote , tlogs ) {
6957 const data = Buffer . from ( signedNote . note , 'utf-8' ) ;
70- return signedNote . signatures . every ( ( signature ) => {
58+ return signedNote . signatures . some ( ( signature ) => {
7159 // Find the transparency log instance with the matching key hint
72- const tlog = tlogs . find ( ( tlog ) => core_1 . crypto . bufferEqual ( tlog . logID . subarray ( 0 , 4 ) , signature . keyHint ) ) ;
60+ const tlog = tlogs . find ( ( tlog ) => core_1 . crypto . bufferEqual ( tlog . logID . subarray ( 0 , 4 ) , signature . keyHint ) &&
61+ tlog . baseURL . match ( signature . name ) // Match the name to the base URL of the tlog
62+ ) ;
7363 if ( ! tlog ) {
7464 return false ;
7565 }
@@ -80,6 +70,8 @@ function verifySignedNote(signedNote, tlogs) {
8070// of a body (or note) and one more signatures calculated over the body. See
8171// https://github.com/transparency-dev/formats/blob/main/log/README.md#signed-envelope
8272class SignedNote {
73+ note ;
74+ signatures ;
8375 constructor ( note , signatures ) {
8476 this . note = note ;
8577 this . signatures = signatures ;
@@ -134,6 +126,10 @@ class SignedNote {
134126// See:
135127// https://github.com/transparency-dev/formats/blob/main/log/README.md#checkpoint-body
136128class LogCheckpoint {
129+ origin ;
130+ logSize ;
131+ logHash ;
132+ rest ;
137133 constructor ( origin , logSize , logHash , rest ) {
138134 this . origin = origin ;
139135 this . logSize = logSize ;
@@ -155,3 +151,4 @@ class LogCheckpoint {
155151 return new LogCheckpoint ( origin , logSize , rootHash , rest ) ;
156152 }
157153}
154+ exports . LogCheckpoint = LogCheckpoint ;
0 commit comments