Documentation ¶
Overview ¶
The puzzle package implements cryptographic primitives to generate, conceal (blind) and solve puzzles required by the TumbleBit protocol.
Index ¶
- func BlindPuzzle(pk *PuzzlePubKey, p []byte) ([]byte, []byte, []byte, error)
- func DecodeIndexList(indexList []byte) ([]int, error)
- func EncodeIndexList(indexList []int) ([]byte, error)
- func FakeTxFormat(randomPad []byte) []byte
- func HashIndexList(salt []byte, indexList []int) ([]byte, error)
- func MarshalPubKey(pk *PuzzleKey) ([]byte, error)
- func NewPuzzlePromise(pk *PuzzleKey, sig []byte) ([]byte, []byte, []byte, error)
- func NewSolutionPromise(pk *PuzzleKey, p []byte) ([]byte, []byte, []byte, error)
- func Quotients(pk *PuzzlePubKey, secrets [][]byte) ([][]byte, error)
- func RevealSolution(promise []byte, secret []byte) ([]byte, error)
- func SolvePuzzle(pk *PuzzleKey, p []byte) ([]byte, error)
- func UnblindPuzzle(pk *PuzzlePubKey, p []byte, r []byte) []byte
- func ValidateBlindedPuzzle(pk *PuzzlePubKey, blinding, puzzle []byte, secret []byte) bool
- func ValidatePuzzle(pk *PuzzlePubKey, puzzle, secret []byte) bool
- func VerifyQuotients(pk *PuzzlePubKey, qs [][]byte, puzzles [][]byte) bool
- func VerifyQuotientsWithSecrets(pk *PuzzlePubKey, qs [][]byte, secrets [][]byte) bool
- type PuzzleKey
- type PuzzlePubKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlindPuzzle ¶
BlindPuzzle generates a random factor and returns a product of the puzzle p and the factor as well as the multiplicative inverse of the factor suitable for UnblindPuzzle.
func DecodeIndexList ¶
DecodeIndexList decodes a buffer containing a series of 16 bit little endian values into a slice of integers.
func EncodeIndexList ¶
EncodeIndexList encodes a slice of integer values that can be represented by a uint16 type in a series of 16 bit little endian values.
func FakeTxFormat ¶
FakeTxFormat generates a hash value for a transaction dummy with a known structure so that it can be verified given the knowledge of a random pad.
func HashIndexList ¶
HashIndexList produces a salted cryptographic hash value of a binary encoded index list.
func MarshalPubKey ¶
func NewPuzzlePromise ¶
func NewSolutionPromise ¶
NewSolutionPromise recovers a solution to the puzzle p and generates a promise that puzzle p opens up to this solution.
func Quotients ¶
func Quotients(pk *PuzzlePubKey, secrets [][]byte) ([][]byte, error)
Quotients returns an slice of quotients, where i'th value is calculated as secret[i] divided by secret[i-1], effectively chaining them together.
func SolvePuzzle ¶
SolvePuzzle decrypts the puzzle p using the private key pk.
func UnblindPuzzle ¶
func UnblindPuzzle(pk *PuzzlePubKey, p []byte, r []byte) []byte
UnblindPuzzle recovers the original value of the puzzle by muliplying it with an inverse obtained from BlindedPuzzle.
func ValidateBlindedPuzzle ¶
func ValidateBlindedPuzzle(pk *PuzzlePubKey, blinding, puzzle []byte, secret []byte) bool
ValidateBlindedPuzzle makes sure that the encrypted secret is a correct blinding factor for the puzzle with the provided public key pk. Essentially this checks that blinding = puzzle * secret^e.
func ValidatePuzzle ¶
func ValidatePuzzle(pk *PuzzlePubKey, puzzle, secret []byte) bool
ValidatePuzzle makes sure that secret encrypts to the same value as the puzzle with the provided public key pk.
func VerifyQuotients ¶
func VerifyQuotients(pk *PuzzlePubKey, qs [][]byte, puzzles [][]byte) bool
VerifyQuotients verifies that quotients are constructed correctly by making sure that i'th puzzle can be recovered as a product of a preceding puzzle and i'th quotient raised to the power of e. In other words, each quotient becomes a blinding factor linking puzzles together.
func VerifyQuotientsWithSecrets ¶
func VerifyQuotientsWithSecrets(pk *PuzzlePubKey, qs [][]byte, secrets [][]byte) bool
VerifyQuotientsWithSecrets verifies that quotients are constructed correctly by making sure that i'th secret can be recovered as a product of preceding quotient values.
Types ¶
type PuzzleKey ¶
type PuzzleKey struct {
// contains filtered or unexported fields
}
func GeneratePuzzleKey ¶
func (*PuzzleKey) PublicKey ¶
func (pk *PuzzleKey) PublicKey() *PuzzlePubKey
type PuzzlePubKey ¶
func ParsePubKey ¶
func ParsePubKey(pub []byte) (PuzzlePubKey, error)