Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToScalar(buf []byte) *edwards25519.Scalar
- func CompareConsensusPublicKeyBytes(a, b *PublicKeyBytes) int
- func DeterministicScalar(entropy []byte) *edwards25519.Scalar
- func GenerateTxProofV1(prefixHash types.Hash, txKey PrivateKey, recipientViewPublicKey PublicKey, ...) (derivation PublicKey, signature *Signature)
- func GenerateTxProofV2(prefixHash types.Hash, txKey PrivateKey, recipientViewPublicKey PublicKey, ...) (derivation PublicKey, signature *Signature)
- func GetDerivationSharedDataAndViewTagForOutputIndexNoAllocate(k PublicKeyBytes, outputIndex uint64, hasher *sha3.HasherState) (edwards25519.Scalar, uint8)
- func GetDerivationViewTagForOutputIndex(derivation PublicKey, outputIndex uint64) uint8
- func GetEdwards25519Point() *edwards25519.Point
- func GetEdwards25519Scalar() *edwards25519.Scalar
- func GetKeccak256Hasher() *sha3.HasherState
- func HashFastSum(hash *sha3.HasherState, b []byte) []byte
- func HashToPoint(publicKey PublicKey) *edwards25519.Point
- func HashToScalar(data ...[]byte) *edwards25519.Scalar
- func HashToScalarNoAllocate(data ...[]byte) edwards25519.Scalar
- func HashToScalarNoAllocateSingle(data []byte) edwards25519.Scalar
- func Keccak256(data ...[]byte) (result types.Hash)
- func Keccak256Single(data []byte) (result types.Hash)
- func PooledKeccak256(data ...[]byte) (result types.Hash)
- func PutEdwards25519Point(p *edwards25519.Point)
- func PutEdwards25519Scalar(s *edwards25519.Scalar)
- func PutKeccak256Hasher(h *sha3.HasherState)
- func RandomScalar() *edwards25519.Scalar
- func VerifyMessageSignature(prefixHash types.Hash, publicKey PublicKey, signature *Signature) bool
- func VerifyMessageSignatureSplit(prefixHash types.Hash, commPublicKey, signPublicKey PublicKey, ...) bool
- type BinaryTreeHash
- type KeyPair
- type PrivateKey
- type PrivateKeyBytes
- func (k *PrivateKeyBytes) AsBytes() PrivateKeyBytes
- func (k *PrivateKeyBytes) AsScalar() *PrivateKeyScalar
- func (k *PrivateKeyBytes) AsSlice() PrivateKeySlice
- func (k *PrivateKeyBytes) GetDerivation(public PublicKey) PublicKey
- func (k *PrivateKeyBytes) GetDerivationCofactor(public PublicKey) PublicKey
- func (k *PrivateKeyBytes) MarshalJSON() ([]byte, error)
- func (k *PrivateKeyBytes) PublicKey() PublicKey
- func (k *PrivateKeyBytes) Scan(src any) error
- func (k *PrivateKeyBytes) String() string
- func (k *PrivateKeyBytes) UnmarshalJSON(b []byte) error
- func (k *PrivateKeyBytes) Value() (driver.Value, error)
- type PrivateKeyScalar
- func (p *PrivateKeyScalar) AsBytes() (buf PrivateKeyBytes)
- func (p *PrivateKeyScalar) AsScalar() *PrivateKeyScalar
- func (p *PrivateKeyScalar) AsSlice() PrivateKeySlice
- func (p *PrivateKeyScalar) GetDerivation(public PublicKey) PublicKey
- func (p *PrivateKeyScalar) GetDerivationCofactor(public PublicKey) PublicKey
- func (p *PrivateKeyScalar) MarshalJSON() ([]byte, error)
- func (p *PrivateKeyScalar) PublicKey() PublicKey
- func (p *PrivateKeyScalar) Scalar() *edwards25519.Scalar
- func (p *PrivateKeyScalar) String() string
- func (p *PrivateKeyScalar) UnmarshalJSON(b []byte) error
- type PrivateKeySlice
- func (k *PrivateKeySlice) AsBytes() (buf PrivateKeyBytes)
- func (k *PrivateKeySlice) AsScalar() *PrivateKeyScalar
- func (k *PrivateKeySlice) AsSlice() PrivateKeySlice
- func (k *PrivateKeySlice) GetDerivation(public PublicKey) PublicKey
- func (k *PrivateKeySlice) GetDerivationCofactor(public PublicKey) PublicKey
- func (k *PrivateKeySlice) MarshalJSON() ([]byte, error)
- func (k *PrivateKeySlice) PublicKey() PublicKey
- func (k *PrivateKeySlice) Scan(src any) error
- func (k *PrivateKeySlice) String() string
- func (k *PrivateKeySlice) UnmarshalJSON(b []byte) error
- func (k *PrivateKeySlice) Value() (driver.Value, error)
- type PublicKey
- type PublicKeyBytes
- func (k *PublicKeyBytes) AsBytes() PublicKeyBytes
- func (k *PublicKeyBytes) AsPoint() *PublicKeyPoint
- func (k *PublicKeyBytes) AsSlice() PublicKeySlice
- func (k *PublicKeyBytes) MarshalJSON() ([]byte, error)
- func (k *PublicKeyBytes) Scan(src any) error
- func (k *PublicKeyBytes) String() string
- func (k *PublicKeyBytes) UnmarshalJSON(b []byte) error
- func (k *PublicKeyBytes) Value() (driver.Value, error)
- type PublicKeyPoint
- func (k *PublicKeyPoint) Add(b *PublicKeyPoint) *PublicKeyPoint
- func (k *PublicKeyPoint) AsBytes() (buf PublicKeyBytes)
- func (k *PublicKeyPoint) AsPoint() *PublicKeyPoint
- func (k *PublicKeyPoint) AsSlice() PublicKeySlice
- func (k *PublicKeyPoint) Cofactor() *PublicKeyPoint
- func (k *PublicKeyPoint) MarshalJSON() ([]byte, error)
- func (k *PublicKeyPoint) Multiply(b *PrivateKeyScalar) *PublicKeyPoint
- func (k *PublicKeyPoint) Point() *edwards25519.Point
- func (k *PublicKeyPoint) String() string
- func (k *PublicKeyPoint) Subtract(b *PublicKeyPoint) *PublicKeyPoint
- func (k *PublicKeyPoint) UnmarshalJSON(b []byte) error
- type PublicKeySlice
- func (k *PublicKeySlice) AsBytes() (buf PublicKeyBytes)
- func (k *PublicKeySlice) AsPoint() *PublicKeyPoint
- func (k *PublicKeySlice) AsSlice() PublicKeySlice
- func (k *PublicKeySlice) MarshalJSON() ([]byte, error)
- func (k *PublicKeySlice) Scan(src any) error
- func (k *PublicKeySlice) String() string
- func (k *PublicKeySlice) UnmarshalJSON(b []byte) error
- func (k *PublicKeySlice) Value() (driver.Value, error)
- type Signature
- type SignatureComm
- type SignatureComm_2
- type SignatureComm_2_V1
- type SignatureSigningHandler
- type SignatureVerificationHandler
Constants ¶
const PrivateKeySize = 32
const PublicKeySize = 32
Variables ¶
var TxProofV2DomainSeparatorHash = Keccak256([]byte("TXPROOF_V2")) // HASH_KEY_TXPROOF_V2
Functions ¶
func BytesToScalar ¶
func BytesToScalar(buf []byte) *edwards25519.Scalar
func CompareConsensusPublicKeyBytes ¶
func CompareConsensusPublicKeyBytes(a, b *PublicKeyBytes) int
CompareConsensusPublicKeyBytes Compares public keys in a special consensus specific way
func DeterministicScalar ¶
func DeterministicScalar(entropy []byte) *edwards25519.Scalar
DeterministicScalar consensus way of generating a deterministic scalar from given entropy Slice entropy will have data appended
func GenerateTxProofV1 ¶
func GenerateTxProofV2 ¶
func GetDerivationSharedDataAndViewTagForOutputIndexNoAllocate ¶
func GetDerivationSharedDataAndViewTagForOutputIndexNoAllocate(k PublicKeyBytes, outputIndex uint64, hasher *sha3.HasherState) (edwards25519.Scalar, uint8)
GetDerivationSharedDataAndViewTagForOutputIndexNoAllocate Special version of GetDerivationSharedDataAndViewTagForOutputIndex
func GetEdwards25519Point ¶
func GetEdwards25519Point() *edwards25519.Point
func GetEdwards25519Scalar ¶
func GetEdwards25519Scalar() *edwards25519.Scalar
func GetKeccak256Hasher ¶
func GetKeccak256Hasher() *sha3.HasherState
func HashFastSum ¶
func HashFastSum(hash *sha3.HasherState, b []byte) []byte
HashFastSum sha3.Sum clones the state by allocating memory. prevent that. b must be pre-allocated to the expected size, or larger
func HashToPoint ¶
func HashToPoint(publicKey PublicKey) *edwards25519.Point
func HashToScalar ¶
func HashToScalar(data ...[]byte) *edwards25519.Scalar
func HashToScalarNoAllocate ¶
func HashToScalarNoAllocate(data ...[]byte) edwards25519.Scalar
func HashToScalarNoAllocateSingle ¶
func HashToScalarNoAllocateSingle(data []byte) edwards25519.Scalar
func Keccak256Single ¶
func PooledKeccak256 ¶
func PutEdwards25519Point ¶
func PutEdwards25519Point(p *edwards25519.Point)
func PutEdwards25519Scalar ¶
func PutEdwards25519Scalar(s *edwards25519.Scalar)
func PutKeccak256Hasher ¶
func PutKeccak256Hasher(h *sha3.HasherState)
func RandomScalar ¶
func RandomScalar() *edwards25519.Scalar
func VerifyMessageSignature ¶
Types ¶
type BinaryTreeHash ¶
func (BinaryTreeHash) MainBranch ¶
func (t BinaryTreeHash) MainBranch() (mainBranch []types.Hash)
func (BinaryTreeHash) RootHash ¶
func (t BinaryTreeHash) RootHash() (rootHash types.Hash)
type KeyPair ¶
type KeyPair struct { PrivateKey PrivateKey PublicKey PublicKey }
func NewKeyPairFromPrivate ¶
func NewKeyPairFromPrivate(privateKey PrivateKey) *KeyPair
type PrivateKey ¶
type PrivateKey interface { AsSlice() PrivateKeySlice AsBytes() PrivateKeyBytes AsScalar() *PrivateKeyScalar PublicKey() PublicKey // GetDerivation derives a secret via a peer PublicKey, ECDH GetDerivation(public PublicKey) PublicKey // GetDerivationCofactor derives a secret via a peer PublicKey, ECDH, making sure it is in the proper range (*8) GetDerivationCofactor(public PublicKey) PublicKey String() string UnmarshalJSON(b []byte) error MarshalJSON() ([]byte, error) }
func GetDerivationSharedDataAndViewTagForOutputIndex ¶
func GetDerivationSharedDataAndViewTagForOutputIndex(derivation PublicKey, outputIndex uint64) (PrivateKey, uint8)
func GetDerivationSharedDataForOutputIndex ¶
func GetDerivationSharedDataForOutputIndex(derivation PublicKey, outputIndex uint64) PrivateKey
type PrivateKeyBytes ¶
type PrivateKeyBytes [PrivateKeySize]byte
var ZeroPrivateKeyBytes PrivateKeyBytes
func (*PrivateKeyBytes) AsBytes ¶
func (k *PrivateKeyBytes) AsBytes() PrivateKeyBytes
func (*PrivateKeyBytes) AsScalar ¶
func (k *PrivateKeyBytes) AsScalar() *PrivateKeyScalar
func (*PrivateKeyBytes) AsSlice ¶
func (k *PrivateKeyBytes) AsSlice() PrivateKeySlice
func (*PrivateKeyBytes) GetDerivation ¶
func (k *PrivateKeyBytes) GetDerivation(public PublicKey) PublicKey
func (*PrivateKeyBytes) GetDerivationCofactor ¶
func (k *PrivateKeyBytes) GetDerivationCofactor(public PublicKey) PublicKey
func (*PrivateKeyBytes) MarshalJSON ¶
func (k *PrivateKeyBytes) MarshalJSON() ([]byte, error)
func (*PrivateKeyBytes) PublicKey ¶
func (k *PrivateKeyBytes) PublicKey() PublicKey
func (*PrivateKeyBytes) Scan ¶
func (k *PrivateKeyBytes) Scan(src any) error
func (*PrivateKeyBytes) String ¶
func (k *PrivateKeyBytes) String() string
func (*PrivateKeyBytes) UnmarshalJSON ¶
func (k *PrivateKeyBytes) UnmarshalJSON(b []byte) error
type PrivateKeyScalar ¶
type PrivateKeyScalar edwards25519.Scalar
func PrivateKeyFromScalar ¶
func PrivateKeyFromScalar(scalar *edwards25519.Scalar) *PrivateKeyScalar
func (*PrivateKeyScalar) AsBytes ¶
func (p *PrivateKeyScalar) AsBytes() (buf PrivateKeyBytes)
func (*PrivateKeyScalar) AsScalar ¶
func (p *PrivateKeyScalar) AsScalar() *PrivateKeyScalar
func (*PrivateKeyScalar) AsSlice ¶
func (p *PrivateKeyScalar) AsSlice() PrivateKeySlice
func (*PrivateKeyScalar) GetDerivation ¶
func (p *PrivateKeyScalar) GetDerivation(public PublicKey) PublicKey
func (*PrivateKeyScalar) GetDerivationCofactor ¶
func (p *PrivateKeyScalar) GetDerivationCofactor(public PublicKey) PublicKey
func (*PrivateKeyScalar) MarshalJSON ¶
func (p *PrivateKeyScalar) MarshalJSON() ([]byte, error)
func (*PrivateKeyScalar) PublicKey ¶
func (p *PrivateKeyScalar) PublicKey() PublicKey
func (*PrivateKeyScalar) Scalar ¶
func (p *PrivateKeyScalar) Scalar() *edwards25519.Scalar
func (*PrivateKeyScalar) String ¶
func (p *PrivateKeyScalar) String() string
func (*PrivateKeyScalar) UnmarshalJSON ¶
func (p *PrivateKeyScalar) UnmarshalJSON(b []byte) error
type PrivateKeySlice ¶
type PrivateKeySlice []byte
func (*PrivateKeySlice) AsBytes ¶
func (k *PrivateKeySlice) AsBytes() (buf PrivateKeyBytes)
func (*PrivateKeySlice) AsScalar ¶
func (k *PrivateKeySlice) AsScalar() *PrivateKeyScalar
func (*PrivateKeySlice) AsSlice ¶
func (k *PrivateKeySlice) AsSlice() PrivateKeySlice
func (*PrivateKeySlice) GetDerivation ¶
func (k *PrivateKeySlice) GetDerivation(public PublicKey) PublicKey
func (*PrivateKeySlice) GetDerivationCofactor ¶
func (k *PrivateKeySlice) GetDerivationCofactor(public PublicKey) PublicKey
func (*PrivateKeySlice) MarshalJSON ¶
func (k *PrivateKeySlice) MarshalJSON() ([]byte, error)
func (*PrivateKeySlice) PublicKey ¶
func (k *PrivateKeySlice) PublicKey() PublicKey
func (*PrivateKeySlice) Scan ¶
func (k *PrivateKeySlice) Scan(src any) error
func (*PrivateKeySlice) String ¶
func (k *PrivateKeySlice) String() string
func (*PrivateKeySlice) UnmarshalJSON ¶
func (k *PrivateKeySlice) UnmarshalJSON(b []byte) error
type PublicKey ¶
type PublicKey interface { AsSlice() PublicKeySlice AsBytes() PublicKeyBytes AsPoint() *PublicKeyPoint String() string UnmarshalJSON(b []byte) error MarshalJSON() ([]byte, error) }
func GetKeyImage ¶
type PublicKeyBytes ¶
type PublicKeyBytes [PublicKeySize]byte
var ZeroPublicKeyBytes PublicKeyBytes
func (*PublicKeyBytes) AsBytes ¶
func (k *PublicKeyBytes) AsBytes() PublicKeyBytes
func (*PublicKeyBytes) AsPoint ¶
func (k *PublicKeyBytes) AsPoint() *PublicKeyPoint
func (*PublicKeyBytes) AsSlice ¶
func (k *PublicKeyBytes) AsSlice() PublicKeySlice
func (*PublicKeyBytes) MarshalJSON ¶
func (k *PublicKeyBytes) MarshalJSON() ([]byte, error)
func (*PublicKeyBytes) Scan ¶
func (k *PublicKeyBytes) Scan(src any) error
func (*PublicKeyBytes) String ¶
func (k *PublicKeyBytes) String() string
func (*PublicKeyBytes) UnmarshalJSON ¶
func (k *PublicKeyBytes) UnmarshalJSON(b []byte) error
type PublicKeyPoint ¶
type PublicKeyPoint edwards25519.Point
func PublicKeyFromPoint ¶
func PublicKeyFromPoint(point *edwards25519.Point, _ ...any) *PublicKeyPoint
func (*PublicKeyPoint) Add ¶
func (k *PublicKeyPoint) Add(b *PublicKeyPoint) *PublicKeyPoint
func (*PublicKeyPoint) AsBytes ¶
func (k *PublicKeyPoint) AsBytes() (buf PublicKeyBytes)
func (*PublicKeyPoint) AsPoint ¶
func (k *PublicKeyPoint) AsPoint() *PublicKeyPoint
func (*PublicKeyPoint) AsSlice ¶
func (k *PublicKeyPoint) AsSlice() PublicKeySlice
func (*PublicKeyPoint) Cofactor ¶
func (k *PublicKeyPoint) Cofactor() *PublicKeyPoint
func (*PublicKeyPoint) MarshalJSON ¶
func (k *PublicKeyPoint) MarshalJSON() ([]byte, error)
func (*PublicKeyPoint) Multiply ¶
func (k *PublicKeyPoint) Multiply(b *PrivateKeyScalar) *PublicKeyPoint
func (*PublicKeyPoint) Point ¶
func (k *PublicKeyPoint) Point() *edwards25519.Point
func (*PublicKeyPoint) String ¶
func (k *PublicKeyPoint) String() string
func (*PublicKeyPoint) Subtract ¶
func (k *PublicKeyPoint) Subtract(b *PublicKeyPoint) *PublicKeyPoint
func (*PublicKeyPoint) UnmarshalJSON ¶
func (k *PublicKeyPoint) UnmarshalJSON(b []byte) error
type PublicKeySlice ¶
type PublicKeySlice []byte
func (*PublicKeySlice) AsBytes ¶
func (k *PublicKeySlice) AsBytes() (buf PublicKeyBytes)
func (*PublicKeySlice) AsPoint ¶
func (k *PublicKeySlice) AsPoint() *PublicKeyPoint
func (*PublicKeySlice) AsSlice ¶
func (k *PublicKeySlice) AsSlice() PublicKeySlice
func (*PublicKeySlice) MarshalJSON ¶
func (k *PublicKeySlice) MarshalJSON() ([]byte, error)
func (*PublicKeySlice) Scan ¶
func (k *PublicKeySlice) Scan(src any) error
func (*PublicKeySlice) String ¶
func (k *PublicKeySlice) String() string
func (*PublicKeySlice) UnmarshalJSON ¶
func (k *PublicKeySlice) UnmarshalJSON(b []byte) error
type Signature ¶
type Signature struct { // C hash of data in signature, also called e C *edwards25519.Scalar // R result of the signature, also called s R *edwards25519.Scalar }
Signature Schnorr signature
func CreateMessageSignature ¶
func CreateMessageSignature(prefixHash types.Hash, key PrivateKey) *Signature
func CreateSignature ¶
func CreateSignature(handler SignatureSigningHandler, privateKey PrivateKey) *Signature
CreateSignature produces a Schnorr Signature using H = keccak
func NewSignatureFromBytes ¶
func (*Signature) Verify ¶
func (s *Signature) Verify(handler SignatureVerificationHandler, publicKey PublicKey) (ok bool, r *PublicKeyPoint)
Verify checks a Schnorr Signature using H = keccak
type SignatureComm ¶
SignatureComm Used in normal message signatures
func (*SignatureComm) Bytes ¶
func (s *SignatureComm) Bytes() []byte
type SignatureComm_2 ¶
type SignatureComm_2 struct { Message types.Hash // KeyDerivation D KeyDerivation PublicKey // RandomPublicKey X RandomPublicKey PublicKey // RandomDerivation Y RandomDerivation PublicKey // Separator Domain Separation Separator types.Hash // TransactionPublicKey R TransactionPublicKey PublicKey // RecipientViewPublicKey A RecipientViewPublicKey PublicKey RecipientSpendPublicKey PublicKey }
SignatureComm_2 Used in v1/v2 tx proofs
func (*SignatureComm_2) Bytes ¶
func (s *SignatureComm_2) Bytes() []byte
type SignatureComm_2_V1 ¶
type SignatureComm_2_V1 struct { Message types.Hash // KeyDerivation D KeyDerivation PublicKey // RandomPublicKey X RandomPublicKey PublicKey // RandomDerivation Y RandomDerivation PublicKey }
SignatureComm_2_V1 Used in v1 tx proofs
func (*SignatureComm_2_V1) Bytes ¶
func (s *SignatureComm_2_V1) Bytes() []byte
type SignatureSigningHandler ¶
type SignatureSigningHandler func(r PrivateKey) []byte
SignatureSigningHandler receives k, inserts it or a pubkey into its data, and produces a []byte buffer for Signing/Verifying
type SignatureVerificationHandler ¶
SignatureVerificationHandler receives r = pubkey(k), inserts it into its data, and produces a []byte buffer for Signing/Verifying