Documentation ¶
Index ¶
- Constants
- Variables
- func Compare(a, b *Scalar) int
- func IsPointEqual(pa *Point, pb *Point) bool
- func IsScalarEqual(sc1, sc2 *Scalar) bool
- func Reverse(x C25519.Key) (result C25519.Key)
- type PedersenCommitment
- type Point
- func (p *Point) Add(pa, pb *Point) *Point
- func (p *Point) AddPedersen(a *Scalar, A *Point, b *Scalar, B *Point) *Point
- func (p *Point) Derive(pa *Point, a *Scalar, b *Scalar) *Point
- func (p *Point) FromBytes(b [Ed25519KeySize]byte) (*Point, error)
- func (p *Point) FromBytesS(b []byte) (*Point, error)
- func (p Point) GetKey() C25519.Key
- func (p *Point) Identity() *Point
- func (p *Point) InvertScalarMult(pa *Point, a *Scalar) *Point
- func (p *Point) InvertScalarMultBase(a *Scalar) *Point
- func (p Point) IsIdentity() bool
- func (p *Point) MultiScalarMult(sList []*Scalar, pList []*Point) *Point
- func (p Point) PointValid() bool
- func (p *Point) ScalarMult(pa *Point, a *Scalar) *Point
- func (p *Point) ScalarMultBase(a *Scalar) *Point
- func (p *Point) Set(q *Point) *Point
- func (p *Point) SetKey(v *C25519.Key) (*Point, error)
- func (p Point) String() string
- func (p *Point) Sub(pa, pb *Point) *Point
- func (p Point) ToBytes() [Ed25519KeySize]byte
- func (p Point) ToBytesS() []byte
- type Scalar
- func (sc *Scalar) Add(a, b *Scalar) *Scalar
- func (sc *Scalar) Exp(a *Scalar, v uint64) *Scalar
- func (sc *Scalar) FromBytes(b [Ed25519KeySize]byte) *Scalar
- func (sc *Scalar) FromBytesS(b []byte) *Scalar
- func (sc *Scalar) FromUint64(v uint64) *Scalar
- func (sc Scalar) GetKey() C25519.Key
- func (sc *Scalar) Invert(a *Scalar) *Scalar
- func (sc *Scalar) IsOne() bool
- func (sc *Scalar) IsZero() bool
- func (sc *Scalar) Mul(a, b *Scalar) *Scalar
- func (sc *Scalar) MulAdd(a, b, c *Scalar) *Scalar
- func (sc *Scalar) ScalarValid() bool
- func (sc *Scalar) Set(v *Scalar) *Scalar
- func (sc *Scalar) SetKey(v *C25519.Key) (*Scalar, error)
- func (sc *Scalar) SetKeyUnsafe(v *C25519.Key) *Scalar
- func (sc Scalar) String() string
- func (sc *Scalar) Sub(a, b *Scalar) *Scalar
- func (sc Scalar) ToBytes() [Ed25519KeySize]byte
- func (sc Scalar) ToBytesS() []byte
- func (sc *Scalar) ToUint64Little() uint64
Constants ¶
const ( Ed25519KeySize = 32 TxRandomIndexSize = 4 CStringBulletProof = "bulletproof" CStringAssetTag = "blindedassettag" CStringOTA = "onetimeaddress" )
Variables ¶
var PedCom = NewPedersenParams()
PedCom represents the parameters used in the Pedersen commitment scheme.
Functions ¶
func IsScalarEqual ¶
IsScalarEqual checks if two scalars are the same.
Types ¶
type PedersenCommitment ¶
type PedersenCommitment struct {
G []*Point // generators
}
PedersenCommitment represents the base points for the Pedersen commitment scheme.
- G[0]: the base point for key-related commitments.
- G[1]: the base point for value commitments.
- G[2]: the base point for SNDerivator commitments.
- G[3]: the base point for shardID commitments.
- G[4]: the base point for randomness factor.
func NewPedersenParams ¶
func NewPedersenParams() PedersenCommitment
NewPedersenParams creates new PedersenCommitment parameters. It also sets GBase as G[1] and HBase as G[4].
func (PedersenCommitment) CommitAll ¶
func (com PedersenCommitment) CommitAll(openings []*Scalar) (*Point, error)
CommitAll commits a list of values using the corresponding base points.
func (PedersenCommitment) CommitAtIndex ¶
func (com PedersenCommitment) CommitAtIndex(value, rand *Scalar, index byte) *Point
CommitAtIndex commits specific value using the base point at the given index.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point represents an elliptic curve point. It only needs 32 bytes to represent a point.
var GBase *Point
GBase is the base point for committing UTXOs' value.
var HBase *Point
HBase is the base point for randomness factor.
func HashToPoint ¶
HashToPoint returns the Point value of the hash of b.
func HashToPointFromIndex ¶
HashToPointFromIndex returns the hash of the concatenation of padStr and index.
func RandomPoint ¶
func RandomPoint() *Point
RandomPoint returns a random Point on the elliptic curve.
func (*Point) AddPedersen ¶
AddPedersen sets p = aA + bB and returns p.
func (*Point) FromBytes ¶
func (p *Point) FromBytes(b [Ed25519KeySize]byte) (*Point, error)
FromBytes sets an array of 32 bytes to a Point.
func (*Point) FromBytesS ¶
FromBytesS sets a slice of bytes to a Point.
func (*Point) InvertScalarMult ¶
InvertScalarMult sets p = (1/a) * pa and returns p.
func (*Point) InvertScalarMultBase ¶
InvertScalarMultBase sets p = (1/a) * G and returns p.
func (Point) IsIdentity ¶
IsIdentity checks if p is the identity point.
func (*Point) MultiScalarMult ¶
MultiScalarMult sets p = sum(sList[i] * pList[i]) and returns p.
func (*Point) ScalarMult ¶
ScalarMult sets p = a * pa and returns p.
func (*Point) ScalarMultBase ¶
ScalarMultBase set p = a * G, where a is a scalar and G is the curve base point and returns p.
func (Point) ToBytes ¶
func (p Point) ToBytes() [Ed25519KeySize]byte
ToBytes returns an 32-byte long array from a Point.
type Scalar ¶
type Scalar struct {
// contains filtered or unexported fields
}
Scalar represents a scalar of an elliptic curve.
func HashToScalar ¶
HashToScalar returns the hash of msg in the form of a scalar.
func (*Scalar) FromBytes ¶
func (sc *Scalar) FromBytes(b [Ed25519KeySize]byte) *Scalar
FromBytes sets an array of 32 bytes to a Scalar.
func (*Scalar) FromBytesS ¶
FromBytesS sets a slice of bytes to a Scalar.
func (*Scalar) FromUint64 ¶
FromUint64 sets the value of a Scalar to v.
func (*Scalar) ScalarValid ¶
ScalarValid checks if a Scalar is valid.
func (*Scalar) SetKeyUnsafe ¶
SetKeyUnsafe sets v as the key of Scalar (without caching errors).
func (Scalar) ToBytes ¶
func (sc Scalar) ToBytes() [Ed25519KeySize]byte
ToBytes returns an 32-byte long array from a Scalar.
func (*Scalar) ToUint64Little ¶
ToUint64Little returns the uint64 value of a Scalar.