Documentation
¶
Index ¶
- Constants
- func DecryptBackup(encrypted string, passphrase string, attemptIterations ...int) (map[string]interface{}, error)
- func DecryptToStruct[T any](encrypted string, passphrase string, attemptIterations ...int) (*T, error)
- type BackupType
- type BapMasterBackup
- type BapMemberBackup
- type EncryptionResult
- type MasterBackupType42
- type OneSatBackup
- type WifBackup
Constants ¶
const ( RECOMMENDED_ITERATIONS = 600000 // Current recommended PBKDF2 iterations LEGACY_ITERATIONS = 100000 // Legacy iteration count for backwards compatibility SALT_LENGTH = 16 // Random salt length in bytes IV_LENGTH = 12 // GCM IV/nonce length in bytes KEY_LENGTH = 32 // AES-256 key length in bytes TAG_LENGTH = 16 // GCM authentication tag length )
Encryption constants matching TypeScript bitcoin-backup library
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackupType ¶
type BackupType string
BackupType represents the type of backup
const ( BackupTypeBapMaster BackupType = "bap-master" BackupTypeBapMember BackupType = "bap-member" BackupTypeWif BackupType = "wif" BackupTypeOneSat BackupType = "onesat" )
func DetectBackupFormat ¶
func DetectBackupFormat(content string) (BackupType, bool, error)
DetectBackupFormat attempts to determine the format of a backup string
type BapMasterBackup ¶
type BapMasterBackup struct { IDs string `json:"ids"` // Encrypted BAP data Xprv string `json:"xprv"` // Extended private key Mnemonic string `json:"mnemonic"` // BIP39 mnemonic phrase Label string `json:"label,omitempty"` // Optional label CreatedAt string `json:"createdAt,omitempty"` // ISO 8601 timestamp }
BapMasterBackup represents a BAP master key backup (mnemonic-based)
type BapMemberBackup ¶
type BapMemberBackup struct { WIF string `json:"wif"` // Private key in WIF format ID string `json:"id"` // BAP ID Label string `json:"label,omitempty"` // Optional label CreatedAt string `json:"createdAt,omitempty"` // ISO 8601 timestamp }
BapMemberBackup represents a BAP member identity backup
func CreateBapMemberBackup ¶
func CreateBapMemberBackup(wif, id, label string) *BapMemberBackup
CreateBapMemberBackup creates a new BAP member backup
type EncryptionResult ¶
type EncryptionResult struct { Encrypted string // Base64 encoded encrypted data Iterations int // PBKDF2 iterations used }
EncryptionResult represents the result of encryption
func EncryptBackup ¶
func EncryptBackup(data interface{}, passphrase string, iterations ...int) (*EncryptionResult, error)
EncryptBackup encrypts any backup type with a passphrase
type MasterBackupType42 ¶
type MasterBackupType42 struct { IDs string `json:"ids"` // Encrypted BAP data MasterKey string `json:"masterKey"` // Master key in WIF format KeyName string `json:"keyName"` // Key identifier for Type 42 Label string `json:"label,omitempty"` // Optional label CreatedAt string `json:"createdAt,omitempty"` // ISO 8601 timestamp }
MasterBackupType42 represents a Type 42 derivation master backup
type OneSatBackup ¶
type OneSatBackup struct { OrdPk string `json:"ordPk"` // Ordinals private key PayPk string `json:"payPk"` // Payment private key IdentityPk string `json:"identityPk"` // Identity private key Label string `json:"label,omitempty"` // Optional label CreatedAt string `json:"createdAt,omitempty"` // ISO 8601 timestamp }
OneSatBackup represents a 1Sat ordinals wallet backup
func CreateOneSatBackup ¶
func CreateOneSatBackup(ordPk, payPk, identityPk, label string) *OneSatBackup
CreateOneSatBackup creates a new 1Sat ordinals backup
type WifBackup ¶
type WifBackup struct { WIF string `json:"wif"` // Private key in WIF format Label string `json:"label,omitempty"` // Optional label CreatedAt string `json:"createdAt,omitempty"` // ISO 8601 timestamp }
WifBackup represents a simple WIF key backup
func CreateWifBackup ¶
CreateWifBackup creates a new WIF backup