more efficient pubkey generation

This commit is contained in:
Jimmy Song 2017-05-25 17:04:59 -04:00
parent d245705108
commit 91b2ed32a5
3 changed files with 17 additions and 3 deletions

View file

@ -15,3 +15,18 @@ func HexToHash(h string) (result Hash) {
copy(result[:], byteSlice)
return
}
// RandomPubKey takes a random scalar, interprets it as a point on the curve
// and then multiplies by 8 to make it a point in the Group
func RandomPubKey() (result *Key) {
result = new(Key)
p3 := new(ExtendedGroupElement)
var p1 ProjectiveGroupElement
var p2 CompletedGroupElement
h := RandomScalar()
p1.FromBytes(h)
GeMul8(&p2, &p1)
p2.ToExtended(p3)
p3.ToBytes(result)
return
}

View file

@ -133,7 +133,7 @@ func AddKeys2(result, a, b, B *Key) {
return
}
// subtract two points together
// subtract two points A - B
func SubKeys(diff, k1, k2 *Key) {
a := k1.ToExtended()
b := new(CachedGroupElement)

View file

@ -1819,8 +1819,7 @@ func TestCreateSignature(t *testing.T) {
privKey, _ := NewKeyPair()
mixins := make([]Key, numMixins)
for j := 0; j < numMixins; j++ {
_, pk := NewKeyPair()
mixins[j] = *pk
mixins[j] = *RandomPubKey()
}
keyImage, pubKeys, sig := CreateSignature(&hash, mixins, privKey)
if !VerifySignature(&hash, &keyImage, pubKeys, sig) {