sealbox

package
v0.0.0-...-c408cbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sealbox implements web3 secrets storage.

https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition

Index

Constants

View Source
const (
	// StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptN = 1 << 18

	// StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptP = 1

	// LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptN = 1 << 12

	// LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptP = 6
)

Variables

View Source
var ErrDecrypt = errors.New("could not decrypt key with given passphrase")

ErrDecrypt - Error returned on failed decryption attempt.

Functions

This section is empty.

Types

type CipherParams

type CipherParams struct {
	IV string `json:"iv,omitempty"`
}

CipherParams - Sealed box params JSON structure.

type Crypto

type Crypto struct {
	Cipher       string       `json:"cipher,omitempty"`
	CipherText   string       `json:"ciphertext,omitempty"`
	CipherParams CipherParams `json:"cipherparams,omitempty"`
	KDF          string       `json:"kdf,omitempty"`
	KDFParams    KDFParams    `json:"kdfparams,omitempty"`
	MAC          string       `json:"mac,omitempty"`
}

Crypto - Sealed JSON structure.

type KDFParams

type KDFParams struct {
	N     int    `json:"n,omitempty"`
	R     int    `json:"r,omitempty"`
	P     int    `json:"p,omitempty"`
	C     int    `json:"c,omitempty"`
	DKLen int    `json:"dklen,omitempty"`
	Salt  string `json:"salt,omitempty"`
	PRF   string `json:"prf,omitempty"`
}

KDFParams - Sealed box KDF parameters.

type SealedBox

type SealedBox struct {
	Version int    `json:"version,omitempty"`
	Crypto  Crypto `json:"crypto,omitempty"`
}

SealedBox - Sealed box JSON structure version 3.

func Encrypt

func Encrypt(body, pwd []byte, scryptN, scryptP int) (_ SealedBox, err error)

Encrypt - Encrypts a box using the specified scrypt parameters.

func EncryptLight

func EncryptLight(body, pwd []byte, scryptN, scryptP int) (_ SealedBox, err error)

EncryptLight - Encrypts a box using light scrypt parameters.

func EncryptStandard

func EncryptStandard(body, pwd []byte, scryptN, scryptP int) (_ SealedBox, err error)

EncryptStandard - Encrypts a box using standard scrypt parameters.

func (*SealedBox) Decrypt

func (box *SealedBox) Decrypt(pwd string) ([]byte, error)

Decrypt - Decrypts a key from a json blob, returning the private key itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL