Documentation ¶
Overview ¶
Package crypto provides crypto related utility functions.
It supports ed25519, BLS for signature scheme, sha256 for hash, argon2id and pbkdf2 for encryption.
Index ¶
- Constants
- func BLSCreateAggSig(keysList [][]byte, pubKeySignaturePairs []*BLSPublicKeySignaturePair) ([]byte, []byte)
- func BLSPopProve(privateKey []byte) []byte
- func BLSPopVerify(publicKey, proof []byte) bool
- func BLSSKToPK(privateKey []byte) []byte
- func BLSSign(msg []byte, privateKey []byte) []byte
- func BLSVerify(msg, signature, publicKey []byte) bool
- func BLSVerifyAggSig(keysList [][]byte, aggregationBits []byte, signature []byte, message []byte) bool
- func BLSVerifyWeightedAggSig(keysList [][]byte, aggregationBits []byte, signature []byte, weights []uint64, ...) bool
- func DecryptMessageWithPassword(encryptedMessage *EncryptedMessage, password string) ([]byte, error)
- func DecryptPassphraseWithPassword(encryptedPassphrase *EncryptedPassphrase, password string) (string, error)
- func DeriveBLSKey(recoveryPhrase, path string) ([]byte, error)
- func DeriveEd25519Key(recoveryPhrase, path string) ([]byte, error)
- func GetAddress(publicKey []byte) []byte
- func GetEdPublicKey(privateKey []byte) []byte
- func GetHashOnionSeed() []byte
- func GetKeys(passphrase string) ([]byte, []byte, error)
- func Hash(key []byte) []byte
- func HashOnion(seed []byte, count int, distance int) [][]byte
- func RandomBytes(size int) []byte
- func Sign(privateKey []byte, message []byte) []byte
- func VerifySignature(publicKey, signature []byte, message []byte) error
- type BLSAggregatePublicKey
- type BLSAggregateSignature
- type BLSKeyPair
- type BLSPublicKey
- type BLSPublicKeySignaturePair
- type BLSSecretKey
- type BLSSignature
- type Bits
- type CipherParams
- func (e *CipherParams) Decode(data []byte) error
- func (e *CipherParams) DecodeFromReader(reader *codec.Reader) error
- func (e *CipherParams) DecodeStrict(data []byte) error
- func (e *CipherParams) DecodeStrictFromReader(reader *codec.Reader) error
- func (e *CipherParams) Encode() []byte
- func (e *CipherParams) MustDecode(data []byte)
- func (e CipherParams) String() string
- func (e CipherParams) Validate() error
- type EncryptOptions
- type EncryptedMessage
- func (e *EncryptedMessage) Decode(data []byte) error
- func (e *EncryptedMessage) DecodeFromReader(reader *codec.Reader) error
- func (e *EncryptedMessage) DecodeStrict(data []byte) error
- func (e *EncryptedMessage) DecodeStrictFromReader(reader *codec.Reader) error
- func (e *EncryptedMessage) Encode() []byte
- func (e *EncryptedMessage) MustDecode(data []byte)
- func (e EncryptedMessage) String() string
- func (e EncryptedMessage) Validate() error
- type EncryptedPassphrase
- type KDFParams
- func (e *KDFParams) Decode(data []byte) error
- func (e *KDFParams) DecodeFromReader(reader *codec.Reader) error
- func (e *KDFParams) DecodeStrict(data []byte) error
- func (e *KDFParams) DecodeStrictFromReader(reader *codec.Reader) error
- func (e *KDFParams) Encode() []byte
- func (e *KDFParams) MustDecode(data []byte)
- func (e KDFParams) String() string
- func (e KDFParams) Validate() error
Constants ¶
View Source
const ( BLSPublicKeyLength = 48 BLSSignatureLength = 96 )
View Source
const ( // PBKDF2Iterations is default iteration for KDF. PBKDF2Iterations = 1000000 // PBKDF2Iterations is default key length. PBKDF2KeyLen = 32 HashLengh = 32 EdPublicKeyLength = 32 EdPrivateKeyLength = 64 EdSignatureLength = 64 )
View Source
const ( CipherAES256GCM = "aes-256-gcm" KDFArgon2ID = "argon2id" )
Variables ¶
This section is empty.
Functions ¶
func BLSCreateAggSig ¶
func BLSCreateAggSig(keysList [][]byte, pubKeySignaturePairs []*BLSPublicKeySignaturePair) ([]byte, []byte)
func BLSPopProve ¶
func BLSPopVerify ¶
func BLSVerifyAggSig ¶
func BLSVerifyWeightedAggSig ¶
func DecryptMessageWithPassword ¶
func DecryptMessageWithPassword(encryptedMessage *EncryptedMessage, password string) ([]byte, error)
func DecryptPassphraseWithPassword ¶
func DecryptPassphraseWithPassword(encryptedPassphrase *EncryptedPassphrase, password string) (string, error)
func DeriveBLSKey ¶
func DeriveEd25519Key ¶
func GetAddress ¶
func GetEdPublicKey ¶
func GetHashOnionSeed ¶
func GetHashOnionSeed() []byte
func RandomBytes ¶
func VerifySignature ¶
Types ¶
type BLSAggregatePublicKey ¶
type BLSAggregatePublicKey = blst.P1Aggregate
type BLSAggregateSignature ¶
type BLSAggregateSignature = blst.P2Aggregate
type BLSKeyPair ¶
BLSKeyPair is a container for a BLS Keypair.
func BLSKeyGen ¶
func BLSKeyGen(passphrase []byte) *BLSKeyPair
BLSKeyGen generates a BLSKeyPair from the passphrase provided.
func BLSRandomKeyGen ¶
func BLSRandomKeyGen() *BLSKeyPair
BLSRandomKeyGen returns a random BLSKeyPair.
type BLSPublicKey ¶
type BLSSecretKey ¶
type BLSSignature ¶
type CipherParams ¶
type CipherParams struct { IV codec.Hex `json:"iv" fieldNumber:"1"` Tag codec.Hex `json:"tag" fieldNumber:"2"` }
func (*CipherParams) Decode ¶
func (e *CipherParams) Decode(data []byte) error
func (*CipherParams) DecodeFromReader ¶
func (e *CipherParams) DecodeFromReader(reader *codec.Reader) error
func (*CipherParams) DecodeStrict ¶
func (e *CipherParams) DecodeStrict(data []byte) error
func (*CipherParams) DecodeStrictFromReader ¶
func (e *CipherParams) DecodeStrictFromReader(reader *codec.Reader) error
func (*CipherParams) Encode ¶
func (e *CipherParams) Encode() []byte
func (*CipherParams) MustDecode ¶
func (e *CipherParams) MustDecode(data []byte)
func (CipherParams) String ¶
func (e CipherParams) String() string
func (CipherParams) Validate ¶
func (e CipherParams) Validate() error
type EncryptOptions ¶
func DefaultEncryptOptions ¶
func DefaultEncryptOptions() *EncryptOptions
type EncryptedMessage ¶
type EncryptedMessage struct { Version string `json:"version" fieldNumber:"1"` CipherText codec.Hex `json:"cipherText" fieldNumber:"2"` Mac codec.Hex `json:"mac" fieldNumber:"3"` KDF string `json:"kdf" fieldNumber:"4"` KDFParams *KDFParams `json:"kdfparams" fieldNumber:"5"` Cipher string `json:"cipher" fieldNumber:"6"` CipherParams *CipherParams `json:"cipherparams" fieldNumber:"7"` }
func EncryptMessageWithPassword ¶
func EncryptMessageWithPassword(message []byte, password string, options *EncryptOptions) (*EncryptedMessage, error)
func (*EncryptedMessage) Decode ¶
func (e *EncryptedMessage) Decode(data []byte) error
func (*EncryptedMessage) DecodeFromReader ¶
func (e *EncryptedMessage) DecodeFromReader(reader *codec.Reader) error
func (*EncryptedMessage) DecodeStrict ¶
func (e *EncryptedMessage) DecodeStrict(data []byte) error
func (*EncryptedMessage) DecodeStrictFromReader ¶
func (e *EncryptedMessage) DecodeStrictFromReader(reader *codec.Reader) error
func (*EncryptedMessage) Encode ¶
func (e *EncryptedMessage) Encode() []byte
func (*EncryptedMessage) MustDecode ¶
func (e *EncryptedMessage) MustDecode(data []byte)
func (EncryptedMessage) String ¶
func (e EncryptedMessage) String() string
func (EncryptedMessage) Validate ¶
func (e EncryptedMessage) Validate() error
type EncryptedPassphrase ¶
type EncryptedPassphrase struct { Iterations int Salt string CipherText string IV string Tag string Version string }
func EncryptPassphraseWithPassword ¶
func EncryptPassphraseWithPassword(passphrase, password string, iteration int) (*EncryptedPassphrase, error)
func ParseEncryptedPassphrase ¶
func ParseEncryptedPassphrase(encryptedPassphrase string) (*EncryptedPassphrase, error)
func (EncryptedPassphrase) String ¶
func (ep EncryptedPassphrase) String() string
type KDFParams ¶
type KDFParams struct { Parallelism uint32 `json:"parallelism" fieldNumber:"1"` Iterations uint32 `json:"iterations" fieldNumber:"2"` MemorySize uint32 `json:"memorySize" fieldNumber:"3"` Salt codec.Hex `json:"salt" fieldNumber:"4"` }
func (*KDFParams) DecodeFromReader ¶
func (*KDFParams) DecodeStrict ¶
func (*KDFParams) DecodeStrictFromReader ¶
func (*KDFParams) MustDecode ¶
Click to show internal directories.
Click to hide internal directories.