Documentation ¶
Overview ¶
Package crypto implements the cryptography used in the Cashu protocol as explained in Cashu.
Index ¶
- Constants
- func BlindMessage(secret string, r *secp256k1.PrivateKey) (*secp256k1.PublicKey, *secp256k1.PrivateKey, error)
- func DeriveKeysetId(keyset map[uint64]*secp256k1.PublicKey) string
- func DeriveKeysetPath(key *hdkeychain.ExtendedKey, index uint32) (*hdkeychain.ExtendedKey, error)
- func GenerateDLEQ(a *secp256k1.PrivateKey, B_ *secp256k1.PublicKey, C_ *secp256k1.PublicKey) (*secp256k1.PrivateKey, *secp256k1.PrivateKey)
- func HashE(publicKeys []*secp256k1.PublicKey) [32]byte
- func HashToCurve(message []byte) (*secp256k1.PublicKey, error)
- func MapPubKeys(keys nut01.KeysMap) (map[uint64]*secp256k1.PublicKey, error)
- func SignBlindedMessage(B_ *secp256k1.PublicKey, k *secp256k1.PrivateKey) *secp256k1.PublicKey
- func UnblindSignature(C_ *secp256k1.PublicKey, r *secp256k1.PrivateKey, K *secp256k1.PublicKey) *secp256k1.PublicKey
- func Verify(secret string, k *secp256k1.PrivateKey, C *secp256k1.PublicKey) bool
- func VerifyDLEQ(e *secp256k1.PrivateKey, s *secp256k1.PrivateKey, A *secp256k1.PublicKey, ...) bool
- type KeyPair
- type KeyPairTemp
- type KeysetTemp
- type KeysetsMap
- type MintKeyset
- type WalletKeyset
- type WalletKeysetTemp
Constants ¶
const DomainSeparator = "Secp256k1_HashToCurve_Cashu_"
const MAX_ORDER = 60
Variables ¶
This section is empty.
Functions ¶
func BlindMessage ¶
func BlindMessage(secret string, r *secp256k1.PrivateKey) (*secp256k1.PublicKey, *secp256k1.PrivateKey, error)
B_ = Y + rG
func DeriveKeysetId ¶
DeriveKeysetId returns the string ID derived from the map keyset The steps to derive the ID are: - sort public keys by their amount in ascending order - concatenate all public keys to one byte array - HASH_SHA256 the concatenated public keys - take the first 14 characters of the hex-encoded hash - prefix it with a keyset ID version byte
func DeriveKeysetPath ¶ added in v0.2.0
func DeriveKeysetPath(key *hdkeychain.ExtendedKey, index uint32) (*hdkeychain.ExtendedKey, error)
func GenerateDLEQ ¶ added in v0.3.0
func GenerateDLEQ( a *secp256k1.PrivateKey, B_ *secp256k1.PublicKey, C_ *secp256k1.PublicKey, ) (*secp256k1.PrivateKey, *secp256k1.PrivateKey)
func HashToCurve ¶
The domain separator is b"Secp256k1_HashToCurve_Cashu_" or bytes.fromhex("536563703235366b315f48617368546f43757276655f43617368755f").
func MapPubKeys ¶ added in v0.2.0
func SignBlindedMessage ¶
func SignBlindedMessage(B_ *secp256k1.PublicKey, k *secp256k1.PrivateKey) *secp256k1.PublicKey
C_ = kB_
func UnblindSignature ¶
func UnblindSignature(C_ *secp256k1.PublicKey, r *secp256k1.PrivateKey, K *secp256k1.PublicKey) *secp256k1.PublicKey
C = C_ - rK
func VerifyDLEQ ¶ added in v0.3.0
func VerifyDLEQ( e *secp256k1.PrivateKey, s *secp256k1.PrivateKey, A *secp256k1.PublicKey, B_ *secp256k1.PublicKey, C_ *secp256k1.PublicKey, ) bool
Types ¶
type KeyPair ¶
type KeyPair struct { PrivateKey *secp256k1.PrivateKey PublicKey *secp256k1.PublicKey }
func (*KeyPair) MarshalJSON ¶
func (*KeyPair) UnmarshalJSON ¶
type KeyPairTemp ¶
type KeysetTemp ¶
type KeysetsMap ¶
type KeysetsMap map[string]map[string]WalletKeyset
KeysetsMap maps a mint url to map of string keyset id to keyset
type MintKeyset ¶ added in v0.2.0
type MintKeyset struct { Id string Unit string Active bool DerivationPathIdx uint32 Keys map[uint64]KeyPair InputFeePpk uint }
func GenerateKeyset ¶
func GenerateKeyset(master *hdkeychain.ExtendedKey, index uint32, inputFeePpk uint) (*MintKeyset, error)
func (*MintKeyset) DerivePublic ¶ added in v0.2.0
func (ks *MintKeyset) DerivePublic() map[uint64]string
DerivePublic returns the keyset's public keys as a map of amounts uint64 to strings that represents the public key
func (*MintKeyset) MarshalJSON ¶ added in v0.2.0
func (ks *MintKeyset) MarshalJSON() ([]byte, error)
func (*MintKeyset) UnmarshalJSON ¶ added in v0.2.0
func (ks *MintKeyset) UnmarshalJSON(data []byte) error
type WalletKeyset ¶ added in v0.2.0
type WalletKeyset struct { Id string MintURL string Unit string Active bool PublicKeys map[uint64]*secp256k1.PublicKey Counter uint32 InputFeePpk uint }
func (*WalletKeyset) MarshalJSON ¶ added in v0.2.0
func (wk *WalletKeyset) MarshalJSON() ([]byte, error)
func (*WalletKeyset) UnmarshalJSON ¶ added in v0.2.0
func (wk *WalletKeyset) UnmarshalJSON(data []byte) error