Skip to content

Commit

Permalink
exp: remove encryption experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Dec 17, 2023
1 parent c5d6f3b commit 0dd7d4c
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 508 deletions.
14 changes: 2 additions & 12 deletions cmd/genji/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ func NewApp() *cli.App {
NewPebbleCommand(),
}

app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "encryption-key",
Aliases: []string{"k"},
Usage: `Encryption key to use to encrypt/decrypt the database.
The key must be a 32, 48 or 64 bytes long hexadecimal string.`,
},
}

// inject cancelable context to all commands (except the shell command)
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
Expand All @@ -60,7 +51,7 @@ func NewApp() *cli.App {
dbpath := c.Args().First()

if dbutil.CanReadFromStandardInput() {
db, err := dbutil.OpenDB(c.Context, dbpath, c.String("encryption-key"))
db, err := dbutil.OpenDB(c.Context, dbpath)
if err != nil {
return err
}
Expand All @@ -70,8 +61,7 @@ func NewApp() *cli.App {
}

return shell.Run(c.Context, &shell.Options{
DBPath: dbpath,
EncryptionKey: c.String("encryption-key"),
DBPath: dbpath,
})
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/genji/commands/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ in the same transaction, use -t`,

path := c.String("path")

db, err := dbutil.OpenDB(c.Context, path, c.String("encryption-key"))
db, err := dbutil.OpenDB(c.Context, path)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/genji/commands/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $ genji dump -f dump.sql my.db`,
return errors.New(cmd.UsageText)
}

db, err := dbutil.OpenDB(c.Context, dbPath, c.String("encryption-key"))
db, err := dbutil.OpenDB(c.Context, dbPath)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/genji/commands/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ $ curl https://api.github.com/repos/genjidb/genji/issues | genji insert --db myd
dbPath := c.String("db")
table := c.String("table")
args := c.Args().Slice()
return runInsertCommand(c.Context, dbPath, table, c.Bool("auto"), args, c.String("encryption-key"))
return runInsertCommand(c.Context, dbPath, table, c.Bool("auto"), args)
},
}
}

