crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxOrder = 64

Variables

This section is empty.

Functions

func DecryptAESGCM added in v0.1.9

func DecryptAESGCM(key, ciphertext []byte) ([]byte, error)

DecryptAESGCM decrypts the ciphertext using AES-GCM with the provided key. The function expects the input ciphertext to include the nonce. It returns the decrypted plaintext or an error if the decryption fails. AES-GCM provides both confidentiality and integrity.

func EncryptAESGCM added in v0.1.9

func EncryptAESGCM(key, plaintext []byte) ([]byte, error)

EncryptAESGCM encrypts the plaintext using AES-GCM with the provided key. The function returns the ciphertext, which includes the nonce. The nonce is randomly generated for each encryption and is used for ensuring uniqueness. AES-GCM provides both confidentiality and integrity.

func FirstStepAlice

func FirstStepAlice(secretMessage string, r *secp256k1.PrivateKey) (*secp256k1.PublicKey, *secp256k1.PrivateKey)

FirstStepAlice creates blinded secrets and produces outputs

func GetKeySetPublicKeys added in v0.1.7

func GetKeySetPublicKeys(keySet *KeySet) map[uint64]string

GetKeySetPublicKeys will return current public keys for all amounts

func HashToCurve

func HashToCurve(secretMessage []byte) *secp256k1.PublicKey

HashToCurve will generate a public key on the curve.

func LegacyHashToCurve

func LegacyHashToCurve(secretMessage []byte) *secp256k1.PublicKey

backwards compatibility with old hash_to_curve < 0.3.3 LegacyHashToCurve will generate a public key on the curve.

func SecondStepBob

func SecondStepBob(B_ secp256k1.PublicKey, a secp256k1.PrivateKey) *secp256k1.PublicKey

SecondStepBob signs blinded secrets and produces promises

func ThirdStepAlice

func ThirdStepAlice(c_ secp256k1.PublicKey, r secp256k1.PrivateKey, A secp256k1.PublicKey) *secp256k1.PublicKey

ThirdStepAlice Alice unbinds blinded signatures and produces proofs

func Verify

func Verify(a secp256k1.PrivateKey, c secp256k1.PublicKey, secretMessage string, curveFunc func(msg []byte) *secp256k1.PublicKey) bool

Verify that secret was signed by bob. curveFunc should be legacyHashToCurve for client version < 0.3.3 this could be removed and replaced with static invocation of hashToCurve

Types

type KeySet

type KeySet struct {
	Id             string `gorm:"primaryKey"`
	DerivationPath string
	PublicKeys     PublicKeyList  `gorm:"-"`
	PrivateKeys    PrivateKeyList `gorm:"-"`
	MintUrl        string
	ValidFrom      time.Time
	ValidTo        time.Time
	FirstSeen      time.Time
	Active         bool
}

func NewKeySet

func NewKeySet(masterKey, derivationPath string) *KeySet

func (*KeySet) DeriveKeySetId

func (k *KeySet) DeriveKeySetId()

func (*KeySet) DeriveKeys

func (k *KeySet) DeriveKeys(masterKey string)

func (*KeySet) DerivePublicKeys

func (k *KeySet) DerivePublicKeys()

func (*KeySet) SetPublicKeyList added in v0.1.7

func (k *KeySet) SetPublicKeyList(keys map[uint64]*secp256k1.PublicKey)

type PrivateKey

type PrivateKey struct {
	Amount uint64
	Key    *secp256k1.PrivateKey
}

type PrivateKeyList

type PrivateKeyList []PrivateKey

func (PrivateKeyList) GetKeyByAmount

func (s PrivateKeyList) GetKeyByAmount(amount uint64) *PrivateKey

func (PrivateKeyList) Len

func (p PrivateKeyList) Len() int

func (PrivateKeyList) Less

func (p PrivateKeyList) Less(i, j int) bool

func (PrivateKeyList) Swap

func (p PrivateKeyList) Swap(i, j int)

type PublicKey

type PublicKey struct {
	Amount uint64
	Key    *secp256k1.PublicKey
}

type PublicKeyList

type PublicKeyList []PublicKey

func (PublicKeyList) GetKeyByAmount

func (s PublicKeyList) GetKeyByAmount(amount uint64) *PublicKey

func (PublicKeyList) Len

func (s PublicKeyList) Len() int

func (PublicKeyList) Less

func (s PublicKeyList) Less(i, j int) bool

func (PublicKeyList) Swap

func (s PublicKeyList) Swap(i, j int)

Jump to

Keyboard shortcuts

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