bulletproofs_cgo

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const ERR_INTERNAL_ERROR = -3
View Source
const ERR_INVALID_INPUT = -2
View Source
const ERR_INVALID_PROOF = -1
View Source
const ERR_MSG_DEFAULT = "unknown error"
View Source
const ERR_MSG_INVALID_INPUT = "wrong input data format"
View Source
const ERR_MSG_INVALID_PROOF = "invalid proof"
View Source
const ERR_MSG_NULL_INPUT = "input is null"
View Source
const ERR_NULL_INPUT = -4
View Source
const OK = 0
View Source
const POINT_SIZE = 32
View Source
const SINGLE_PROOF_SIZE = 672

Variables

This section is empty.

Functions

func PedersenAddCommitment

func PedersenAddCommitment(commitment1, commitment2 []byte) ([]byte, error)

PedersenAddCommitment Compute a commitment to x + y from commitments to x and y, without revealing the value x and y commitment1: commitment to x: Cx = xB + rB' commitment2: commitment to y: Cy = yB + sB' return: commitment to x + y: C = (x + y)B + (r + s)B'

func PedersenAddCommitmentWithOpening

func PedersenAddCommitmentWithOpening(commitment1, commitment2, opening1, opening2 []byte) ([]byte, []byte, error)

PedersenAddCommitmentWithOpening Compute a commitment to x + y without revealing the value x and y commitment1: commitment to x: Cx = xB + rB' commitment2: commitment to y: Cy = yB + sB' return1: the new commitment to x + y: C' = (x + y)B + rB' return2: the new opening r + s

func PedersenAddNum

func PedersenAddNum(commitment []byte, value uint64) ([]byte, error)

PedersenAddNum Compute a commitment to x + y from a commitment to x without revealing the value x, where y is a scalar commitment: C = xB + rB' value: the value y return1: the new commitment to x + y: C' = (x + y)B + rB'

func PedersenAddOpening

func PedersenAddOpening(opening1, opening2 []byte) ([]byte, error)

PedersenAddOpening Compute the sum of two openings. Openings are big numbers with 256 bits. opening1, opening2: the two openings r and s to be summed return: the result opening: r + s

func PedersenCommitRandomOpening

func PedersenCommitRandomOpening(x uint64) ([]byte, []byte, error)

PedersenCommitRandomOpening compute Pedersen commitment on a value x with a randomly chosen opening x: the value to commit return1: commitment C = xB + rB' return2: opening r (randomly picked)

func PedersenCommitSpecificOpening

func PedersenCommitSpecificOpening(x uint64, r []byte) ([]byte, error)

PedersenCommitSpecificOpening compute Pedersen commitment on a value x with a given opening x: the value to commit return1: commitment C = xB + rB'

func PedersenMulNum

func PedersenMulNum(commitment1 []byte, value uint64) ([]byte, error)

PedersenMulNum Compute a commitment to x * y from a commitment to x and an integer y, without revealing the value x and y commitment1: commitment to x: Cx = xB + rB' value: integer value y return: commitment to x * y: C = (x * y)B + (r * y)B'

func PedersenMulNumWithOpening

func PedersenMulNumWithOpening(commitment []byte, opening []byte, value uint64) ([]byte, []byte, error)

PedersenMulNumWithOpening Compute a commitment to x * y from a commitment to x and an integer y, without revealing the value x and y commitment: commitment to x: Cx = xB + rB' opening: opening to Cx: r value: integer value y return1: commitment to x * y: C = (x * y)B + (r * y)B' return2: opening to the result commitment: r * y

func PedersenMulOpening

func PedersenMulOpening(opening1 []byte, value uint64) ([]byte, error)

PedersenMulOpening Compute opening1 * integer. Openings are big numbers with 256 bits. opening1: the input opening r value: the input integer value y return: the multiplication r * y as a big number with 256 bits in []byte form

func PedersenNeg

func PedersenNeg(commitment []byte) ([]byte, error)

PedersenNeg Compute a commitment to -x from a commitment to x without revealing the value x commitment: C = xB + rB' value: the value y return1: the new commitment to x + y: C' = (x + y)B + rB'

func PedersenNegOpening

func PedersenNegOpening(opening []byte) ([]byte, error)

PedersenNegOpening Compute the negation of opening. Openings are big numbers with 256 bits. opening: the opening r to be negated return: the result opening: -r

func PedersenRNG

func PedersenRNG() ([]byte, error)

PedersenRNG generate a truly random scalar (which can be used as an opening to generate a commitment). return: a random scalar in []byte format

func PedersenSubCommitment

func PedersenSubCommitment(commitment1, commitment2 []byte) ([]byte, error)

PedersenSubCommitment Compute a commitment to x - y from commitments to x and y, without revealing the value x and y commitment1: commitment to x: Cx = xB + rB' commitment2: commitment to y: Cy = yB + sB' return: commitment to x - y: C = (x - y)B + (r - s)B'

func PedersenSubCommitmentWithOpening

func PedersenSubCommitmentWithOpening(commitment1, commitment2, opening1, opening2 []byte) ([]byte, []byte, error)