func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args []string, encKey string) error {
func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args []string) error {
generatedName := "data_" + strconv.FormatInt(time.Now().Unix(), 10)
createTable := false
if table == "" && auto {
Expand All @@ -83,7 +83,7 @@ func runInsertCommand(ctx context.Context, dbPath, table string, auto bool, args
dbPath = generatedName
}

db, err := dbutil.OpenDB(ctx, dbPath, encKey)
db, err := dbutil.OpenDB(ctx, dbPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/genji/commands/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewPebbleCommand() *cli.Command {
cmd.Action = func(c *cli.Context) error {
path := c.String("path")

db, err := dbutil.OpenDB(c.Context, path, c.String("encryption-key"))
db, err := dbutil.OpenDB(c.Context, path)
if err != nil {
return err
}
Expand Down
21 changes: 2 additions & 19 deletions cmd/genji/dbutil/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,17 @@ package dbutil

import (
"context"
"encoding/hex"

"github.com/cockroachdb/errors"
"github.com/genjidb/genji"
)

// OpenDB is a helper function that takes raw unvalidated parameters and opens a database.
func OpenDB(ctx context.Context, dbPath string, encKey string) (*genji.DB, error) {
func OpenDB(ctx context.Context, dbPath string) (*genji.DB, error) {
if dbPath == "" {
dbPath = ":memory:"
}

// if an encryption key is provided, open the database with the experimental encryption feature.
// the key must be a 32, 48 or 64 bytes long hexadecimal string.
var key []byte
if encKey != "" {
var err error
key, err = hex.DecodeString(encKey)
if err != nil {
return nil, errors.Wrap(err, "invalid encryption key")
}
}

db, err := genji.OpenWith(dbPath, &genji.Options{
Experimental: struct{ EncryptionKey []byte }{
EncryptionKey: key,
},
})
db, err := genji.Open(dbPath)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/genji/dbutil/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Restore(ctx context.Context, db *genji.DB, dumpFile, dbPath string) error {
defer file.Close()

if db == nil {
db, err = OpenDB(ctx, dbPath, "")
db, err = OpenDB(ctx, dbPath)
if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/genji/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ require (
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-tty v0.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/sio v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -48,7 +47,6 @@ require (
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
Expand Down
7 changes: 2 additions & 5 deletions cmd/genji/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
Expand Down Expand Up @@ -180,8 +181,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/minio/sio v0.3.0 h1:syEFBewzOMOYVzSTFpp1MqpSZk8rUNbz8VIIc+PNzus=
github.com/minio/sio v0.3.0/go.mod h1:8b0yPp2avGThviy/+OCJBI6OMpvxoUuiLvE6F1lebhw=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -280,15 +279,12 @@ go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d h1:vtUKgx8dahOomfFzLREU8nSv25YHnTgLBn4rDnWZdU0=
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
Expand Down Expand Up @@ -413,6 +409,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
Expand Down
2 changes: 1 addition & 1 deletion cmd/genji/shell/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func runIndexesCmd(db *genji.DB, tableName string, w io.Writer) error {
// If a path already exists, existing values in the target database will be overwritten.
func runSaveCmd(ctx context.Context, db *genji.DB, dbPath string) error {
// Open the new database
otherDB, err := dbutil.OpenDB(ctx, dbPath, "")
otherDB, err := dbutil.OpenDB(ctx, dbPath)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/genji/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ type Shell struct {
type Options struct {
// Path of the database directory that will be created.
// If empty, the database will be in-memory.
DBPath string
EncryptionKey string
DBPath string
}

// Run a shell.
Expand All @@ -79,7 +78,7 @@ func Run(ctx context.Context, opts *Options) error {

sh.opts = opts

db, err := dbutil.OpenDB(ctx, sh.opts.DBPath, sh.opts.EncryptionKey)
db, err := dbutil.OpenDB(ctx, sh.opts.DBPath)
if err != nil {
return err
}
Expand Down
19 changes: 0 additions & 19 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,8 @@ type DB struct {
// If path is equal to ":memory:" it will open an in-memory database,
// otherwise it will create an on-disk database.
func Open(path string) (*DB, error) {
return OpenWith(path, nil)
}

type Options struct {
// Experimental options. These options are subject to change and should not be used in production.
Experimental struct {
EncryptionKey []byte
}
}

// Open creates a Genji database at the given path.
// If path is equal to ":memory:" it will open an in-memory database,
// otherwise it will create an on-disk database.
func OpenWith(path string, opts *Options) (*DB, error) {
if opts == nil {
opts = &Options{}
}

db, err := database.Open(path, &database.Options{
CatalogLoader: catalogstore.LoadCatalog,
EncryptionKey: opts.Experimental.EncryptionKey,
})
if err != nil {
return nil, err
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ require (
github.com/cockroachdb/errors v1.9.1
github.com/cockroachdb/pebble v0.0.0-20230126224944-0a21ab1b22f5
github.com/google/go-cmp v0.5.9
github.com/minio/sio v0.3.0
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.5.0
golang.org/x/sync v0.1.0
)

Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
Expand Down Expand Up @@ -157,8 +158,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/minio/sio v0.3.0 h1:syEFBewzOMOYVzSTFpp1MqpSZk8rUNbz8VIIc+PNzus=
github.com/minio/sio v0.3.0/go.mod h1:8b0yPp2avGThviy/+OCJBI6OMpvxoUuiLvE6F1lebhw=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -243,15 +242,12 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20200513190911-00229845015e h1:rMqLP+9XLy+LdbCXHjJHAmTfXCr93W7oruWA6Hq1Alc=
Expand Down Expand Up @@ -379,6 +375,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
Expand Down
12 changes: 2 additions & 10 deletions internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type Database struct {
// how the database is loaded.
type Options struct {
CatalogLoader func(tx *Transaction) (*Catalog, error)
EncryptionKey []byte
}

// CatalogLoader loads the catalog from the disk.
Expand Down Expand Up @@ -76,7 +75,7 @@ func Open(path string, opts *Options) (*Database, error) {
path = ""
}

pdb, err := OpenPebble(path, popts, opts)
pdb, err := OpenPebble(path, popts)
if err != nil {
return nil, err
}
Expand All @@ -85,7 +84,7 @@ func Open(path string, opts *Options) (*Database, error) {
}

// Open a database with a custom comparer.
func OpenPebble(path string, popts *pebble.Options, opts *Options) (*pebble.DB, error) {
func OpenPebble(path string, popts *pebble.Options) (*pebble.DB, error) {
if popts == nil {
popts = &pebble.Options{}
}
Expand All @@ -95,13 +94,6 @@ func OpenPebble(path string, popts *pebble.Options, opts *Options) (*pebble.DB,
}

popts = popts.EnsureDefaults()
if path != "" && opts.EncryptionKey != nil {
if err := validateEncryptionKey(opts.EncryptionKey); err != nil {
return nil, err
}

popts.FS = NewEncryptedFS(popts.FS, opts.EncryptionKey)
}

return pebble.Open(path, popts)
}
Expand Down
Loading

0 comments on commit 0dd7d4c

Please sign in to comment.