confidential

package
v0.0.0-...-53dc9a8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPrivKeyMult         = errors.New("privKey mult error")
	ErrPrivKeyTweakAdd     = errors.New("privKey tweak add error")
	ErrPrivKeyNegate       = errors.New("privKey negate error")
	ErrInvalidValueBlinder = errors.New("invalid value blinder")
)
View Source
var (
	Zero = make([]byte, 32)
)

Functions

func AssetCommitment

func AssetCommitment(asset, factor []byte) ([]byte, error)

AssetCommitment method generates asset commitment

func CalculateScalarOffset

func CalculateScalarOffset(
	amount uint64, assetBlinder, valueBlinder []byte,
) ([]byte, error)

CalculateScalarOffset computes the scalar offset used for the final blinder computation value * asset_blinder + value_blinder

func ComputeAndAddToScalarOffset

func ComputeAndAddToScalarOffset(
	scalar []byte, value uint64, assetBlinder, valueBlinder []byte,
) ([]byte, error)

ComputeAndAddToScalarOffset computes a scalar offset and adds it to another existing one

func CreateBlindAssetProof

func CreateBlindAssetProof(
	asset, assetCommitment, assetBlinder []byte,
) ([]byte, error)

func CreateBlindValueProof

func CreateBlindValueProof(
	rng func() ([]byte, error),
	valueBlinder []byte, amount uint64, valueCommitment, assetCommitment []byte,
) ([]byte, error)

func FinalValueBlindingFactor

func FinalValueBlindingFactor(
	args FinalValueBlindingFactorArgs,
) ([32]byte, error)

FinalValueBlindingFactor method calculates the blinder as the sum of all previous blinders of a tx.

func NewZKPGeneratorFromBlindingKeys

func NewZKPGeneratorFromBlindingKeys(
	inBlindingKeys [][]byte, opts *ZKPGeneratorOpts,
) *zkpGenerator

func NewZKPGeneratorFromMasterBlindingKey

func NewZKPGeneratorFromMasterBlindingKey(
	masterBlindingKey []byte, opts *ZKPGeneratorOpts,
) (*zkpGenerator, error)

func NewZKPGeneratorFromOwnedInputs

func NewZKPGeneratorFromOwnedInputs(
	ownedInputs map[uint32]psetv2.OwnedInput, opts *ZKPGeneratorOpts,
) (*zkpGenerator, error)

func NewZKPValidator

func NewZKPValidator() *zkpValidator

func NonceHash

func NonceHash(pubKey, privKey []byte) ([32]byte, error)

NonceHash method generates hashed secret based on ecdh.

func RangeProof

func RangeProof(args RangeProofArgs) ([]byte, error)

RangeProof method calculates range proof

func SubtractScalars

func SubtractScalars(a []byte, b []byte) ([]byte, error)

SubtractScalars subtract b from a in place

func SurjectionProof

func SurjectionProof(args SurjectionProofArgs) ([]byte, bool)

SurjectionProof method generates surjection proof

func ValueCommitment

func ValueCommitment(value uint64, generator, factor []byte) ([]byte, error)

ValueCommitment method generates value commitment

func VerifyBlindAssetProof

func VerifyBlindAssetProof(asset, assetCommitment, proof []byte) bool

func VerifyBlindValueProof

func VerifyBlindValueProof(
	value uint64, valueCommitment, assetCommitment, proof []byte,
) bool

func VerifyRangeProof

func VerifyRangeProof(valueCommitment, assetCommitment, script, proof []byte) bool

func VerifySurjectionProof

func VerifySurjectionProof(args VerifySurjectionProofArgs) bool

VerifySurjectionProof method verifies the validity of a surjection proof

Types

type FinalValueBlindingFactorArgs

type FinalValueBlindingFactorArgs struct {
	InValues      []uint64
	OutValues     []uint64
	InGenerators  [][]byte
	OutGenerators [][]byte
	InFactors     [][]byte
	OutFactors    [][]byte
}

FinalValueBlindingFactorArgs is the type provided to the function that calculates the blinder of the last output of a tx.

type RandomNumberGenerator

type RandomNumberGenerator func() ([]byte, error)

type RangeProofArgs

type RangeProofArgs struct {
	Value               uint64
	Nonce               [32]byte
	Asset               []byte
	AssetBlindingFactor []byte
	ValueBlindFactor    [32]byte
	ValueCommit         []byte
	ScriptPubkey        []byte
	Exp                 int
	MinBits             int
}

type SurjectionProofArgs

type SurjectionProofArgs struct {
	OutputAsset               []byte
	OutputAssetBlindingFactor []byte
	InputAssets               [][]byte
	InputAssetBlindingFactors [][]byte
	Seed                      []byte
	NumberOfTargets           int
}

type UnblindIssuanceResult

type UnblindIssuanceResult struct {
	Asset *UnblindOutputResult
	Token *UnblindOutputResult
}

func UnblindIssuance

func UnblindIssuance(
	in *transaction.TxInput, blindKeys [][]byte,
) (*UnblindIssuanceResult, error)

type UnblindOutputResult

type UnblindOutputResult struct {
	Value               uint64
	Asset               []byte
	ValueBlindingFactor []byte
	AssetBlindingFactor []byte
}

UnblindOutputResult is the type returned by the functions that unblind tx outs. It contains the unblinded asset and value and also the respective blinding factors.

func UnblindOutputWithKey

func UnblindOutputWithKey(
	out *transaction.TxOutput, blindKey []byte,
) (*UnblindOutputResult, error)

UnblindOutputWithKey method unblinds a confidential transaction output with the given blinding private key.

func UnblindOutputWithNonce

func UnblindOutputWithNonce(
	out *transaction.TxOutput, nonce []byte,
) (*UnblindOutputResult, error)

UnblindOutputWithNonce method unblinds a confidential transaction output with the given ecdh nonce calculated for example with the above NonceHash func.

type VerifySurjectionProofArgs

type VerifySurjectionProofArgs struct {
	InputAssets               [][]byte
	InputAssetBlindingFactors [][]byte
	OutputAsset               []byte
	OutputAssetBlindingFactor []byte
	Proof                     []byte
}

type ZKPGeneratorOpts

type ZKPGeneratorOpts struct {
	Rng RandomNumberGenerator
}

Jump to

Keyboard shortcuts

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