PedersenSubCommitmentWithOpening Compute a commitment to x - y without from two commitments of x and y respectively commitment1: commitment to x: Cx = xB + rB' commitment2: commitment to y: Cy = yB + sB' return1: the new commitment to x - y: C' = (x - y)B + (r - s)B' return2: the new opening r - s

func PedersenSubNum

func PedersenSubNum(commitment []byte, value uint64) ([]byte, error)

PedersenSubNum Compute a commitment to x - y from a commitment to x without revealing the value x, where y is a scalar commitment: C = xB + rB' value: the value y return1: the new commitment to x - y: C' = (x - y)B + rB'

func PedersenSubOpening

func PedersenSubOpening(opening1, opening2 []byte) ([]byte, error)

PedersenSubOpening Compute opening1 - opening2. Openings are big numbers with 256 bits. opening1, opening2: two openings r and s return: the result opening r - s

func PedersenVerify

func PedersenVerify(commitment, opening []byte, value uint64) (bool, error)

PedersenVerify verify the validity of a commitment with respect to a value-opening pair commitment: the commitment to be opened or verified: xB + rB' opening: the opening of the commitment: r value: the value claimed being binding to commitment: x return1: true if commitment is valid, false otherwise

func ProveAfterAddCommitment

func ProveAfterAddCommitment(x, y uint64, openingX, openingY, commitmentX, commitmentY []byte) ([]byte, []byte, []byte, error)

ProveAfterAddCommitment Update commitments of x (xB + rB') and y (yB + sB') to x + y and generate a proof of it with the sum of the two opening x, y: prove x + y is in the range [0, 2^64) openingX: the randomness r used to commit x openingY: the randomness s used to commit y commitmentX: commitment of x: xB + rB' commitmentX: commitment of y: yB + sB' return 1: proof in []byte return 2: commitment of x + y: (x + y)B + (r + s)B' return 3: new opening for the result commitment (r + s)

func ProveAfterAddNum

func ProveAfterAddNum(x, y uint64, openingX, commitmentX []byte) ([]byte, []byte, error)

ProveAfterAddNum Update a commitment of x (xB + rB') to x + y and generate a proof of it with the same opening x, y: prove x + y is in the range [0, 2^64) openingX: the randomness r used to commit x, also used in the new proof commitmentX: commitment of x: xB + rB' return 1: proof in []byte return 2: commitment of x + y: (x + y)B + rB'

func ProveAfterMulNum

func ProveAfterMulNum(x, y uint64, openingX, commitmentX []byte) ([]byte, []byte, []byte, error)

ProveAfterMulNum Update commitment of x (xB + rB') to commitment of x * y and generate a proof of it with the an updated opening, where y is a value x, y: prove x * y is in the range [0, 2^64) openingX: the randomness r used to commit x commitmentX: commitment of x: xB + rB' return 1: proof in []byte return 2: commitment of x * y: (x * y)B + (r * y)B' return 3: new opening for the result commitment: r * y

func ProveAfterSubCommitment

func ProveAfterSubCommitment(x, y uint64, openingX, openingY, commitmentX, commitmentY []byte) ([]byte, []byte, []byte, error)

ProveAfterSubCommitment Update commitments of x (xB + rB') and y (yB + sB') to x - y and generate a proof of it with the subtraction of the two openings x, y: prove x + y is in the range [0, 2^64) openingX: the randomness r used to commit x openingY: the randomness s used to commit y commitmentX: commitment of x: xB + rB' commitmentX: commitment of y: yB + sB' return 1: proof in []byte return 2: commitment of x - y: (x - y)B + (r - s)B' return 3: new opening for the result commitment (r - s)

func ProveAfterSubNum

func ProveAfterSubNum(x, y uint64, openingX, commitmentX []byte) ([]byte, []byte, error)

ProveAfterSubNum Update a commitment of x (xB + rB') to x - y and generate a proof of it with the same opening x, y: prove x - y is in the range [0, 2^64) openingX: the randomness r used to commit x, also used in the new proof commitmentX: commitment of x (old commitment) return 1: proof in []byte return 2: commitment of x - y: (x - y)B + rB'

func ProveRandomOpening

func ProveRandomOpening(x uint64) ([]byte, []byte, []byte, error)

ProveRandomOpening Generate proof with randomly pick opening x: prove x is in the range [0, 2^64) return 1: proof in []byte return 2: commitment of x: xB + rB' return 3: opening, the randomness r used to commit x (secret key)

func ProveSpecificOpening

func ProveSpecificOpening(x uint64, opening []byte) ([]byte, []byte, error)

ProveSpecificOpening Generate proof with a chosen opening x: prove x is in the range [0, 2^64) opening: the chosen randomness to commit x (secret key) return 1: proof in []byte return 2: commitment of x using opening

func Verify

func Verify(proof []byte, commitment []byte) (bool, error)

Verify Verify the validity of a proof proof: the zero-knowledge proof proving the number committed in commitment is in the range [0, 2^64) commitment: commitment bindingly hiding the number x return: true on valid proof, false otherwise

Types

This section is empty.

Jump to

Keyboard shortcuts

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