aboutsummaryrefslogtreecommitdiff
path: root/commitment/commitment.go
blob: c958987cd714aea9ca7dd33706bc0d38ccecbc32 (plain)
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
// Implements the data structures and methods for
// creating a commitment for the SEAL protocol
package commitment

import (
	"fmt"

	"kesim.org/seal/curve"
)

type Scalar = curve.Curve25519Scalar
type Point = curve.Curve25519Point

var Curve = curve.Curve25519

type Bidder struct {
	private struct {
		id *Scalar
	}
	Id *Point
}

type Bid struct {
	Bidder *Point
	zbid   uint64 // bigendian encoding of the bid
	n      uint8  // number of bits encoded in zbid.
	bits   []Bit  // derived from zbid
}

type Bit struct {
	set bool
	a   *Scalar
	b   *Scalar
	com *BitCommitment
}

type BitCommitment struct {
	Gab *Point
	A   *Point
	B   *Point

	Proofs struct {
		A *Proof
		B *Proof
	}
}

type Proof struct {
	V *Point  `json:"V"`
	R *Scalar `json:"r"`
}

func NewBid(price uint64, bitlength uint8) (*Bidder, error) {
	if bitlength > 63 {
		return nil, fmt.Errorf("bitlength too large, maximum is 63")
	}

	return nil, fmt.Errorf("NewBid not implemented")
}