This commit is contained in:
Jimmy Song 2017-05-13 16:30:20 -07:00
parent 3ac7b7eb7b
commit 173404a991
2 changed files with 40 additions and 0 deletions

View file

@ -9,6 +9,11 @@ const (
TestNetwork = 53
)
// Zero, Identity and L?
var Zero = Key{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
var Identity = Key{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
var L = Key{0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}
// The other basepoint for use in Pedersen Commitments, which is used for
// Confidential Transactions
// H = G.HashToEC(), where G is the basepoint

View file

@ -78,6 +78,37 @@ type RctSig struct {
RctSigPrunable
}
func (k *Key) ToExtended() (result *ExtendedGroupElement) {
result = new(ExtendedGroupElement)
result.FromBytes((*[32]byte).k)
return
}
// add two points together
func (k *Key) Add(k2 *Key) (result *Key) {
a := k.ToExtended()
b = new(CachedGroupElement)
k2.ToExtended().ToCached(b)
c := new(CompletedGroupElement)
geAdd(c, a, b)
tmp := new(ExtendedGroupElement)
c.ToExtended(tmp)
tmp.ToBytes(result)
return
}
func (k *Key) ScalarMult(a *Key) (result *Key) {
tmp := new(ProjectiveGroupElement)
GeScalarMult(tmp, a, k.ToExtended())
tmp.ToBytes(result)
return
}
// a is a scalar, k2 is a point
func (k *Key) ScalarMultAdd(a, k2 *Key) (result *Key) {
}
func (k *Key64) Serialize() (result []byte) {
for _, key := range k {
result = append(result, key[:]...)
@ -154,6 +185,10 @@ func (r *RctSig) PrunableHash() (result Hash) {
return
}
func (r *rctSig) VerifyRctSimple() (result bool) {
}
func ParseKey(buf io.Reader) (result Key, err error) {
key := make([]byte, KeyLength)
if _, err = buf.Read(key); err != nil {