github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/storage/crypt.go (about)

     1  package storage
     2  
     3  import (
     4  	"github.com/keybase/client/go/encrypteddb"
     5  	"github.com/keybase/client/go/libkb"
     6  	"github.com/keybase/client/go/protocol/gregor1"
     7  	"github.com/keybase/client/go/protocol/keybase1"
     8  	"golang.org/x/net/context"
     9  )
    10  
    11  // ***
    12  // If we change this, make sure to update libkb.EncryptionReasonChatLocalStorage as well!
    13  // Also see the encrypteddb package's cryptoVersion.
    14  // ***
    15  const cryptoVersion = 1
    16  
    17  func GetSecretBoxKey(ctx context.Context, g *libkb.GlobalContext) (fkey [32]byte, err error) {
    18  	return encrypteddb.GetSecretBoxKey(ctx, g, libkb.EncryptionReasonChatLocalStorage, "encrypt chat message")
    19  }
    20  
    21  func GetSecretBoxKeyWithUID(ctx context.Context, g *libkb.GlobalContext, uid gregor1.UID) (fkey [32]byte, err error) {
    22  	uid2, err := keybase1.UIDFromString(uid.String())
    23  	if err != nil {
    24  		return [32]byte{}, err
    25  	}
    26  	return encrypteddb.GetSecretBoxKeyWithUID(ctx, g, uid2, libkb.EncryptionReasonChatLocalStorage, "encrypt chat message")
    27  }