-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitment.go
145 lines (125 loc) · 5.92 KB
/
commitment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
Copyright (C) BABEC. All rights reserved.
Copyright (C) THL A29 Limited, a Tencent company. All rights reserved.
SPDX-License-Identifier: Apache-2.0
*/
package bulletproofs_nocgo
import "C"
// 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 PedersenRNG() ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenCommitRandomOpening(x uint64) ([]byte, []byte, error) {
return nil, nil, ErrUnsupported
}
// PedersenCommitSpecificOpening compute Pedersen commitment on a value x with a given opening
// x: the value to commit
// return1: commitment C = xB + rB'
func PedersenCommitSpecificOpening(x uint64, r []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenVerify(commitment, opening []byte, value uint64) (bool, error) {
return false, ErrUnsupported
}
// 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 PedersenNeg(commitment []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenNegOpening(opening []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenAddNum(commitment []byte, value uint64) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenAddCommitment(commitment1, commitment2 []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenAddOpening(opening1, opening2 []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenAddCommitmentWithOpening(commitment1, commitment2, opening1, opening2 []byte) ([]byte, []byte, error) {
return nil, nil, ErrUnsupported
}
// 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 PedersenSubNum(commitment []byte, value uint64) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenSubCommitment(commitment1, commitment2 []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenSubOpening(opening1, opening2 []byte) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenSubCommitmentWithOpening(commitment1, commitment2, opening1, opening2 []byte) ([]byte, []byte, error) {
return nil, nil, ErrUnsupported
}
// 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 PedersenMulNum(commitment1 []byte, value uint64) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenMulOpening(opening1 []byte, value uint64) ([]byte, error) {
return nil, ErrUnsupported
}
// 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 PedersenMulNumWithOpening(commitment []byte, opening []byte, value uint64) ([]byte, []byte, error) {
return nil, nil, ErrUnsupported
}