Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove timestamp from checkpoint #1888

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cmd/rekor-cli/app/log_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"encoding/pem"
"errors"
"fmt"
"time"

"github.com/go-openapi/swag"
rclient "github.com/sigstore/rekor/pkg/generated/client"
Expand All @@ -45,21 +44,17 @@ type logInfoCmdOutput struct {
ActiveTreeSize int64
TotalTreeSize int64
RootHash string
TimestampNanos uint64
TreeID string
}

func (l *logInfoCmdOutput) String() string {
// Verification is always successful if we return an object.
ts := time.Unix(0, int64(l.TimestampNanos)).UTC().Format(time.RFC3339)

return fmt.Sprintf(`Verification Successful!
Active Tree Size: %v
Total Tree Size: %v
Root Hash: %s
Timestamp: %s
TreeID: %s
`, l.ActiveTreeSize, l.TotalTreeSize, l.RootHash, ts, l.TreeID)
`, l.ActiveTreeSize, l.TotalTreeSize, l.RootHash, l.TreeID)
}

// logInfoCmd represents the current information about the transparency log
Expand Down Expand Up @@ -105,7 +100,6 @@ var logInfoCmd = &cobra.Command{
ActiveTreeSize: swag.Int64Value(logInfo.TreeSize),
TotalTreeSize: totalTreeSize(logInfo, logInfo.InactiveShards),
RootHash: swag.StringValue(logInfo.RootHash),
TimestampNanos: sth.GetTimestamp(),
TreeID: swag.StringValue(logInfo.TreeID),
}
return cmdOutput, nil
Expand Down
23 changes: 0 additions & 23 deletions pkg/util/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"fmt"
"strconv"
"strings"
"time"

"github.com/sigstore/sigstore/pkg/signature"
"github.com/sigstore/sigstore/pkg/signature/options"
Expand Down Expand Up @@ -145,27 +144,6 @@ func (r *SignedCheckpoint) UnmarshalText(data []byte) error {
return nil
}

func (r *SignedCheckpoint) SetTimestamp(timestamp uint64) {
var ts uint64
for i, val := range r.OtherContent {
if n, _ := fmt.Fscanf(strings.NewReader(val), "Timestamp: %d", &ts); n == 1 {
r.OtherContent = append(r.OtherContent[:i], r.OtherContent[i+1:]...)
}
}
r.OtherContent = append(r.OtherContent, fmt.Sprintf("Timestamp: %d", timestamp))
r.SignedNote = SignedNote{Note: string(r.Checkpoint.String())}
}

func (r *SignedCheckpoint) GetTimestamp() uint64 {
var ts uint64
for _, val := range r.OtherContent {
if n, _ := fmt.Fscanf(strings.NewReader(val), "Timestamp: %d", &ts); n == 1 {
break
}
}
return ts
}

// CreateAndSignCheckpoint creates a signed checkpoint as a commitment to the current root hash
func CreateAndSignCheckpoint(ctx context.Context, hostname string, treeID int64, treeSize uint64, rootHash []byte, signer signature.Signer) ([]byte, error) {
sth, err := CreateSignedCheckpoint(Checkpoint{
Expand All @@ -176,7 +154,6 @@ func CreateAndSignCheckpoint(ctx context.Context, hostname string, treeID int64,
if err != nil {
return nil, fmt.Errorf("error creating checkpoint: %v", err)
}
sth.SetTimestamp(uint64(time.Now().UnixNano()))
if _, err := sth.Sign(hostname, signer, options.WithContext(ctx)); err != nil {
return nil, fmt.Errorf("error signing checkpoint: %v", err)
}
Expand Down
33 changes: 30 additions & 3 deletions pkg/util/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"crypto/sha256"
"fmt"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/sigstore/sigstore/pkg/signature"
Expand Down Expand Up @@ -225,6 +224,34 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
wantSignErr: false,
wantVerifyErr: false,
},
{
c: Checkpoint{
Origin: "Log Checkpoint With Timestamp",
Size: 123,
Hash: []byte("bananas"),
OtherContent: []string{"Timestamp: 12345"},
},
identity: "someone",
signer: edPrivKey,
pubKey: edPubKey,
opts: crypto.Hash(0),
wantSignErr: false,
wantVerifyErr: false,
},
{
c: Checkpoint{
Origin: "Log Checkpoint With Multiple Other Contents",
Size: 123,
Hash: []byte("bananas"),
OtherContent: []string{"Timestamp: 12345", "Extra: Foo Bar"},
},
identity: "someone",
signer: edPrivKey,
pubKey: edPubKey,
opts: crypto.Hash(0),
wantSignErr: false,
wantVerifyErr: false,
},
{
c: Checkpoint{
Origin: "Log Checkpoint Mismatch v0",
Expand Down Expand Up @@ -283,8 +310,8 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
if err != nil {
t.Fatalf("error creating signed checkpoint")
}
time := uint64(time.Now().UnixNano())
sth.SetTimestamp(time)
// time := uint64(time.Now().UnixNano())
// sth.SetTimestamp(time)
haydentherapper marked this conversation as resolved.
Show resolved Hide resolved
signer, _ := signature.LoadSigner(test.signer, crypto.SHA256)
if _, ok := test.signer.(*rsa.PrivateKey); ok {
signer, _ = signature.LoadRSAPSSSigner(test.signer.(*rsa.PrivateKey), crypto.SHA256, test.opts.(*rsa.PSSOptions))
Expand Down